#include <opennn/network/layers/layer.h>
Classes | |
| struct | TiedWeight |
Public Member Functions | |
| virtual | ~Layer ()=default |
| const string & | get_label () const noexcept |
| const string & | get_name () const |
| LayerType | get_type () const noexcept |
| virtual bool | accepts_input_rank (Index) const |
| void | set_input_shape (const Shape &new_input_shape) |
| virtual void | set_output_shape (const Shape &) |
| void | set_label (string new_label) |
| Index | get_parameters_number () const |
| const vector< Operator * > & | get_operators () const noexcept |
| virtual vector< TensorSpec > | get_parameter_specs () const |
| virtual vector< TensorSpec > | get_state_specs () const |
| virtual vector< TensorSpec > | get_forward_specs (Index batch_size) const |
| virtual vector< TensorSpec > | get_backward_specs (Index batch_size) const |
| virtual ForwardSlotKind | get_forward_slot_kind (size_t) const |
| virtual bool | is_forward_slot_inference_elidable (size_t, Device) const noexcept |
| virtual size_t | get_recomputable_forward_slot () const noexcept |
| virtual void | recompute_forward_slot (ForwardPropagation &, size_t) |
| virtual bool | backward_uses_forward_output () const noexcept |
| virtual bool | backward_uses_input (size_t) const noexcept |
| virtual bool | preserves_output_delta_during_backward () const noexcept |
| virtual bool | allows_input_delta_alias () const noexcept |
| virtual bool | folds_input_delta_addend (size_t) const noexcept |
| virtual Shape | get_input_shape () const noexcept |
| virtual Shape | get_output_shape () const =0 |
| virtual ActivationFunction | get_output_activation () const |
| virtual Index | get_sources_number () const noexcept |
| virtual bool | allows_successors () const noexcept |
| virtual bool | is_recurrent () const noexcept |
| virtual bool | skip_for_pre_scaled_input () const noexcept |
| virtual bool | uses_sequence_position () const noexcept |
| virtual bool | allows_bf16_input_cast (size_t) const noexcept |
| Index | get_inputs_number () const noexcept |
| Index | get_outputs_number () const |
| virtual void | forward_propagate (ForwardPropagation &forward_propagation, size_t layer, ForwardPropagationMode pass) |
| virtual void | back_propagate (ForwardPropagation &forward_propagation, BackPropagation &back_propagation, size_t i) const |
| virtual void | from_JSON (const JsonDocument &) |
| virtual void | read_JSON_body (const Json *) |
| virtual void | on_loaded () |
| virtual void | load_state_from_JSON (const JsonDocument &) |
| virtual void | to_JSON (JsonWriter &) const |
| virtual void | write_JSON_body (JsonWriter &) const |
| virtual string | write_expression (const vector< string > &, const vector< string > &) const |
| bool | get_is_trainable () const noexcept |
| void | set_is_trainable (bool trainable) |
| Type | get_compute_dtype () const noexcept |
| Device | get_compute_device () const noexcept |
| void | set_compute_dtype (Type new_compute_dtype) |
| void | set_compute_device (Device new_compute_device) |
| virtual void | on_compute_dtype_changed () |
| virtual float * | link_states (float *, Device) |
| float * | link_gradients (float *, Device) |
| vector< TensorView > & | get_parameter_views () |
| const vector< TensorView > & | get_parameter_views () const noexcept |
| vector< TensorView > & | get_parameter_scales () |
| const vector< TensorView > & | get_parameter_scales () const noexcept |
| vector< Operator::SlotQuantization > | get_parameter_quantization () const |
| virtual TiedWeight | get_tied_weight () const |
| virtual void | set_tied_weight (const TiedWeight &tied_weight) |
| void | redistribute_parameters_to_operators () |
Protected Types | |
| enum | Forward { Input , Output } |
Protected Member Functions | |
| virtual void | apply_input_shape (const Shape &new_input_shape) |
| Layer (LayerType type, Trainability trainability=Trainability::Trainable) | |
| float * | link_views_to_operators (vector< TensorView > &, float *, vector< TensorSpec >(Operator::*specs_fn)() const, void(Operator::*link_fn)(span< const TensorView >), Device) |
Static Protected Member Functions | |
| static bool | refresh_feature_storage (Buffer &storage, bool &dirty, Device device, Index features, Index columns, const function< void(float *)> &fill) |
Protected Attributes | |
| string | label = "my_layer" |
| bool | is_trainable = true |
| Shape | input_shape |
| Type | compute_dtype = Type::FP32 |
| Type | weights_dtype = Type::FP32 |
| Device | compute_device = Device::CPU |
| vector< TensorView > | parameters |
| vector< TensorView > | parameter_scales |
| vector< TensorView > | states |
| vector< Operator * > | operators |
Member Enumeration Documentation
◆ Forward
|
protected |
Constructor & Destructor Documentation
◆ ~Layer()
|
virtualdefault |
◆ Layer()
|
inlineprotected |
Member Function Documentation
◆ accepts_input_rank()
|
inlinevirtual |
Reimplemented in opennn::Activation, opennn::Addition, opennn::C2PSA, opennn::Clamping, opennn::Concatenation, opennn::Convolutional, opennn::Dense, opennn::Detection, opennn::DetectionV8, opennn::Embedding, opennn::Flatten, opennn::GroupedQueryAttention, opennn::LSTM, opennn::MultiHeadAttention, opennn::NonMaxSuppression, opennn::Normalization3d, opennn::Pooling3d, opennn::Pooling, opennn::Recurrent, opennn::Scaling, opennn::Tokenizer, and opennn::Upsampling.
◆ allows_bf16_input_cast()
|
inlinevirtualnoexcept |
Reimplemented in opennn::Embedding, and opennn::Tokenizer.
◆ allows_input_delta_alias()
|
inlinevirtualnoexcept |
Reimplemented in opennn::Normalization3d.
◆ allows_successors()
|
inlinevirtualnoexcept |
Reimplemented in opennn::Clamping.
◆ apply_input_shape()
|
inlineprotectedvirtual |
Reimplemented in opennn::Addition, opennn::C2PSA, opennn::Clamping, opennn::Convolutional, opennn::Dense, opennn::Detection, opennn::DetectionV8, opennn::Embedding, opennn::Flatten, opennn::GroupedQueryAttention, opennn::LSTM, opennn::MultiHeadAttention, opennn::NonMaxSuppression, opennn::Normalization3d, opennn::Pooling3d, opennn::Pooling, opennn::Recurrent, opennn::Scaling, opennn::Unscaling, and opennn::Upsampling.
◆ back_propagate()
|
inlinevirtual |
Reimplemented in opennn::Pooling.
◆ backward_uses_forward_output()
|
inlinevirtualnoexcept |
Reimplemented in opennn::Convolutional, opennn::Dense, and opennn::MultiHeadAttention.
◆ backward_uses_input()
|
inlinevirtualnoexcept |
Reimplemented in opennn::Convolutional, and opennn::Normalization3d.
◆ folds_input_delta_addend()
|
inlinevirtualnoexcept |
Reimplemented in opennn::Convolutional, opennn::Dense, and opennn::MultiHeadAttention.
◆ forward_propagate()
|
inlinevirtual |
Reimplemented in opennn::Convolutional, opennn::Pooling, and opennn::Scaling.
◆ from_JSON()
|
virtual |
Reimplemented in opennn::Concatenation.
◆ get_backward_specs()
|
inlinevirtual |
◆ get_compute_device()
|
inlinenoexcept |
◆ get_compute_dtype()
|
inlinenoexcept |
◆ get_forward_slot_kind()
|
inlinevirtual |
◆ get_forward_specs()
|
inlinevirtual |
◆ get_input_shape()
|
inlinevirtualnoexcept |
◆ get_inputs_number()
|
inlinenoexcept |
◆ get_is_trainable()
|
inlinenoexcept |
◆ get_label()
|
inlinenoexcept |
◆ get_name()
| const string & opennn::Layer::get_name | ( | ) | const |
◆ get_operators()
|
inlinenoexcept |
◆ get_output_activation()
|
inlinevirtual |
Reimplemented in opennn::Activation, opennn::Convolutional, opennn::Dense, opennn::LSTM, and opennn::Recurrent.
◆ get_output_shape()
|
pure virtual |
Implemented in opennn::Activation, opennn::Addition, opennn::C2PSA, opennn::Clamping, opennn::Concatenation, opennn::Convolutional, opennn::Dense, opennn::Detection, opennn::DetectionV8, opennn::Embedding, opennn::Flatten, opennn::GroupedQueryAttention, opennn::LSTM, opennn::MultiHeadAttention, opennn::NonMaxSuppression, opennn::Normalization3d, opennn::Pooling3d, opennn::Pooling, opennn::Recurrent, opennn::Scaling, opennn::Tokenizer, and opennn::Upsampling.
◆ get_outputs_number()
|
inline |
◆ get_parameter_quantization()
| vector< Operator::SlotQuantization > opennn::Layer::get_parameter_quantization | ( | ) | const |
◆ get_parameter_scales() [1/2]
|
inline |
◆ get_parameter_scales() [2/2]
|
inlinenoexcept |
◆ get_parameter_specs()
|
virtual |
◆ get_parameter_views() [1/2]
|
inline |
◆ get_parameter_views() [2/2]
|
inlinenoexcept |
◆ get_parameters_number()
| Index opennn::Layer::get_parameters_number | ( | ) | const |
◆ get_recomputable_forward_slot()
|
inlinevirtualnoexcept |
Reimplemented in opennn::Convolutional.
◆ get_sources_number()
|
inlinevirtualnoexcept |
Reimplemented in opennn::Addition, opennn::Concatenation, opennn::Convolutional, opennn::MultiHeadAttention, and opennn::Normalization3d.
◆ get_state_specs()
|
virtual |
◆ get_tied_weight()
|
inlinevirtual |
Reimplemented in opennn::Dense.
◆ get_type()
|
inlinenoexcept |
◆ is_forward_slot_inference_elidable()
|
inlinevirtualnoexcept |
Reimplemented in opennn::Convolutional, and opennn::GroupedQueryAttention.
◆ is_recurrent()
|
inlinevirtualnoexcept |
Reimplemented in opennn::LSTM, and opennn::Recurrent.
◆ link_gradients()
| float * opennn::Layer::link_gradients | ( | float * | , |
| Device | ) |
◆ link_states()
|
virtual |
Reimplemented in opennn::Clamping, and opennn::Scaling.
◆ link_views_to_operators()
|
protected |
◆ load_state_from_JSON()
|
virtual |
Reimplemented in opennn::Concatenation.
◆ on_compute_dtype_changed()
|
inlinevirtual |
◆ on_loaded()
|
inlinevirtual |
Reimplemented in opennn::Convolutional, and opennn::Dense.
◆ preserves_output_delta_during_backward()
|
inlinevirtualnoexcept |
Reimplemented in opennn::Dense, and opennn::MultiHeadAttention.
◆ read_JSON_body()
|
inlinevirtual |
Reimplemented in opennn::Addition, opennn::Clamping, opennn::Concatenation, opennn::Convolutional, opennn::Dense, opennn::Detection, opennn::DetectionV8, opennn::Embedding, opennn::GroupedQueryAttention, opennn::LSTM, opennn::MultiHeadAttention, opennn::NonMaxSuppression, opennn::Normalization3d, opennn::Pooling3d, opennn::Pooling, opennn::Recurrent, opennn::Scaling, opennn::Tokenizer, opennn::Unscaling, and opennn::Upsampling.
◆ recompute_forward_slot()
|
inlinevirtual |
Reimplemented in opennn::Convolutional.
◆ redistribute_parameters_to_operators()
| void opennn::Layer::redistribute_parameters_to_operators | ( | ) |
◆ refresh_feature_storage()
|
staticprotected |
◆ set_compute_device()
|
inline |
◆ set_compute_dtype()
|
inline |
◆ set_input_shape()
|
inline |
◆ set_is_trainable()
|
inline |
◆ set_label()
|
inline |
◆ set_output_shape()
|
inlinevirtual |
Reimplemented in opennn::Dense, opennn::Embedding, opennn::LSTM, and opennn::Recurrent.
◆ set_tied_weight()
|
inlinevirtual |
Reimplemented in opennn::Dense.
◆ skip_for_pre_scaled_input()
|
inlinevirtualnoexcept |
Reimplemented in opennn::Scaling.
◆ to_JSON()
|
virtual |
◆ uses_sequence_position()
|
inlinevirtualnoexcept |
Reimplemented in opennn::GroupedQueryAttention.
◆ write_expression()
|
inlinevirtual |
Reimplemented in opennn::Clamping, opennn::Dense, opennn::LSTM, opennn::Recurrent, opennn::Scaling, and opennn::Unscaling.
◆ write_JSON_body()
|
inlinevirtual |
Reimplemented in opennn::Addition, opennn::Clamping, opennn::Concatenation, opennn::Convolutional, opennn::Dense, opennn::Detection, opennn::DetectionV8, opennn::Embedding, opennn::GroupedQueryAttention, opennn::LSTM, opennn::MultiHeadAttention, opennn::NonMaxSuppression, opennn::Normalization3d, opennn::Pooling3d, opennn::Pooling, opennn::Recurrent, opennn::Scaling, opennn::Tokenizer, opennn::Unscaling, and opennn::Upsampling.
Member Data Documentation
◆ compute_device
|
protected |
◆ compute_dtype
|
protected |
◆ input_shape
|
protected |
◆ is_trainable
|
protected |
◆ label
|
protected |
◆ operators
|
protected |
◆ parameter_scales
|
protected |
◆ parameters
|
protected |
◆ states
|
protected |
◆ weights_dtype
|
protected |