NEML2 1.4.0
Loading...
Searching...
No Matches
VariableBase Class Referenceabstract

#include <Variable.h>

Inheritance diagram for VariableBase:

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 Tensorraw_value () const
 Raw flattened variable value.
 
virtual const Tensor tensor () const =0
 Variable value of the logical shape.
 
const VariableNamename () const
 Name of this variable.
 
const Modelowner () const
 The owner of this variable.
 
const VariableBasesrc () 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.
 

Subaxis

const bool _is_state
 
const bool _is_old_state
 
const bool _is_force
 
const bool _is_old_force
 
const bool _is_residual
 
const bool _is_parameter
 
const bool _is_other
 
const bool _is_solve_dependent
 
bool is_state () const
 
bool is_old_state () const
 
bool is_force () const
 
bool is_old_force () const
 
bool is_residual () const
 
bool is_parameter () const
 
bool is_other () const
 
bool is_solve_dependent () const
 

Constructor & Destructor Documentation

◆ VariableBase()

VariableBase ( const VariableName & name_in,
const Model * owner )

◆ ~VariableBase()

virtual ~VariableBase ( )
virtualdefault

Member Function Documentation

◆ base_dim()

Size base_dim ( ) const
inline

Base dimension.

◆ base_sizes()

◆ base_storage()

Size base_storage ( ) const
inline

Base storage.

◆ batch_dim()

Size batch_dim ( ) const
inline

Batch dimension.

◆ batch_sizes()

TensorShapeRef batch_sizes ( ) const
inline

Batch shape.

◆ cache()

◆ d() [1/2]

Create a wrapper representing the derivative dy/dx.

◆ d() [2/2]

Create a wrapper representing the second derivative d2y/dx2.

◆ is_dependent()

bool is_dependent ( ) const

Check if the derivative with respect to this variable should be evaluated.

◆ is_force()

bool is_force ( ) const
inline

◆ is_old_force()

bool is_old_force ( ) const
inline

◆ is_old_state()

bool is_old_state ( ) const
inline

◆ is_other()

bool is_other ( ) const
inline

◆ is_parameter()

bool is_parameter ( ) const
inline

◆ is_residual()

bool is_residual ( ) const
inline

◆ is_solve_dependent()

bool is_solve_dependent ( ) const
inline

◆ is_state()

bool is_state ( ) const
inline

◆ name()

const VariableName & name ( ) const
inline

Name of this variable.

◆ owner()

const Model & owner ( ) const
inline

The owner of this variable.

◆ raw_value()

const Tensor & raw_value ( ) const
inline

Raw flattened variable value.

◆ requires_grad_()

◆ setup_views() [1/2]

◆ setup_views() [2/2]

◆ sizes()

◆ src()

const VariableBase * src ( ) const
inline

The source variable.

◆ tensor()

◆ type()

Member Data Documentation

◆ _batch_sizes

TensorShape _batch_sizes
protected

Batch shape of this variable.

◆ _d2value_d

std::map<VariableName, std::map<VariableName, Tensor> > _d2value_d
protected

The second derivative of this variable w.r.t. arguments.

◆ _dvalue_d

std::map<VariableName, Tensor> _dvalue_d
protected

The derivative of this variable w.r.t. arguments.

◆ _is_force

const bool _is_force
protected

◆ _is_old_force

const bool _is_old_force
protected

◆ _is_old_state

const bool _is_old_state
protected

◆ _is_other

const bool _is_other
protected

◆ _is_parameter

const bool _is_parameter
protected

◆ _is_residual

const bool _is_residual
protected

◆ _is_solve_dependent

const bool _is_solve_dependent
protected

◆ _is_state

const bool _is_state
protected

◆ _name

const VariableName _name
protected

Name of the variable.

◆ _owner

const Model* _owner
protected

The model which declared this variable.

◆ _raw_value

Tensor _raw_value
protected

The raw (flattened) variable value.

◆ _src

const VariableBase* _src
protected

The source variable this variable follows.