Base class for compute building blocks composed by layers (matmul, activation, dropout, etc.). More...
#include <operators.h>
Public Member Functions | |
| virtual | ~Operator ()=default |
| virtual vector< TensorSpec > | parameter_specs () const |
| Returns the tensor specs of trainable parameters owned by this operator. | |
| virtual vector< TensorSpec > | state_specs () const |
| Returns the tensor specs of persistent state owned by this operator. | |
| virtual void | link_parameters (span< const TensorView >) |
| Binds parameter views provided by the hosting layer. | |
| virtual void | link_gradients (span< const TensorView >) |
| Binds gradient views provided by the hosting layer. | |
| virtual void | link_states (span< const TensorView >) |
| Binds state views provided by the hosting layer. | |
| virtual void | set_parameters_random () |
| Initializes parameters with random values. | |
| virtual void | set_parameters_glorot () |
| Initializes parameters using Glorot (Xavier) initialization. | |
| virtual void | forward_propagate (ForwardPropagation &, size_t, bool) noexcept |
| Runs the operator's forward computation. | |
| virtual void | back_propagate (ForwardPropagation &, BackPropagation &, size_t) const noexcept |
| Runs the operator's backward computation, accumulating into gradient/delta buffers. | |
| virtual void | to_JSON (JsonWriter &) const |
| Serializes the operator configuration to a JSON writer. | |
| virtual void | from_JSON (const Json *) |
| Restores the operator configuration from a JSON node. | |
| virtual void | load_state_from_JSON (const Json *) |
| Restores persistent state (e.g. running statistics) from a JSON node. | |
| virtual void | destroy_cuda () |
| Releases CUDA resources owned by the operator; called from destructors. | |
| TensorView & | get_input (ForwardPropagation &fp, size_t layer, size_t i=0) const noexcept |
| vector< TensorView > & | get_inputs (ForwardPropagation &fp, size_t layer, size_t i=0) const noexcept |
| TensorView & | get_output (ForwardPropagation &fp, size_t layer, size_t i=0) const noexcept |
| TensorView & | get_output_delta (BackPropagation &bp, size_t layer, size_t i=0) const noexcept |
| TensorView & | get_input_delta (BackPropagation &bp, size_t layer, size_t i=0) const noexcept |
Public Attributes | |
| vector< size_t > | input_slots = {0} |
| vector< size_t > | output_slots = {1} |
| vector< size_t > | input_delta_slots = {1} |
| vector< size_t > | output_delta_slots = {0} |
Detailed Description
Base class for compute building blocks composed by layers (matmul, activation, dropout, etc.).
Constructor & Destructor Documentation
◆ ~Operator()
|
virtualdefault |
Member Function Documentation
◆ back_propagate()
|
inlinevirtualnoexcept |
Runs the operator's backward computation, accumulating into gradient/delta buffers.
- Parameters
-
fp Forward propagation workspace (read-only). bp Back propagation workspace receiving gradients and deltas. layer Index of the hosting layer in the workspace.
Reimplemented in opennn::ActivationOp, opennn::AddOp, opennn::AttentionOp, opennn::BatchNormOp, opennn::CombinationOp, opennn::CombinationReluOp, opennn::ConvolutionOp, opennn::ConvolutionReluOp, opennn::DropoutOp, opennn::EmbeddingLookupOp, opennn::FlatOp, opennn::LayerNormOp, opennn::MergeOp, opennn::MultiHeadProjectionOp, opennn::Pool3dOp, and opennn::PoolOp.
◆ destroy_cuda()
|
inlinevirtual |
Releases CUDA resources owned by the operator; called from destructors.
Reimplemented in opennn::ActivationOp, opennn::AttentionOp, opennn::ConvolutionOp, opennn::ConvolutionReluOp, opennn::DropoutOp, and opennn::PoolOp.
◆ forward_propagate()
|
inlinevirtualnoexcept |
Runs the operator's forward computation.
- Parameters
-
fp Forward propagation workspace. layer Index of the hosting layer in the workspace. is_training If true, enables training-only behavior (e.g. dropout sampling).
Reimplemented in opennn::ActivationOp, opennn::AddOp, opennn::AttentionOp, opennn::BatchNormOp, opennn::BoundOp, opennn::CombinationOp, opennn::CombinationReluOp, opennn::ConvolutionOp, opennn::ConvolutionReluOp, opennn::DropoutOp, opennn::EmbeddingLookupOp, opennn::FlatOp, opennn::LayerNormOp, opennn::MergeOp, opennn::MultiHeadProjectionOp, opennn::Pool3dOp, opennn::PoolOp, opennn::ScaleOp, and opennn::UnscaleOp.
◆ from_JSON()
|
inlinevirtual |
Restores the operator configuration from a JSON node.
Reimplemented in opennn::ActivationOp, opennn::AttentionOp, opennn::BatchNormOp, and opennn::DropoutOp.
◆ get_input()
|
inlinenoexcept |
◆ get_input_delta()
|
inlinenoexcept |
◆ get_inputs()
|
inlinenoexcept |
◆ get_output()
|
inlinenoexcept |
◆ get_output_delta()
|
inlinenoexcept |
◆ link_gradients()
|
inlinevirtual |
Binds gradient views provided by the hosting layer.
Reimplemented in opennn::BatchNormOp, opennn::CombinationOp, opennn::CombinationReluOp, opennn::ConvolutionOp, opennn::ConvolutionReluOp, opennn::EmbeddingLookupOp, opennn::LayerNormOp, and opennn::MultiHeadProjectionOp.
◆ link_parameters()
|
inlinevirtual |
Binds parameter views provided by the hosting layer.
Reimplemented in opennn::BatchNormOp, opennn::CombinationOp, opennn::CombinationReluOp, opennn::ConvolutionOp, opennn::ConvolutionReluOp, opennn::EmbeddingLookupOp, opennn::LayerNormOp, and opennn::MultiHeadProjectionOp.
◆ link_states()
|
inlinevirtual |
Binds state views provided by the hosting layer.
Reimplemented in opennn::BatchNormOp, and opennn::EmbeddingLookupOp.
◆ load_state_from_JSON()
|
inlinevirtual |
Restores persistent state (e.g. running statistics) from a JSON node.
Reimplemented in opennn::BatchNormOp.
◆ parameter_specs()
|
inlinevirtual |
Returns the tensor specs of trainable parameters owned by this operator.
Reimplemented in opennn::BatchNormOp, opennn::CombinationOp, opennn::CombinationReluOp, opennn::ConvolutionOp, opennn::ConvolutionReluOp, opennn::EmbeddingLookupOp, opennn::LayerNormOp, and opennn::MultiHeadProjectionOp.
◆ set_parameters_glorot()
|
inlinevirtual |
Initializes parameters using Glorot (Xavier) initialization.
Reimplemented in opennn::BatchNormOp, opennn::CombinationOp, opennn::CombinationReluOp, opennn::ConvolutionOp, opennn::ConvolutionReluOp, opennn::EmbeddingLookupOp, opennn::LayerNormOp, and opennn::MultiHeadProjectionOp.
◆ set_parameters_random()
|
inlinevirtual |
Initializes parameters with random values.
Reimplemented in opennn::BatchNormOp, opennn::CombinationOp, opennn::CombinationReluOp, opennn::ConvolutionOp, opennn::ConvolutionReluOp, opennn::EmbeddingLookupOp, opennn::LayerNormOp, and opennn::MultiHeadProjectionOp.
◆ state_specs()
|
inlinevirtual |
Returns the tensor specs of persistent state owned by this operator.
Reimplemented in opennn::BatchNormOp, and opennn::EmbeddingLookupOp.
◆ to_JSON()
|
inlinevirtual |
Serializes the operator configuration to a JSON writer.
Reimplemented in opennn::ActivationOp, opennn::AttentionOp, opennn::BatchNormOp, and opennn::DropoutOp.
Member Data Documentation
◆ input_delta_slots
| vector<size_t> opennn::Operator::input_delta_slots = {1} |
◆ input_slots
| vector<size_t> opennn::Operator::input_slots = {0} |
◆ output_delta_slots
| vector<size_t> opennn::Operator::output_delta_slots = {0} |
◆ output_slots
| vector<size_t> opennn::Operator::output_slots = {1} |