27#include "neml2/models/VariableBase.h"
80 [[maybe_unused]] std::optional<TracerPrivilege> key = std::nullopt)
override;
The base class for all constitutive models.
Definition Model.h:83
const Model & owner() const
const VariableName & name() const
Name of this variable.
Definition VariableBase.h:73
bool defined() const override
Dtype scalar_type() const override
Scalar type.
Tensor tensor() const override
Get the variable value cast to Tensor.
void requires_grad_(bool req=true) override
Mark this variable as a leaf variable in tracing function graph for AD.
Variable< T > * _ref
The variable referenced by this (nullptr if this is a storing variable).
Definition Variable.h:94
void operator=(const Tensor &val) override
Assignment operator.
Device device() const override
Device.
Variable(VariableName name_in, Model *owner)
Definition Variable.h:39
VariableBase * direct_ref() override
Definition Variable.h:69
const VariableBase * ref() const override
Get the referencing variable (returns this if this is a storing variable).
Definition Variable.h:66
VariableBase * ref() override
Definition Variable.h:67
void assign(const Tensor &val, std::optional< TracerPrivilege > key=std::nullopt) override
Assignment operator (with TracerPrivilege).
void zero(const TensorOptions &options) override
Set the variable value to zero.
T operator-() const
Negation.
Definition Variable.h:88
TensorOptions options() const override
Tensor options.
TensorType type() const override
Variable tensor type.
const TraceableTensorShape & dynamic_sizes() const override
bool owning() const override
Check if this is an owning variable.
Definition Variable.h:71
std::unique_ptr< VariableBase > clone(const VariableName &name={}, Model *owner=nullptr) const override
Clone this variable.
T _value
Variable value (undefined if this is a referencing variable).
Definition Variable.h:97
const VariableBase * direct_ref() const override
Get the direct referencing variable (returns nullptr if this is a storing variable).
Definition Variable.h:68
void clear() override
Clear the variable value and derivatives.
void ref(VariableBase &var) override
Reference another variable.
const T & operator()() const
Variable value.
Definition Variable.h:85
Definition DiagnosticsInterface.h:31
c10::Device Device
Definition types.h:69
TensorType
Definition tensors.h:56
LabeledAxisAccessor VariableName
Definition LabeledAxisAccessor.h:185
c10::TensorOptions TensorOptions
Definition types.h:66
c10::ScalarType Dtype
Definition types.h:67
Traceable tensor shape.
Definition TraceableTensorShape.h:38