onnx API reference
88 public APIs from onnx (onnx/onnx) — 14 classes, 61 functions, 13 methods. Signatures extracted by static analysis of the actual source.
Repository: onnx/onnx
| Kind | Count |
|---|---|
| Classes | 14 |
| Functions | 61 |
| Methods | 13 |
API list
method
onnx.backend.base.Backend.supports_device(device:str) -> boolChecks whether the backend is compiled with particular device support.
class
onnx.backend.base.DeviceTypeDescribes device type.
func
onnx.checker.check_model(model:onnx.ModelProto | str | bytes | os.PathLike, full_check:bool=False, skip_opset_compatibility_check:bool=False, check_custom_domain:bool=False) -> NoneCheck the consistency of a model.
func
onnx.defs.get_function_ops() -> list[OpSchema]Return operators defined as functions.
func
onnx.defs.onnx_ml_opset_version() -> intReturn current opset for domain `ai.onnx.ml`.
func
onnx.defs.onnx_opset_version() -> intReturn current opset for domain `ai.onnx`.
func
onnx.defs.register_schema(schema:OpSchema) -> NoneRegister a user provided OpSchema.
func
onnx.external_data_helper.load_external_data_for_tensor(tensor:TensorProto, base_dir:str) -> NoneLoads data from an external file for tensor.
func
onnx.external_data_helper.uses_external_data(tensor:TensorProto) -> boolReturns true if the tensor stores data in an external location.
func
onnx.helper.get_all_tensor_dtypes() -> KeysView[int]Get all tensor types from TensorProto.
func
onnx.helper.make_attribute(key:str, value:Any, doc_string:str | None=None, attr_type:int | None=None) -> AttributeProtoMakes an AttributeProto based on the value type.
func
onnx.helper.make_map(name:str, key_type:int, keys:list[Any], values:SequenceProto) -> MapProtoMake a Map with specified key-value pair arguments.
func
onnx.helper.make_map_type_proto(key_type:int, value_type:TypeProto) -> TypeProtoMakes a map TypeProto.
func
onnx.helper.make_node(op_type:str, inputs:Sequence[str], outputs:Sequence[str], name:str | None=None, doc_string:str | None=None, domain:str | None=None, overload:str | None=None, **kwargs:Any) -> NodeProtoConstruct a NodeProto.
func
onnx.helper.make_operatorsetid(domain:str, version:int) -> OperatorSetIdProtoConstruct an OperatorSetIdProto.
func
onnx.helper.make_opsetid(domain:str, version:int) -> OperatorSetIdProtoConstruct an OperatorSetIdProto.
func
onnx.helper.make_optional(name:str, elem_type:OptionalProto.DataType, value:google.protobuf.message.Message | None) -> OptionalProtoMake an Optional with specified value arguments.
func
onnx.helper.make_optional_type_proto(inner_type_proto:TypeProto) -> TypeProtoMakes an optional TypeProto.
func
onnx.helper.make_sequence(name:str, elem_type:SequenceProto.DataType, values:Sequence[Any]) -> SequenceProtoMake a Sequence with specified value arguments.
func
onnx.helper.make_sequence_type_proto(inner_type_proto:TypeProto) -> TypeProtoMakes a sequence TypeProto.
func
onnx.helper.make_tensor(name:str, data_type:int, dims:Sequence[int], vals:Sequence[int | float] | bytes | np.ndarray, raw:bool=False) -> TensorProtoMake a TensorProto with specified arguments.
func
onnx.helper.make_value_info(name:str, type_proto:TypeProto, doc_string:str='') -> ValueInfoProtoMakes a ValueInfoProto with the given type_proto.
func
onnx.helper.np_dtype_to_tensor_dtype(np_dtype:np.dtype) -> TensorProto.DataTypeConvert a numpy's dtype to corresponding tensor type.
func
onnx.helper.printable_graph(graph:GraphProto, prefix:str='') -> strDisplay a GraphProto as a string.
func
onnx.helper.strip_doc_string(proto:google.protobuf.message.Message) -> NoneEmpties `doc_string` field on any nested protobuf messages
func
onnx.helper.tensor_dtype_to_field(tensor_dtype:int) -> strConvert a TensorProto's data_type to corresponding field name for storage.
func
onnx.helper.tensor_dtype_to_np_dtype(tensor_dtype:int) -> np.dtypeConvert a TensorProto's data_type to corresponding numpy dtype.
func
onnx.helper.tensor_dtype_to_string(tensor_dtype:int) -> strGet the name of given TensorProto's data_type.
func
onnx.inliner.inline_local_functions(model:onnx.ModelProto, convert_version:bool=False) -> onnx.ModelProtoInline model-local functions in given model.
func
onnx.inliner.inline_selected_functions(model:onnx.ModelProto, function_ids:list[tuple[str, str]], exclude:bool=False, inline_schema_functions:bool=False) -> onnx.ModelProtoInline selected functions in given model.
func
onnx.load_model(f:IO[bytes] | str | os.PathLike, format:_SupportedFormat | None=None, load_external_data:bool=True) -> ModelProtoLoads a serialized ModelProto into memory.
func
onnx.load_tensor(f:IO[bytes] | str | os.PathLike, format:_SupportedFormat | None=None) -> TensorProtoLoads a serialized TensorProto into memory.
func
onnx.model_container.make_large_tensor_proto(location:str, tensor_name:str, tensor_type:int, shape:tuple[int, ...]) -> onnx.TensorProtoCreate an external tensor.
func
onnx.numpy_helper.create_random_int(input_shape:tuple[int], dtype:np.dtype, seed:int=1) -> np.ndarrayCreate random integer array for backend/test/case/node.
func
onnx.numpy_helper.from_dict(dict_:dict[Any, Any], name:str | None=None) -> onnx.MapProtoConverts a Python dictionary into a map def.
func
onnx.numpy_helper.from_list(lst:list[Any], name:str | None=None, dtype:int | None=None) -> onnx.SequenceProtoConverts a list into a sequence def.
func
onnx.numpy_helper.from_optional(opt:Any | None, name:str | None=None, dtype:int | None=None) -> onnx.OptionalProtoConverts an optional value into a Optional def.
func
onnx.numpy_helper.saturate_cast(x:np.ndarray, dtype:np.dtype) -> np.ndarraySaturate cast for numeric types.
func
onnx.numpy_helper.to_array(tensor:onnx.TensorProto, base_dir:str='') -> np.ndarrayConverts a tensor def object to a numpy array.
func
onnx.numpy_helper.to_dict(map_proto:onnx.MapProto) -> dict[Any, Any]Converts a map def to a Python dictionary.
func
onnx.numpy_helper.to_float8e8m0(x:np.ndarray, saturate:bool=True, round_mode:str='up') -> np.ndarrayConvert float32 NumPy array to float8e8m0 representation.
func
onnx.numpy_helper.to_list(sequence:onnx.SequenceProto) -> list[Any]Converts a sequence def to a Python list.
func
onnx.numpy_helper.to_optional(optional:onnx.OptionalProto) -> Any | NoneConverts an optional def to a Python optional.
func
onnx.numpy_helper.tobytes_little_endian(array:np.ndarray) -> bytesConverts an array into bytes in little endian byte order.
func
onnx.parser.parse_function(function_text:str) -> onnx.FunctionProtoParse a string to build a FunctionProto.
func
onnx.parser.parse_graph(graph_text:str) -> onnx.GraphProtoParse a string to build a GraphProto.
func
onnx.parser.parse_model(model_text:str) -> onnx.ModelProtoParse a string to build a ModelProto.
func
onnx.parser.parse_node(node_text:str) -> onnx.NodeProtoParse a string to build a NodeProto.
class
onnx.reference.op_run.OpFunctionRuns a custom function.
class
onnx.reference.op_run.OpRunAncestor to all operators in this subfolder.
method
onnx.reference.op_run.OpRun.create(n_inputs:int | None=None, n_outputs:int | None=None, verbose:int=0, **kwargs:Any) -> AnyInstantiates this class based on the given information.
method
onnx.reference.op_run.OpRun.domain() -> strReturns node attribute `domain`.
method
onnx.reference.op_run.OpRun.eval(*n_outputs:int | None=None, *verbose:int=0, *args:list[Any], **kwargs:Any) -> AnyEvaluates this operator.
method
onnx.reference.op_run.OpRun.input() -> Sequence[str]Returns node attribute `input`.
method
onnx.reference.op_run.OpRun.op_type() -> strReturns node attribute `op_type`.
method
onnx.reference.op_run.OpRun.output() -> Sequence[str]Returns node attribute `output`.
class
onnx.reference.op_run.OpRunExpandClass any operator to avoid must inherit from.
class
onnx.reference.op_run.RuntimeImplementationErrorRaised when no implementation was found for an operator.
class
onnx.reference.op_run.RuntimeTypeErrorRaised when a type of a variable is unexpected.
class
onnx.reference.op_run.SparseTensorSimple representation of a sparse tensor.
func
onnx.reference.op_run.to_sparse_tensor(att:onnx.AttributeProto) -> SparseTensorHosts a sparse tensor.
class
onnx.reference.ops._op.OpRunBinaryAncestor to all binary operators in this subfolder.
class
onnx.reference.ops._op.OpRunBinaryNumAncestor to all binary operators in this subfolder.
class
onnx.reference.ops._op.OpRunReduceNumpyImplements the reduce logic.
class
onnx.reference.ops._op.OpRunUnaryAncestor to all unary operators in this subfolder.
method
onnx.reference.ops._op.OpRunUnaryNum.run(x)Calls method ``OpRunUnary.run``.
func
onnx.reference.ops.aionnx_preview._op_list.load_op(domain:str, op_type:str, version:int | None, custom:Any=None) -> AnyLoads the implemented for a specified operator.
func
onnx.reference.ops.aionnx_preview_training._op_list.load_op(domain:str, op_type:str, version:int | None, custom:Any=None) -> AnyLoads the implemented for a specified operator.
func
onnx.reference.ops.aionnxml._common_classifier.compute_softmax_zero(values:np.ndarray) -> np.ndarrayThe function modifies the input inplace.
func
onnx.reference.ops.aionnxml._common_classifier.softmax(values:np.ndarray) -> np.ndarrayModifications in place.
func
onnx.reference.ops.aionnxml._common_classifier.softmax_zero(values:np.ndarray) -> np.ndarrayModifications in place.
func
onnx.reference.ops.aionnxml._op_list.load_op(domain:str, op_type:str, version:int | None, custom:Any=None) -> AnyLoads the implemented for a specified operator.
method
onnx.reference.ops.aionnxml.op_normalizer.Normalizer.norm_l1(x)L1 normalization
method
onnx.reference.ops.aionnxml.op_normalizer.Normalizer.norm_l2(x)L2 normalization
method
onnx.reference.ops.aionnxml.op_normalizer.Normalizer.norm_max(x)Max normalization
class
onnx.reference.ops.aionnxml.op_svm_helper.SVMCommonBase class for SVM.
class
onnx.reference.ops.aionnxml.op_svm_regressor.SVMRegressorThe class only implements `POST_TRANSFORM="NONE"`.
method
onnx.reference.ops.aionnxml.op_tree_ensemble_helper.TreeEnsemble.leaf_index_tree(X:np.ndarray, tree_id:int) -> intComputes the leaf index for one tree.
method
onnx.reference.ops.aionnxml.op_tree_ensemble_helper.TreeEnsemble.leave_index_tree(X:np.ndarray) -> np.ndarrayComputes the leaf index for all trees.
func
onnx.reference.ops.experimental._op_list.load_op(domain:str, op_type:str, version:int | None, custom:Any=None) -> AnyLoads the implemented for a specified operator.
class
onnx.reference.ops.op_blackman_window.BlackmanWindowBlankman windowing function.
func
onnx.reference.ops.op_matmul.numpy_matmul(a, b)Implements a matmul product.
func
onnx.reference.ops.op_scatter_elements.scatter_elements(data, indices, updates, axis=0, reduction=None)Scatter elements.
func
onnx.save_tensor(proto:TensorProto, f:IO[bytes] | str | os.PathLike, format:_SupportedFormat | None=None) -> NoneSaves the TensorProto to the specified path.
func
onnx.shape_inference.infer_shapes(model:ModelProto | bytes, check_type:bool=False, strict_mode:bool=False, data_prop:bool=False) -> ModelProtoApply shape inference to the provided ModelProto.
func
onnx.shape_inference.infer_shapes_path(model_path:str | os.PathLike, output_path:str | os.PathLike='', check_type:bool=False, strict_mode:bool=False, data_prop:bool=False) -> NoneTake model path for shape_inference.
func
onnx.utils.extract_model(input_path:str | os.PathLike, output_path:str | os.PathLike, input_names:list[str], output_names:list[str], check_model:bool=True, infer_shapes:bool=True) -> NoneExtracts sub-model from an ONNX model.
func
onnx.version_converter.convert_version(model:ModelProto, target_version:int) -> ModelProtoConvert opset version of the ModelProto.
About this data
These signatures were extracted from the public source of onnx/onnx
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.