Base interface for format-specific graph-model backends.
More...
#include <graph_model_internal.hpp>
Subclasses (e.g. Onnx) own the heavy dependency and implement metadata fill, symbolic import and symbolic export. Registered as plugins by format name.
- Date
- 2026
Extra doc: https://github.com/casadi/casadi/wiki/L_2ji
Definition at line 47 of file graph_model_internal.hpp.
|
| static std::map< std::string, Plugin > | solvers_ |
| | Collection of available format plugins. More...
|
| |
| static const std::string | infix_ = "graphmodel" |
| | Infix used to form plugin registration symbols (casadi_register_graphmodel_<name>) More...
|
| |
◆ Creator
◆ RegFcn
◆ weak_ref_type
◆ GraphModelInternal()
| casadi::GraphModelInternal::GraphModelInternal |
( |
const std::vector< uint8_t > & |
model_data | ) |
|
|
explicit |
Definition at line 83 of file graph_model.cpp.
const std::vector< uint8_t > & model_data() const
Raw model bytes.
bool verbose_
Verbose – for debugging.
std::vector< uint8_t > model_data_
Raw model bytes (empty when constructed for export only)
◆ ~GraphModelInternal()
| casadi::GraphModelInternal::~GraphModelInternal |
( |
| ) |
|
|
override |
◆ class_name()
| std::string casadi::GraphModelInternal::class_name |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ construct()
| void casadi::GraphModelInternal::construct |
( |
const Dict & |
opts | ) |
|
Definition at line 96 of file graph_model.cpp.
97 for (
auto&& op : opts) {
98 if (op.first ==
"verbose")
verbose_ = op.second;
virtual void init(const Dict &opts)
Initialize.
References init(), and verbose_.
◆ debug_repr()
Definition at line 62 of file generic_shared_internal.hpp.
177 return str( (casadi_int)(i)) +
"/" +
static_cast<const Internal*
>(
this)->class_name();
std::string str(const T &v)
String representation, any type.
◆ deps_version_check()
◆ deserialize()
Extra doc: https://github.com/casadi/casadi/wiki/L_rr
Definition at line 124 of file plugin_interface.hpp.
126 s.unpack(
"PluginInterface::plugin_name",
plugin_name);
static Deserialize plugin_deserialize(const std::string &pname)
Get the plugin deserialize_map.
static ProtoFunction * deserialize(DeserializingStream &s)
Deserialize with type disambiguation.
virtual const char * plugin_name() const=0
ProtoFunction *(* Deserialize)(DeserializingStream &)
◆ destroySingleton()
◆ disp()
| void casadi::GraphModelInternal::disp |
( |
std::ostream & |
stream, |
|
|
bool |
more |
|
) |
| const |
|
overridevirtual |
◆ export_symbolic()
| virtual std::vector<uint8_t> casadi::GraphModelInternal::export_symbolic |
( |
const Function & |
f, |
|
|
const Dict & |
opts |
|
) |
| |
|
pure virtual |
◆ fill_metadata()
◆ get_options()
| virtual const Options& casadi::GraphModelInternal::get_options |
( |
| ) |
const |
|
inlinevirtual |
◆ getCount()
◆ getPlugin()
Definition at line 102 of file plugin_interface.hpp.
297 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
298 std::lock_guard<std::mutex> lock(Derived::mutex_solvers_);
302 auto it=Derived::solvers_.find(pname);
305 if (it==Derived::solvers_.end()) {
307 it=Derived::solvers_.find(pname);
309 casadi_assert_dev(it!=Derived::solvers_.end());
static Plugin load_plugin(const std::string &pname, bool register_plugin=true, bool needs_lock=true)
Load a plugin dynamically.
◆ has_plugin()
Definition at line 76 of file plugin_interface.hpp.
136 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
137 std::lock_guard<std::mutex> lock(Derived::mutex_solvers_);
141 if (Derived::solvers_.
find(pname) != Derived::solvers_.end()) {
149 }
catch (CasadiException& ex) {
151 casadi_warning(ex.what());
std::vector< casadi_int > find(const std::vector< T > &v)
find nonzeros
◆ import_symbolic()
◆ init()
| void casadi::GraphModelInternal::init |
( |
const Dict & |
opts | ) |
|
|
virtual |
◆ initSingleton()
Called in the constructor of singletons to avoid that the counter reaches zero
Definition at line 71 of file generic_shared_internal.hpp.
72 casadi_assert_dev(
static_cast<Internal*
>(
this)->count==0);
73 static_cast<Internal*
>(
this)->count++;
◆ instantiate()
Definition at line 106 of file plugin_interface.hpp.
321 casadi_error(
"Plugin '" + pname +
"' is not found.");
323 return getPlugin(pname).creator(fname, problem);
static bool has_plugin(const std::string &pname, bool verbose=false)
Check if a plugin is available or can be loaded.
static Plugin & getPlugin(const std::string &pname)
Load and get the creator function.
◆ load_library()
Definition at line 92 of file plugin_interface.hpp.
190 casadi_error(
"WITH_DL option needed for dynamic loading");
194 std::string lib = std::string(CasadiMeta::shared_library_prefix()) + libname +
195 CasadiMeta::shared_library_suffix();
199 return open_shared_library(lib, search_paths, resultpath,
200 "PluginInterface::load_plugin", global);
std::vector< std::string > get_search_paths()
◆ load_plugin()
Definition at line 88 of file plugin_interface.hpp.
210 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
215 if (Derived::solvers_.
find(pname) != Derived::solvers_.end()) {
216 casadi_warning(
"PluginInterface: Solver " + pname +
" is already in use. Ignored.");
227 casadi_error(
"WITH_DL option needed for dynamic loading");
233 std::string regName =
"casadi_register_" + Derived::infix_ +
"_" + pname;
235 std::string searchpath;
242 #pragma GCC diagnostic push
243 #pragma GCC diagnostic ignored "-Wcast-function-type"
245 reg =
reinterpret_cast<RegFcn>(GetProcAddress(handle, TEXT(regName.c_str())));
247 #pragma GCC diagnostic pop
255 reg =
reinterpret_cast<RegFcn>(dlsym(handle, regName.c_str()));
257 casadi_assert(reg!=
nullptr,
258 "PluginInterface::load_plugin: no \"" + regName +
"\" found in " + searchpath +
".");
263 if (register_plugin) {
static handle_t load_library(const std::string &libname, std::string &resultpath, bool global)
Load a library dynamically.
int(* RegFcn)(Plugin *plugin)
static Plugin pluginFromRegFcn(RegFcn regfcn)
Instantiate a Plugin struct from a factory function.
static void registerPlugin(const Plugin &plugin, bool needs_lock=true)
Register an integrator in the factory.
◆ model_data()
| const std::vector<uint8_t>& casadi::GraphModelInternal::model_data |
( |
| ) |
const |
|
inline |
◆ plugin_deserialize()
Definition at line 82 of file plugin_interface.hpp.
167 casadi_assert(m,
"Plugin \"" + pname +
"\" does not support deserialize");
◆ plugin_name()
| const char* casadi::GraphModelInternal::plugin_name |
( |
| ) |
const |
|
overridepure virtual |
◆ plugin_options()
Definition at line 79 of file plugin_interface.hpp.
159 const Options *op =
getPlugin(pname).options;
160 casadi_assert(op!=
nullptr,
"Plugin \"" + pname +
"\" does not support options");
◆ pluginFromRegFcn()
Definition at line 85 of file plugin_interface.hpp.
178 int flag = regfcn(&plugin);
179 casadi_assert(flag==0,
"Registration of plugin failed.");
◆ registerPlugin() [1/2]
Definition at line 96 of file plugin_interface.hpp.
280 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
285 typename std::map<std::string, Plugin>::iterator it=Derived::solvers_.find(plugin.name);
286 casadi_assert(it==Derived::solvers_.end(),
287 "Solver " +
str(plugin.name) +
" is already in use");
290 Derived::solvers_[plugin.name] = plugin;
◆ registerPlugin() [2/2]
◆ serialize_type()
◆ shared_from_this() [1/2]
Definition at line 83 of file generic_shared_internal.hpp.
84 casadi_assert_dev(B::test_cast(
static_cast<Internal*
>(
this)));
86 ret.own(
static_cast<Internal*
>(
this));
◆ shared_from_this() [2/2]
Definition at line 92 of file generic_shared_internal.hpp.
93 casadi_assert_dev(B::test_cast(
static_cast<const Internal*
>(
this)));
95 ret.own(
const_cast<Internal*
>(
static_cast<const Internal*
>(
this)));
◆ shortname()
| static std::string casadi::GraphModelInternal::shortname |
( |
| ) |
|
|
inlinestatic |
◆ weak()
Extra doc: https://github.com/casadi/casadi/wiki/L_1ai
Definition at line 67 of file generic_shared_internal.hpp.
211 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
212 auto* w = weak_ref_.load(std::memory_order_acquire);
214 auto* nw =
new GenericWeakRef<Shared, Internal>(
static_cast<Internal*
>(
this));
215 GenericWeakRef<Shared, Internal>* expected =
nullptr;
216 if (weak_ref_.compare_exchange_strong(
217 expected, nw, std::memory_order_release, std::memory_order_acquire)) {
226 if (weak_ref_==
nullptr) {
227 weak_ref_ =
new GenericWeakRef<Shared, Internal>(
static_cast<Internal*
>(
this));
◆ infix_
| const std::string casadi::GraphModelInternal::infix_ = "graphmodel" |
|
static |
◆ model_data_
| std::vector<uint8_t> casadi::GraphModelInternal::model_data_ |
|
protected |
◆ options_
| const Options casadi::GraphModelInternal::options_ |
|
static |
◆ solvers_
| std::map< std::string, GraphModelInternal::Plugin > casadi::GraphModelInternal::solvers_ |
|
static |
◆ verbose_
| bool casadi::GraphModelInternal::verbose_ |
|
protected |
The documentation for this class was generated from the following files: