A class representing a set of utilities allowing modification of an ONNX model. More...
#include <editor.hpp>
Public Member Functions | |
ONNXModelEditor (const std::string &model_path) | |
Creates an editor from a model file located on a storage device. The file is parsed and loaded into the m_model_proto member variable. More... | |
void | set_input_types (const std::map< std::string, element::Type_t > &input_types) |
Modifies the in-memory representation of the model (m_model_proto) by setting custom input types for all inputs specified in the provided map. More... | |
void | set_input_shapes (const std::map< std::string, ngraph::PartialShape > &input_shapes) |
Modifies the in-memory representation of the model (m_model_proto) by setting custom input shapes for all inputs specified in the provided map. More... | |
void | set_input_values (const std::map< std::string, std::shared_ptr< ngraph::op::Constant >> &input_values) |
Modifies the in-memory representation of the model by setting custom input values for inputs specified in the provided map. More... | |
ONNX_NAMESPACE::ModelProto & | model () const |
Returns a non-const reference to the underlying ModelProto object, possibly modified by the editor's API calls. More... | |
const std::string & | model_path () const |
Returns the path to the original model file. | |
void | serialize (const std::string &out_file_path) const |
Saves the possibly model held by this class to a file. Serializes in binary mode. More... | |
A class representing a set of utilities allowing modification of an ONNX model.
ngraph::onnx_import::ONNXModelEditor::ONNXModelEditor | ( | const std::string & | model_path | ) |
Creates an editor from a model file located on a storage device. The file is parsed and loaded into the m_model_proto member variable.
model_path | Path to the file containing the model. |
ONNX_NAMESPACE::ModelProto& ngraph::onnx_import::ONNXModelEditor::model | ( | ) | const |
Returns a non-const reference to the underlying ModelProto object, possibly modified by the editor's API calls.
void ngraph::onnx_import::ONNXModelEditor::serialize | ( | const std::string & | out_file_path | ) | const |
Saves the possibly model held by this class to a file. Serializes in binary mode.
out_file_path | A path to the file where the modified model should be dumped. |
void ngraph::onnx_import::ONNXModelEditor::set_input_shapes | ( | const std::map< std::string, ngraph::PartialShape > & | input_shapes | ) |
Modifies the in-memory representation of the model (m_model_proto) by setting custom input shapes for all inputs specified in the provided map.
input_shapes | A collection of pairs {input_name: new_input_shape} that should be used to modified the ONNX model loaded from a file. This method throws an exception if the model doesn't contain any of the inputs specified in its parameter. |
void ngraph::onnx_import::ONNXModelEditor::set_input_types | ( | const std::map< std::string, element::Type_t > & | input_types | ) |
Modifies the in-memory representation of the model (m_model_proto) by setting custom input types for all inputs specified in the provided map.
input_types | A collection of pairs {input_name: new_input_type} that should be used to modified the ONNX model loaded from a file. This method throws an exception if the model doesn't contain any of the inputs specified in its parameter. |
void ngraph::onnx_import::ONNXModelEditor::set_input_values | ( | const std::map< std::string, std::shared_ptr< ngraph::op::Constant >> & | input_values | ) |
Modifies the in-memory representation of the model by setting custom input values for inputs specified in the provided map.
input_values | A collection of pairs {input_name: new_input_values} used to update the ONNX model. Initializers already existing are overwritten. |