yobx.torch.torch_helper#
- yobx.torch.torch_helper.onnx_dtype_to_torch_dtype(itype: int) dtype[source]#
Converts an onnx type into a torch dtype.
- Parameters:
to – onnx dtype
- Returns:
torch dtype
- yobx.torch.torch_helper.to_numpy(tensor: Tensor) ndarray[source]#
Converts a
torch.Tensortonumpy.ndarray.
- yobx.torch.torch_helper.to_tensor(tensor: TensorProto, base_dir: str = '') Tensor[source]#
Converts a TensorProto to a torch.Tensor.
- Parameters:
tensor – a TensorProto object.
base_dir – if external tensor exists, base_dir can help to find the path to it
- Returns:
the converted torch tensor