|
| OnnxDriver (Context &context) |
| Construct a new parser driver context.
|
|
bool | ParseStreamCore (std::istream &in) override |
| Parse the stream.
|
|
bool | ParseFile (const std::string &filename) override |
| Invoke the scanner and parser on a file.
|
|
const std::unordered_map< std::string, Tensor > & | variables () const |
| Get read-only access to the variables of the Driver.
|
|
const std::unordered_map< std::string, Tensor > & | available_inputs () const |
| Get read-only access to the available_inputs of the Driver.
|
|
const ::onnx::ModelProto & | model () const |
| Get read-only access to the model of the Driver.
|
|
const ::onnx::GraphProto & | graph () const |
| Get read-only access to the graph of the Driver.
|
|
| Driver (Context &context, const std::string &class_name="Driver") |
| construct a new parser driver context
|
|
bool | ParseStream (std::istream &in, const std::string &sname="stream input") |
| Invoke the scanner and parser for a stream.
|
|
bool | ParseString (const std::string &input, const std::string &sname="string stream") |
| Invoke the scanner and parser on an input string.
|
|
void | Push (int n) |
| Push the current context to the stack.
|
|
void | Pop (int n) |
| Restore a previously pushed context from the stack.
|
|
void | CheckSat () |
| Call context_.CheckSat() and print proper output messages to the standard output.
|
|
void | GetModel () |
| Return a model computed by the solver in response to an invocation of the check-sat.
|
|
void | GetAssertions () const |
| Callback for the command get-assertions .
|
|
void | GetOption (const std::string &key) const |
| Callback for the command get-option .
|
|
void | GetInfo (const std::string &key) const |
| Callback for the command get-info .
|
|
void | SetInfo (const std::string &key, const std::string &value) |
| Callback for the command set-info .
|
|
void | SetOption (const std::string &key, const std::string &value) |
| Callback for the command set-option .
|
|
void | SetLogic (const Logic logic) |
| Callback for the command set-logic .
|
|
void | Maximize (const Expression &f) |
| Maximize the objective function f .
|
|
void | Minimize (const Expression &f) |
| Minimize the objective function f .
|
|
void | Exit () |
| Callback for the command exit .
|
|
bool | trace_scanning () const |
| Check whether the scanner debugger is enabled.
|
|
bool | trace_parsing () const |
| Check whether the trace debugger is enabled.
|
|
const Context & | context () const |
| Get read-only access to the enabled of the Driver.
|
|
const std::string & | stream_name () const |
| Get read-only access to the stream name of the input being parsed.
|
|
std::string & | m_stream_name () |
| Get read-write access to the stream name of the input being parsed.
|
|
const Stats & | stats () const |
| Statistics for the driver.
|
|
|
template<IsAnyOf< bool, float, std::int64_t, std::string, std::vector< float >, std::vector< std::int64_t >, std::vector< std::string >, const ::onnx::TensorProto * > T> |
T | GetAttribute (const ::onnx::NodeProto &node, const std::string &name, const std::optional< T > &default_value={}) const |
| Get the attribute name from the node .
|
|
void | ParseGraph () |
| Parse the model_ 's graph.
|
|
void | AddNodes () |
| Go through all the nodes in the graph and construct the final assertions.
|
|
bool | AddNode (const ::onnx::NodeProto &node) |
| Go through a specific node and add the corresponding assertions.
|
|
void | AddValueInfo (const ::onnx::ValueInfoProto &value_info, bool is_input=false) |
| Add the input and output to the Context.
|
|
void | AddValueInfoTensor (const ::onnx::ValueInfoProto &value_info, bool is_input=false) |
| Add the input and output to the Context.
|
|
void | AddInitializer (const ::onnx::TensorProto &tensor) |
| Add an initializer to the available_inputs_.
|
|
void | AddFormula (const std::string &output) |
| Add the formulas to the Context.
|
|
template<NodeOpType T> |
void | AddNode (const ::onnx::NodeProto &node) |
| Add a node to the context.
|
|
const Variable & | ToEqualVar (const Expression &expression) |
| Associate to a linear expression a fresh variable.
|
|
The OnnxDriver class reads the onnx file.
The information collected is used to update the context by running all the nodes, from the input to the output of the graph.
Definition at line 37 of file Driver.h.
template<IsAnyOf< bool, float, std::int64_t, std::string, std::vector< float >, std::vector< std::int64_t >, std::vector< std::string >, const ::onnx::TensorProto * > T>
templateconst::onnx::TensorProto * dlinear::onnx::OnnxDriver::GetAttribute |
( |
const ::onnx::NodeProto & | node, |
|
|
const std::string & | name, |
|
|
const std::optional< T > & | default_value = {} ) const |
|
private |
Get the attribute name
from the node
.
If the attribute is not found, the default_value
is returned. If no default_value
is provided, an exception is thrown.
- Template Parameters
-
T | type of the attribute to get. Limited to
- bool
- float
- int64_t
- string
- vector<float>,
- vector<int64_t>
- vector<string>
- const onnx::TensorProto*.
|
- Parameters
-
node | node to get the attribute from |
name | name of the attribute |
default_value | optional default value. If the attribute is not found, this value is returned. |
- Returns
- attribute value
- Exceptions
-
std::runtime_error | if the attribute is not found and no default value is provided |
Definition at line 153 of file Driver.cpp.