|
OpenNN
Open-source neural networks library
|
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} |
Base class for compute building blocks composed by layers (matmul, activation, dropout, etc.).
|
virtualdefault |
|
inlinevirtualnoexcept |
Runs the operator's backward computation, accumulating into gradient/delta buffers.
| 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.
|
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.
|
inlinevirtualnoexcept |
Runs the operator's forward computation.
| 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.
|
inlinevirtual |
Restores the operator configuration from a JSON node.
Reimplemented in opennn::ActivationOp, opennn::AttentionOp, opennn::BatchNormOp, and opennn::DropoutOp.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
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.
|
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.
|
inlinevirtual |
Binds state views provided by the hosting layer.
Reimplemented in opennn::BatchNormOp, and opennn::EmbeddingLookupOp.
|
inlinevirtual |
Restores persistent state (e.g. running statistics) from a JSON node.
Reimplemented in opennn::BatchNormOp.
|
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.
|
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.
|
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.
|
inlinevirtual |
Returns the tensor specs of persistent state owned by this operator.
Reimplemented in opennn::BatchNormOp, and opennn::EmbeddingLookupOp.
|
inlinevirtual |
Serializes the operator configuration to a JSON writer.
Reimplemented in opennn::ActivationOp, opennn::AttentionOp, opennn::BatchNormOp, and opennn::DropoutOp.
| vector<size_t> opennn::Operator::input_delta_slots = {1} |
| vector<size_t> opennn::Operator::input_slots = {0} |
| vector<size_t> opennn::Operator::output_delta_slots = {0} |
| vector<size_t> opennn::Operator::output_slots = {1} |