template<typename T>
class neml2::Variable< T >
Concrete definition of a variable.
|
| | Variable (VariableName name_in, Model *owner) |
| 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 (VariableBase &var) override |
| | Reference another variable.
|
| const VariableBase * | ref () const override |
| | Get the referencing variable (returns this if this is a storing variable).
|
| VariableBase * | ref () override |
| const VariableBase * | direct_ref () const override |
| | Get the direct referencing variable (returns nullptr if this is a storing variable).
|
| VariableBase * | direct_ref () override |
| bool | owning () const override |
| | Check if this is an owning variable.
|
| void | zero (const TensorOptions &options) override |
| | Set the variable value to zero.
|
| 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 | assign (const Tensor &val, std::optional< TracerPrivilege > key=std::nullopt) override |
| | Assignment operator (with TracerPrivilege).
|
| 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 () |
| | VariableBase (VariableName name_in, Model *owner, TensorShapeRef base_shape) |
| | The canonical constructor.
|
| const VariableName & | name () const |
| | Name of this variable.
|
| bool | is_mutable () const |
| | Whether this variable is mutable when it is referenced by another variable.
|
| void | set_mutable (bool m) |
| | Allow/disable mutation of this variable when it is referenced by another variable.
|
| 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 &arg, std::size_t deriv_intrsc_intmd_dim=0, std::size_t var_intrsc_intmd_dim=0, std::size_t arg_intrsc_intmd_dim=0) |
| | Wrapper for assigning partial derivative.
|
| const Derivative< 1 > & | d (const VariableBase &arg) const |
| Derivative< 2 > & | d2 (const VariableBase &arg1, const VariableBase &arg2, std::size_t deriv_intrsc_intmd_dim=0, std::size_t var_intrsc_intmd_dim=0, std::size_t arg1_intrsc_intmd_dim=0, std::size_t arg2_intrsc_intmd_dim=0) |
| | Wrapper for assigning second partial derivative.
|
| const Derivative< 2 > & | d2 (const VariableBase &arg1, const VariableBase &arg2) const |
| const DerivContainer & | derivatives () const |
| | Partial derivatives.
|
| DerivContainer & | derivatives () |
| const SecDerivContainer & | second_derivatives () const |
| | Partial second derivatives.
|
| SecDerivContainer & | second_derivatives () |
| void | clear_derivatives () |
| | Clear only the derivatives.
|
| 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) |
| bool | is_leaf (const DependencyResolver< Model, VariableName > &) const |
| const VariableBase & | provider (const DependencyResolver< Model, VariableName > &) const |
| | Get the provider in the dependency graph.
|
| const DerivContainer & | total_derivatives (const DependencyResolver< Model, VariableName > &) const |
| | Get total derivatives with respect to leaf variables.
|
| const SecDerivContainer & | total_second_derivatives (const DependencyResolver< Model, VariableName > &) const |
| | Get total second derivatives with respect to leaf variables.
|
| void | clear_chain_rule_cache (const DependencyResolver< Model, VariableName > &) const |
| | Clear chain rule cache.
|