Internal class for GraphBuilder. More...
#include <graph_builder_internal.hpp>
Single mutable holder of graph metadata + configuration; dependency-free. Metadata is populated either from a parsed model (via a GraphModel backend) or from a source Function.
Extra doc: https://github.com/casadi/casadi/wiki/L_2jv
Definition at line 65 of file graph_builder_internal.hpp.


Public Types | |
| using | weak_ref_type = WeakRefInternal |
Public Member Functions | |
| GraphBuilderInternal (const std::string &name, const std::vector< uint8_t > &model_data, const std::string &format, const Dict &opts) | |
| Construct from parsed model bytes of a given format. More... | |
| GraphBuilderInternal (const std::string &name, const Function &f, const Dict &opts) | |
| Construct from a source Function (export lifecycle) More... | |
| ~GraphBuilderInternal () override | |
| std::string | class_name () const override |
| Readable name of the internal class. More... | |
| void | disp (std::ostream &stream, bool more) const override |
| Print a description of the object. More... | |
| casadi_int | n_in () const |
| casadi_int | n_out () const |
| std::vector< std::string > | name_in () const |
| std::vector< std::string > | name_out () const |
| std::vector< casadi_int > | input_shape (const std::string &name) const |
| std::vector< casadi_int > | output_shape (const std::string &name) const |
| std::vector< std::string > | dynamic_params () const |
| Node | node (const std::string &name) const |
| std::vector< Node > | nodes () const |
| void | bind_dim (const std::string ¶m, casadi_int value) |
| void | bind_shape (const std::string &input_name, const std::vector< casadi_int > &shape) |
| void | set_value (const std::string &input_name, const std::vector< double > &value) |
| Function | create_function (const std::string &name, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts) const |
| void | export_onnx (const std::string &filename, const Dict &opts) |
| void | add_node (const Node &n) |
| Append a tensor descriptor (called by a backend during fill_metadata) More... | |
| void | clear_nodes () |
| Drop all tensor descriptors (called by a backend before re-filling) More... | |
| std::vector< casadi_int > | resolved_shape (const Node &n) const |
| const Node & | find (const std::string &name, const std::string &io) const |
| Locate a node by name in a given I/O role (throws if absent) More... | |
| casadi_int | getCount () const |
| Get the reference count. More... | |
| std::string | debug_repr (const SharedObjectInternal *) const |
| GenericWeakRef< SharedObject, SharedObjectInternal > * | weak () |
| Get a weak reference to the object. More... | |
| const std::vector< Node > & | node_list () const |
| const std::map< std::string, casadi_int > & | dim_bindings () const |
Public Attributes | |
| std::string | name_ |
| std::string | format_ |
| std::vector< uint8_t > | model_data_ |
| Function | fun_ |
| Source Function (export lifecycle); null when built from a model. More... | |
| GraphModel | model_ |
| Parsed model backend (import lifecycle); null when built from a Function. More... | |
| std::vector< Node > | nodes_ |
| Tensor metadata (inputs followed by outputs) More... | |
| std::map< std::string, casadi_int > | dim_bindings_ |
| Pending configuration carried into create() More... | |
| std::map< std::string, std::vector< casadi_int > > | input_shapes_ |
| std::map< std::string, std::vector< double > > | input_values_ |
Protected Member Functions | |
| void | initSingleton () |
| void | destroySingleton () |
| B | shared_from_this () |
| Get a shared object from the current internal object. More... | |
| const B | shared_from_this () const |
| Get a shared object from the current internal object. More... | |
|
inherited |
Definition at line 152 of file shared_object.hpp.
| casadi::GraphBuilderInternal::GraphBuilderInternal | ( | const std::string & | name, |
| const std::vector< uint8_t > & | model_data, | ||
| const std::string & | format, | ||
| const Dict & | opts | ||
| ) |
Definition at line 146 of file graph_builder.cpp.
References casadi::GraphModel::fill_metadata(), and model_.
| casadi::GraphBuilderInternal::GraphBuilderInternal | ( | const std::string & | name, |
| const Function & | f, | ||
| const Dict & | opts | ||
| ) |
Definition at line 154 of file graph_builder.cpp.
|
override |
Definition at line 160 of file graph_builder.cpp.
|
inline |
Definition at line 98 of file graph_builder_internal.hpp.
Referenced by casadi::Onnx::fill_metadata().
|
inline |
Definition at line 87 of file graph_builder_internal.hpp.
| void casadi::GraphBuilderInternal::bind_shape | ( | const std::string & | input_name, |
| const std::vector< casadi_int > & | shape | ||
| ) |
Definition at line 260 of file graph_builder.cpp.
References dim_bindings_, casadi::Node::dim_params, casadi::Node::dimension, find(), and input_shapes_.
|
inlineoverridevirtual |
Implements casadi::SharedObjectInternal.
Definition at line 74 of file graph_builder_internal.hpp.
|
inline |
Definition at line 100 of file graph_builder_internal.hpp.
Referenced by casadi::Onnx::fill_metadata().
| Function casadi::GraphBuilderInternal::create_function | ( | const std::string & | name, |
| const std::vector< std::string > & | name_in, | ||
| const std::vector< std::string > & | name_out, | ||
| const Dict & | opts | ||
| ) | const |
Definition at line 272 of file graph_builder.cpp.
References casadi::OnnxFunction::create(), casadi::GraphModel::import_symbolic(), casadi::GenericShared< Shared, Internal >::is_null(), model_, and model_data_.
|
inherited |
Definition at line 62 of file generic_shared_internal.hpp.
|
inlineprotectedinherited |
Called in the destructor of singletons
Definition at line 77 of file generic_shared_internal.hpp.
|
inline |
Read-only views for backends
Definition at line 105 of file graph_builder_internal.hpp.
Referenced by casadi::Onnx::import_symbolic().
|
overridevirtual |
Implements casadi::SharedObjectInternal.
Definition at line 311 of file graph_builder.cpp.
References dynamic_params(), n_in(), n_out(), name_, and nodes_.
| std::vector< std::string > casadi::GraphBuilderInternal::dynamic_params | ( | ) | const |
| void casadi::GraphBuilderInternal::export_onnx | ( | const std::string & | filename, |
| const Dict & | opts | ||
| ) |
Definition at line 297 of file graph_builder.cpp.
References casadi::GraphModel::export_symbolic(), casadi::filename(), format_, fun_, casadi::GenericShared< Shared, Internal >::is_null(), and model_data_.
| const Node & casadi::GraphBuilderInternal::find | ( | const std::string & | name, |
| const std::string & | io | ||
| ) | const |
Definition at line 200 of file graph_builder.cpp.
Referenced by bind_shape(), input_shape(), output_shape(), and set_value().
|
inherited |
Definition at line 60 of file generic_shared_internal.hpp.
|
inlineprotectedinherited |
Called in the constructor of singletons to avoid that the counter reaches zero
Definition at line 71 of file generic_shared_internal.hpp.
| std::vector< casadi_int > casadi::GraphBuilderInternal::input_shape | ( | const std::string & | name | ) | const |
Definition at line 225 of file graph_builder.cpp.
References casadi::Node::dimension, and find().
| casadi_int casadi::GraphBuilderInternal::n_in | ( | ) | const |
| casadi_int casadi::GraphBuilderInternal::n_out | ( | ) | const |
| std::vector< std::string > casadi::GraphBuilderInternal::name_in | ( | ) | const |
| std::vector< std::string > casadi::GraphBuilderInternal::name_out | ( | ) | const |
| Node casadi::GraphBuilderInternal::node | ( | const std::string & | name | ) | const |
|
inline |
Read-only views for backends
Definition at line 104 of file graph_builder_internal.hpp.
Referenced by casadi::OnnxFunction::OnnxFunction().
|
inline |
Definition at line 85 of file graph_builder_internal.hpp.
| std::vector< casadi_int > casadi::GraphBuilderInternal::output_shape | ( | const std::string & | name | ) | const |
Definition at line 228 of file graph_builder.cpp.
References casadi::Node::dimension, and find().
| std::vector< casadi_int > casadi::GraphBuilderInternal::resolved_shape | ( | const Node & | n | ) | const |
Resolve a node's declared shape to concrete sizes: input_shapes_ override (inputs), else dynamic axes bound via dim_bindings_ (named) or defaulted to 1
Definition at line 183 of file graph_builder.cpp.
References dim_bindings_, casadi::Node::dim_params, casadi::Node::dimension, input_shapes_, casadi::Node::io, and casadi::Node::name.
Referenced by casadi::OnnxFunction::OnnxFunction().
| void casadi::GraphBuilderInternal::set_value | ( | const std::string & | input_name, |
| const std::vector< double > & | value | ||
| ) |
Definition at line 250 of file graph_builder.cpp.
References find(), input_values_, and nodes_.
|
inlineprotectedinherited |
Definition at line 83 of file generic_shared_internal.hpp.
|
inlineprotectedinherited |
Definition at line 92 of file generic_shared_internal.hpp.
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_1ai
Definition at line 67 of file generic_shared_internal.hpp.
| std::map<std::string, casadi_int> casadi::GraphBuilderInternal::dim_bindings_ |
Definition at line 128 of file graph_builder_internal.hpp.
Referenced by bind_shape(), casadi::OnnxFunction::from_model_data(), and resolved_shape().
| std::string casadi::GraphBuilderInternal::format_ |
Definition at line 116 of file graph_builder_internal.hpp.
Referenced by export_onnx().
| Function casadi::GraphBuilderInternal::fun_ |
Definition at line 120 of file graph_builder_internal.hpp.
Referenced by export_onnx().
| std::map<std::string, std::vector<casadi_int> > casadi::GraphBuilderInternal::input_shapes_ |
Definition at line 129 of file graph_builder_internal.hpp.
Referenced by bind_shape(), casadi::OnnxFunction::from_model_data(), and resolved_shape().
| std::map<std::string, std::vector<double> > casadi::GraphBuilderInternal::input_values_ |
Definition at line 130 of file graph_builder_internal.hpp.
Referenced by casadi::OnnxFunction::from_model_data(), casadi::OnnxFunction::OnnxFunction(), and set_value().
| GraphModel casadi::GraphBuilderInternal::model_ |
Definition at line 122 of file graph_builder_internal.hpp.
Referenced by create_function(), and GraphBuilderInternal().
| std::vector<uint8_t> casadi::GraphBuilderInternal::model_data_ |
Definition at line 117 of file graph_builder_internal.hpp.
Referenced by create_function(), export_onnx(), and casadi::OnnxFunction::OnnxFunction().
| std::string casadi::GraphBuilderInternal::name_ |
Definition at line 115 of file graph_builder_internal.hpp.
| std::vector<Node> casadi::GraphBuilderInternal::nodes_ |
Definition at line 125 of file graph_builder_internal.hpp.
Referenced by disp(), dynamic_params(), find(), n_in(), n_out(), name_in(), name_out(), node(), and set_value().