Data Structures | Typedefs | Functions
ngraph::onnx_import Namespace Reference

ONNX importer features namespace. Functions in this namespace make it possible to use ONNX models. More...

Data Structures

class  Node
 
class  ONNXModelEditor
 A class representing a set of utilities allowing modification of an ONNX model. More...
 

Typedefs

using Operator = std::function< OutputVector(const Node &)>
 Function which transforms single ONNX operator to nGraph sub-graph.
 
using OperatorSet = std::unordered_map< std::string, std::reference_wrapper< const Operator > >
 Map which contains ONNX operators accessible by std::string value as a key.
 

Functions

std::ostream & operator<< (std::ostream &outs, const Node &node)
 
NGRAPH_HELPER_DLL_IMPORT std::set< std::string > get_supported_operators (std::int64_t version, const std::string &domain)
 Returns a set of names of supported operators for the given opset version and domain. More...
 
NGRAPH_HELPER_DLL_IMPORT bool is_operator_supported (const std::string &op_name, std::int64_t version, const std::string &domain="ai.onnx")
 Determines whether ONNX operator is supported. More...
 
NGRAPH_HELPER_DLL_IMPORT std::shared_ptr< Functionimport_onnx_model (std::istream &stream, const std::string &model_path="")
 Imports and converts an serialized ONNX model from the input stream to an nGraph Function representation. More...
 
NGRAPH_HELPER_DLL_IMPORT std::shared_ptr< Functionimport_onnx_model (const std::string &file_path)
 Imports and converts an ONNX model from the input file to an nGraph Function representation. More...
 
NGRAPH_HELPER_DLL_IMPORT std::shared_ptr< Functionimport_onnx_model (const ONNXModelEditor &model_editor)
 Imports an ONNX model modified by the ONNXModelEditor wrapper. More...
 
NGRAPH_HELPER_DLL_IMPORT void register_operator (const std::string &name, std::int64_t version, const std::string &domain, Operator fn)
 Registers ONNX custom operator. The function performs the registration of external ONNX operator which is not part of ONNX importer. More...
 
NGRAPH_HELPER_DLL_IMPORT void unregister_operator (const std::string &name, std::int64_t version, const std::string &domain)
 Unregisters ONNX custom operator. The function unregisters previously registered operator. More...
 

Detailed Description

ONNX importer features namespace. Functions in this namespace make it possible to use ONNX models.

Function Documentation

◆ get_supported_operators()

NGRAPH_HELPER_DLL_IMPORT std::set<std::string> ngraph::onnx_import::get_supported_operators ( std::int64_t  version,
const std::string &  domain 
)

Returns a set of names of supported operators for the given opset version and domain.

Parameters
[in]versionAn opset version to get the supported operators for.
[in]domainA domain to get the supported operators for.
Returns
The set containing names of supported operators.

◆ import_onnx_model() [1/3]

NGRAPH_HELPER_DLL_IMPORT std::shared_ptr<Function> ngraph::onnx_import::import_onnx_model ( const ONNXModelEditor model_editor)

Imports an ONNX model modified by the ONNXModelEditor wrapper.

Note
Refer to the ONNXModelEditor documentation for available modifications.
Parameters
[in]model_editorReference to the model editor object instance.
Returns
An nGraph function representing the previously modified ONNX model.

◆ import_onnx_model() [2/3]

NGRAPH_HELPER_DLL_IMPORT std::shared_ptr<Function> ngraph::onnx_import::import_onnx_model ( const std::string &  file_path)

Imports and converts an ONNX model from the input file to an nGraph Function representation.

Note
If file parsing fails or the ONNX model contains unsupported ops, the function throws an ngraph_error exception.
Parameters
[in]file_pathThe path to a file containing the ONNX model (relative or absolute).
Returns
An nGraph function that represents a single output from the created graph.

◆ import_onnx_model() [3/3]

NGRAPH_HELPER_DLL_IMPORT std::shared_ptr<Function> ngraph::onnx_import::import_onnx_model ( std::istream &  stream,
const std::string &  model_path = "" 
)

Imports and converts an serialized ONNX model from the input stream to an nGraph Function representation.

Note
If stream parsing fails or the ONNX model contains unsupported ops, the function throws an ngraph_error exception.
Parameters
[in]streamThe input stream (e.g. file stream, memory stream, etc).
[in]model_pathThe path to the imported onnx model. It is required if the imported model uses data saved in external files.
Returns
An nGraph function that represents a single output from the created graph.

◆ is_operator_supported()

NGRAPH_HELPER_DLL_IMPORT bool ngraph::onnx_import::is_operator_supported ( const std::string &  op_name,
std::int64_t  version,
const std::string &  domain = "ai.onnx" 
)

Determines whether ONNX operator is supported.

Parameters
[in]op_nameThe ONNX operator name.
[in]versionThe ONNX operator set version.
[in]domainThe domain the ONNX operator is registered to. If not set, the default domain "ai.onnx" is used.
Returns
true if operator is supported, false otherwise.

◆ register_operator()

NGRAPH_HELPER_DLL_IMPORT void ngraph::onnx_import::register_operator ( const std::string &  name,
std::int64_t  version,
const std::string &  domain,
Operator  fn 
)

Registers ONNX custom operator. The function performs the registration of external ONNX operator which is not part of ONNX importer.

Note
The operator must be registered before calling "import_onnx_model" functions.
Parameters
nameThe ONNX operator name.
versionThe ONNX operator set version.
domainThe domain the ONNX operator is registered to.
fnThe function providing the implementation of the operator which transforms the single ONNX operator to an nGraph sub-graph.

◆ unregister_operator()

NGRAPH_HELPER_DLL_IMPORT void ngraph::onnx_import::unregister_operator ( const std::string &  name,
std::int64_t  version,
const std::string &  domain 
)

Unregisters ONNX custom operator. The function unregisters previously registered operator.

Parameters
nameThe ONNX operator name.
versionThe ONNX operator set version.
domainThe domain the ONNX operator is registered to.