NEML2 1.4.0
|
#include <Variable.h>
Public Member Functions | |
VariableBase (const VariableName &name_in, const Model *owner) | |
virtual | ~VariableBase ()=default |
virtual void | cache (TensorShapeRef batch_shape) |
Cache the variable's batch shape. | |
virtual void | setup_views (const LabeledVector *value, const LabeledMatrix *deriv=nullptr, const LabeledTensor3D *secderiv=nullptr) |
Setup the variable's views into blocks of the storage. | |
virtual void | setup_views (const VariableBase *other) |
Setup the variable's views following another variable. | |
virtual void | requires_grad_ (bool req=true)=0 |
Set requires_grad for the underlying storage. | |
Derivative | d (const VariableBase &x) |
Create a wrapper representing the derivative dy/dx. | |
Derivative | d (const VariableBase &x1, const VariableBase &x2) |
Create a wrapper representing the second derivative d2y/dx2. | |
const Tensor & | raw_value () const |
Raw flattened variable value. | |
virtual const Tensor | tensor () const =0 |
Variable value of the logical shape. | |
const VariableName & | name () const |
Name of this variable. | |
const Model & | owner () const |
The owner of this variable. | |
const VariableBase * | src () const |
The source variable. | |
TensorShapeRef | batch_sizes () const |
Batch shape. | |
virtual TensorShapeRef | base_sizes () const =0 |
Base shape. | |
Size | batch_dim () const |
Batch dimension. | |
Size | base_dim () const |
Base dimension. | |
Size | base_storage () const |
Base storage. | |
virtual TensorShapeRef | sizes () const =0 |
Total shape. | |
virtual TensorType | type () const =0 |
Variable type. | |
bool | is_dependent () const |
Check if the derivative with respect to this variable should be evaluated. | |
Protected Attributes | |
const VariableName | _name |
Name of the variable. | |
const Model * | _owner |
The model which declared this variable. | |
TensorShape | _batch_sizes |
Batch shape of this variable. | |
Tensor | _raw_value |
The raw (flattened) variable value. | |
std::map< VariableName, Tensor > | _dvalue_d |
The derivative of this variable w.r.t. arguments. | |
std::map< VariableName, std::map< VariableName, Tensor > > | _d2value_d |
The second derivative of this variable w.r.t. arguments. | |
const VariableBase * | _src |
The source variable this variable follows. | |
VariableBase | ( | const VariableName & | name_in, |
const Model * | owner ) |
|
virtualdefault |
|
inline |
Base dimension.
|
pure virtual |
Base shape.
Implemented in Variable< T >, Variable< neml2::R2 >, Variable< neml2::Rot >, Variable< neml2::Scalar >, Variable< neml2::SR2 >, Variable< neml2::Tensor >, Variable< neml2::Vec >, Variable< neml2::WR2 >, and Variable< Scalar >.
|
inline |
Base storage.
|
inline |
Batch dimension.
|
inline |
Batch shape.
|
virtual |
Cache the variable's batch shape.
Reimplemented in Variable< T >, Variable< neml2::R2 >, Variable< neml2::Rot >, Variable< neml2::Scalar >, Variable< neml2::SR2 >, Variable< neml2::Tensor >, Variable< neml2::Vec >, Variable< neml2::WR2 >, and Variable< Scalar >.
Derivative d | ( | const VariableBase & | x | ) |
Create a wrapper representing the derivative dy/dx.
Derivative d | ( | const VariableBase & | x1, |
const VariableBase & | x2 ) |
Create a wrapper representing the second derivative d2y/dx2.
bool is_dependent | ( | ) | const |
Check if the derivative with respect to this variable should be evaluated.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Name of this variable.
Set requires_grad for the underlying storage.
Implemented in Variable< T >, Variable< neml2::R2 >, Variable< neml2::Rot >, Variable< neml2::Scalar >, Variable< neml2::SR2 >, Variable< neml2::Tensor >, Variable< neml2::Vec >, Variable< neml2::WR2 >, and Variable< Scalar >.
|
virtual |
Setup the variable's views into blocks of the storage.
Reimplemented in Variable< T >, Variable< neml2::R2 >, Variable< neml2::Rot >, Variable< neml2::Scalar >, Variable< neml2::SR2 >, Variable< neml2::Tensor >, Variable< neml2::Vec >, Variable< neml2::WR2 >, and Variable< Scalar >.
|
virtual |
Setup the variable's views following another variable.
Reimplemented in Variable< T >, Variable< neml2::R2 >, Variable< neml2::Rot >, Variable< neml2::Scalar >, Variable< neml2::SR2 >, Variable< neml2::Tensor >, Variable< neml2::Vec >, Variable< neml2::WR2 >, and Variable< Scalar >.
|
pure virtual |
Total shape.
Implemented in Variable< T >, Variable< neml2::R2 >, Variable< neml2::Rot >, Variable< neml2::Scalar >, Variable< neml2::SR2 >, Variable< neml2::Tensor >, Variable< neml2::Vec >, Variable< neml2::WR2 >, and Variable< Scalar >.
|
inline |
The source variable.
Variable value of the logical shape.
Implemented in Variable< T >, Variable< neml2::R2 >, Variable< neml2::Rot >, Variable< neml2::Scalar >, Variable< neml2::SR2 >, Variable< neml2::Tensor >, Variable< neml2::Vec >, Variable< neml2::WR2 >, and Variable< Scalar >.
|
pure virtual |
|
protected |
Batch shape of this variable.
|
protected |
The second derivative of this variable w.r.t. arguments.
|
protected |
The derivative of this variable w.r.t. arguments.
|
protected |
Name of the variable.
|
protected |
The raw (flattened) variable value.
|
protected |
The source variable this variable follows.