template<typename T>
class neml2::Variable< T >
Concrete definition of a variable.
|
| | Variable (VariableName name_in, Model *owner, TensorShapeRef dep_intmd_dims={}) |
| |
| TensorType | type () const override |
| | Variable tensor type.
|
| |
| const TraceableTensorShape & | dynamic_sizes () const override |
| |
| std::unique_ptr< VariableBase > | clone (const VariableName &name={}, Model *owner=nullptr) const override |
| | Clone this variable.
|
| |
| void | ref (const VariableBase &var, bool ref_is_mutable=false) override |
| | Reference another variable.
|
| |
| const VariableBase * | ref () const override |
| | Get the referencing variable (returns this if this is a storing variable)
|
| |
| bool | owning () const override |
| | Check if this is an owning variable.
|
| |
| void | zero (const TensorOptions &options) override |
| | Set the variable value to zero.
|
| |
| void | set (const Tensor &val, std::optional< TracerPrivilege > key) override |
| | Set the variable value from a Tensor in assembly format.
|
| |
| Tensor | get () const override |
| | Get the variable value in assembly format.
|
| |
| 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.
|
| |
| void | operator= (const Tensor &val) override |
| | Assignment operator.
|
| |
| const T & | operator() () const |
| | Variable value.
|
| |
| T | operator- () const |
| | Negation.
|
| |
| void | clear () override |
| | Clear the variable value and derivatives.
|
| |
|
| bool | defined () const override |
| |
| TensorOptions | options () const override |
| | Tensor options.
|
| |
| Dtype | scalar_type () const override |
| | Scalar type.
|
| |
| Device | device () const override |
| | Device.
|
| |
| | VariableBase ()=default |
| |
| | VariableBase (const VariableBase &)=delete |
| |
| | VariableBase (VariableBase &&)=delete |
| |
| VariableBase & | operator= (const VariableBase &)=delete |
| |
| VariableBase & | operator= (VariableBase &&)=delete |
| |
| virtual | ~VariableBase ()=default |
| |
| | VariableBase (VariableName name_in, Model *owner, TensorShapeRef base_shape, TensorShapeRef dep_intmd_dims) |
| |
| const VariableName & | name () const |
| | Name of this variable.
|
| |
| void | set_intmd_sizes (TensorShapeRef shape) |
| | Set the intermediate shape.
|
| |
| ArrayRef< Size > | dep_intmd_dims () const |
| | Get dependent intermediate dimensions for derivative calculation.
|
| |
| Tensor | zeros (const TensorOptions &options) const |
| | Make zeros tensor with the shape of this variable.
|
| |
| bool | requires_grad () const |
| | Check if this variable is part of the AD function graph.
|
| |
| bool | has_derivative (const VariableName &vname) const |
| | Whether the variable has non-zero derivative with respect to another variable.
|
| |
| bool | has_derivative (const VariableName &v1name, const VariableName &v2name) const |
| | Whether the variable has non-zero second derivative with respect to another variable.
|
| |
| Derivative< 1 > & | d (const VariableBase &var, ArrayRef< Size > dep_dims={}) |
| | Wrapper for assigning partial derivative.
|
| |
| const Derivative< 1 > & | d (const VariableBase &var) const |
| |
| Derivative< 2 > & | d2 (const VariableBase &var1, const VariableBase &var2, ArrayRef< Size > dep_dims={}) |
| | Wrapper for assigning second partial derivative.
|
| |
| const Derivative< 2 > & | d2 (const VariableBase &var1, const VariableBase &var2) const |
| |
| const std::vector< Derivative< 1 > > & | derivatives () const |
| | Partial derivatives.
|
| |
| std::vector< Derivative< 1 > > & | derivatives () |
| |
| const std::vector< Derivative< 2 > > & | second_derivatives () const |
| | Partial second derivatives.
|
| |
| std::vector< Derivative< 2 > > & | second_derivatives () |
| |
| void | clear_derivatives () |
| | Clear only the derivatives.
|
| |
| void | apply_chain_rule (const DependencyResolver< Model, VariableName > &) |
| | Apply first order chain rule.
|
| |
| void | apply_second_order_chain_rule (const DependencyResolver< Model, VariableName > &) |
| | Apply second order chain rule.
|
| |
| const Model & | owner () const |
| |
| Model & | owner () |
| |
| 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_solve_dependent () const |
| |
| bool | is_dependent () const |
| | Check if the derivative with respect to this variable should be evaluated.
|
| |
| Size | dim () const |
| |
| Size | batch_dim () const |
| |
| Size | base_dim () const |
| |
| Size | dynamic_dim () const |
| |
| Size | static_dim () const |
| |
| Size | intmd_dim () const |
| |
| TensorShapeRef | sizes () const |
| |
| TraceableTensorShape | batch_sizes () const |
| |
| TensorShapeRef | base_sizes () const |
| |
| TensorShapeRef | static_sizes () const |
| |
| TensorShapeRef | intmd_sizes () const |
| |
| Size | size (Size i) const |
| |
| TraceableSize | batch_size (Size i) const |
| |
| Size | base_size (Size i) const |
| |
| const TraceableSize & | dynamic_size (Size i) const |
| |
| Size | static_size (Size i) const |
| |
| Size | intmd_size (Size i) const |
| |
| void | request_AD (const VariableBase &u) |
| |
| void | request_AD (const std::vector< const VariableBase * > &us) |
| |
| void | request_AD (const VariableBase &u1, const VariableBase &u2) |
| |
| void | request_AD (const std::vector< const VariableBase * > &u1s, const std::vector< const VariableBase * > &u2s) |
| |