27#include "neml2/base/NEML2Object.h"
28#include "neml2/base/OptionSet.h"
29#include "neml2/base/Storage.h"
30#include "neml2/tensors/TensorValue.h"
34#include "neml2/base/CrossRef.h"
35#include "neml2/base/EnumSelection.h"
82 virtual std::map<std::string, const VariableBase *>
86 virtual std::map<std::string, Model *>
110 template <
typename T,
typename =
typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>>
128 template <
typename T,
typename =
typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>>
153template <
typename T,
typename>
157 if (_object->
host() != _object)
164 if (_param_values.has_key(name))
169 auto val = std::make_unique<TensorValue<T>>(
rawval);
170 base_ptr = _param_values.set_pointer(name, std::move(
val));
174 neml_assert(
ptr,
"Internal error: Failed to cast parameter to a concrete type.");
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:56
The base class of all "manufacturable" objects in the NEML2 library.
Definition NEML2Object.h:38
const std::string & name() const
A readonly reference to the object's name.
Definition NEML2Object.h:65
const T * host() const
Get a readonly pointer to the host.
Definition NEML2Object.h:90
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:100
Interface for object which can store parameters.
Definition ParameterStore.h:45
std::map< std::string, const VariableBase * > _nl_params
Map from nonlinear parameter names to their corresponding variable views.
Definition ParameterStore.h:134
virtual void send_parameters_to(const torch::TensorOptions &options)
Send parameters to options.
Definition ParameterStore.cxx:39
void set_parameter(const std::string &, const Tensor &)
}@
Definition ParameterStore.cxx:48
ParameterStore(const OptionSet &options, NEML2Object *object)
Definition ParameterStore.cxx:32
std::map< std::string, Model * > _nl_param_models
Map from nonlinear parameter names to models which evaluate them.
Definition ParameterStore.h:137
void set_parameters(const std::map< std::string, Tensor > &)
Set values for parameters.
Definition ParameterStore.cxx:57
bool has_nl_param() const
Whether this parameter store has any nonlinear parameter.
Definition ParameterStore.h:71
TensorValueBase & get_parameter(const std::string &name)
Get a writable reference of a parameter.
Definition ParameterStore.cxx:64
const Storage< std::string, TensorValueBase > & named_parameters() const
Definition ParameterStore.h:51
const T & declare_parameter(const std::string &name, const T &rawval)
Declare a parameter.
Definition ParameterStore.h:155
virtual std::map< std::string, Model * > named_nonlinear_parameter_models(bool recursive=false) const
Get all nonlinear parameters' models.
Definition ParameterStore.cxx:117
virtual std::map< std::string, const VariableBase * > named_nonlinear_parameters(bool recursive=false) const
Get all nonlinear parameters.
Definition ParameterStore.cxx:94
const VariableBase * nl_param(const std::string &) const
Query the existence of a nonlinear parameter.
Definition ParameterStore.cxx:80
The base class to allow us to set up a polymorphic container of Tensors. The concrete definitions wil...
Definition TensorValue.h:36
Definition CrossRef.cxx:30
std::string & parameter_name_separator()
Default nested parameter name separator.
Definition types.cxx:95
void neml_assert(bool assertion, Args &&... args)
Definition error.h:64