ONE - On-device Neural Engine
Loading...
Searching...
No Matches
circle_resizer::ModelEditor Class Reference

#include <ModelEditor.h>

Public Member Functions

 ModelEditor (std::shared_ptr< CircleModel > circle_model)
 Initialize the editor with CircleModel object.
 
ModelEditorresize_inputs (const std::vector< Shape > &new_inputs_shapes)
 Resize the model. It means changing shape of the inputs and propagating changes through the graph.
 

Detailed Description

The class to modify circle models.

Definition at line 33 of file ModelEditor.h.

Constructor & Destructor Documentation

◆ ModelEditor()

ModelEditor::ModelEditor ( std::shared_ptr< CircleModel circle_model)
explicit

Initialize the editor with CircleModel object.

Definition at line 67 of file ModelEditor.cpp.

67 : _circle_model{circle_model}
68{
69 assert(circle_model != nullptr); // FIX_CALLER_UNLESS
70}

Member Function Documentation

◆ resize_inputs()

ModelEditor & ModelEditor::resize_inputs ( const std::vector< Shape > &  new_inputs_shapes)

Resize the model. It means changing shape of the inputs and propagating changes through the graph.

Exceptions:

  • std::runtime_error if the new_inputs_shapes are invalid. It can happens for scenarios like:
    • new shapes for NOT all inputs are provided
    • an exception was thrown during shape inference pass

Definition at line 72 of file ModelEditor.cpp.

73{
74 auto graph = _circle_model->module()->graph();
75 change_inputs_shapes(graph, new_inputs_shapes);
76
77 logo::Phase phase;
78 phase.emplace_back(std::make_unique<logo::RemoveDeadNodeWithQueryPass>());
79 phase.emplace_back(std::make_unique<luci::CircleShapeInferencePass>());
80 phase.emplace_back(std::make_unique<luci::CircleTypeInferencePass>());
81
83 try
84 {
85 phase_runner.run(phase);
86 }
87 catch (const std::exception &e)
88 {
89 throw std::runtime_error("Exception during resizing with message: " + std::string{e.what()});
90 }
91
92 return *this;
93}
std::vector< std::unique_ptr< Pass > > Phase
Definition Phase.h:31

Referenced by entry().


The documentation for this class was generated from the following files: