onnx.numpy_helper¶
array¶
- onnx.numpy_helper.to_array(tensor: TensorProto) np.ndarray[Any] ¶
Converts a tensor def object to a numpy array.
- Inputs:
tensor: a TensorProto object.
- Returns:
arr: the converted array.
- onnx.numpy_helper.from_array(arr: np.ndarray[Any], name: Optional[Text] = None) TensorProto ¶
Converts a numpy array to a tensor def.
- Inputs:
arr: a numpy array. name: (optional) the name of the tensor.
- Returns:
tensor_def: the converted tensor def.
sequence, dictionary, optional¶
- onnx.numpy_helper.to_list(sequence: onnx.onnx_data_pb2.SequenceProto) List[Any] ¶
Converts a sequence def to a Python list.
- Inputs:
sequence: a SequenceProto object.
- Returns:
lst: the converted list.
- onnx.numpy_helper.from_list(lst: List[Any], name: Optional[str] = None, dtype: Optional[int] = None) onnx.onnx_data_pb2.SequenceProto ¶
Converts a list into a sequence def.
- Inputs:
lst: a Python list name: (optional) the name of the sequence. dtype: (optional) type of element in the input list, used for specifying
sequence values when converting an empty list.
- Returns:
sequence: the converted sequence def.
- onnx.numpy_helper.to_dict(map: MapProto) np.ndarray[Any] ¶
Converts a map def to a Python dictionary.
- Inputs:
map: a MapProto object.
- Returns:
dict: the converted dictionary.
- onnx.numpy_helper.from_dict(dict: Dict[Any, Any], name: Optional[str] = None) onnx.onnx_data_pb2.MapProto ¶
Converts a Python dictionary into a map def.
- Inputs:
dict: Python dictionary name: (optional) the name of the map.
- Returns:
map: the converted map def.
- onnx.numpy_helper.to_optional(optional: onnx.onnx_data_pb2.OptionalProto) Optional[Any] ¶
Converts an optional def to a Python optional.
- Inputs:
optional: an OptionalProto object.
- Returns:
opt: the converted optional.
- onnx.numpy_helper.from_optional(opt: Optional[Any], name: Optional[str] = None, dtype: Optional[int] = None) onnx.onnx_data_pb2.OptionalProto ¶
Converts an optional value into a Optional def.
- Inputs:
opt: a Python optional name: (optional) the name of the optional. dtype: (optional) type of element in the input, used for specifying
optional values when converting empty none. dtype must be a valid OptionalProto.DataType value
- Returns:
optional: the converted optional def.
tools¶
- onnx.numpy_helper.convert_endian(tensor: onnx.onnx_ml_pb2.TensorProto) None ¶
call to convert endianess of raw data in tensor. @params TensorProto: TensorProto to be converted.