26 #ifndef CASADI_GRAPH_BUILDER_INTERNAL_HPP
27 #define CASADI_GRAPH_BUILDER_INTERNAL_HPP
29 #include "graph_builder.hpp"
30 #include "graph_model_impl.hpp"
31 #include "shared_object.hpp"
43 :
public SWIG_IF_ELSE(PrintableCommon, Printable<Node>) {
53 void disp(std::ostream& stream,
bool more=
false)
const;
54 std::string get_str(
bool more=
false)
const;
69 const std::string& format,
const Dict& opts);
74 std::string
class_name()
const override {
return "GraphBuilderInternal"; }
75 void disp(std::ostream& stream,
bool more)
const override;
77 casadi_int n_in()
const;
78 casadi_int n_out()
const;
79 std::vector<std::string> name_in()
const;
80 std::vector<std::string> name_out()
const;
81 std::vector<casadi_int> input_shape(
const std::string& name)
const;
82 std::vector<casadi_int> output_shape(
const std::string& name)
const;
83 std::vector<std::string> dynamic_params()
const;
84 Node node(
const std::string& name)
const;
85 std::vector<Node>
nodes()
const {
return nodes_; }
87 void bind_dim(
const std::string& param, casadi_int value) { dim_bindings_[param] = value; }
88 void bind_shape(
const std::string& input_name,
const std::vector<casadi_int>& shape);
89 void set_value(
const std::string& input_name,
const std::vector<double>& value);
91 Function create_function(
const std::string& name,
92 const std::vector<std::string>& name_in,
93 const std::vector<std::string>& name_out,
94 const Dict& opts)
const;
95 void export_onnx(
const std::string&
filename,
const Dict& opts);
104 const std::vector<Node>&
node_list()
const {
return nodes_; }
105 const std::map<std::string, casadi_int>&
dim_bindings()
const {
return dim_bindings_; }
110 std::vector<casadi_int> resolved_shape(
const Node& n)
const;
113 const Node&
find(
const std::string& name,
const std::string& io)
const;
134 void populate_from_function();
Internal class for GraphBuilder.
std::map< std::string, std::vector< double > > input_values_
std::vector< Node > nodes_
Tensor metadata (inputs followed by outputs)
Function fun_
Source Function (export lifecycle); null when built from a model.
std::vector< Node > nodes() const
const std::vector< Node > & node_list() const
void clear_nodes()
Drop all tensor descriptors (called by a backend before re-filling)
std::map< std::string, casadi_int > dim_bindings_
Pending configuration carried into create()
std::map< std::string, std::vector< casadi_int > > input_shapes_
GraphModel model_
Parsed model backend (import lifecycle); null when built from a Function.
void add_node(const Node &n)
Append a tensor descriptor (called by a backend during fill_metadata)
std::string class_name() const override
Readable name of the internal class.
void bind_dim(const std::string ¶m, casadi_int value)
std::vector< uint8_t > model_data_
const std::map< std::string, casadi_int > & dim_bindings() const
Format-agnostic handle to a parsed computational-graph model.
std::vector< casadi_int > find(const std::vector< T > &v)
find nonzeros
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
std::string filename(const std::string &path)
Metadata for one graph tensor (graph input or output)
std::vector< casadi_int > dimension
Declared shape, -1 for dynamic dimensions.
std::string type_name() const
std::vector< double > value
Baked value (optional)
std::string name
Tensor name.
std::string io
"input" or "output"
std::string dtype
Element type name (FLOAT, INT64, ...)
std::vector< std::string > dim_params
Symbolic name per axis ("" if static)