OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
opennn::CombinationOp Struct Reference

Affine combination output = input * weights + bias (the dense matmul building block). More...

#include <operators.h>

Inheritance diagram for opennn::CombinationOp:
[legend]

Public Member Functions

void set (Index new_input_features, Index new_output_features, Type new_weight_type=Type::FP32)
 Configures input/output dimensions and the weight storage dtype.
 
vector< TensorSpecparameter_specs () const override
 Returns the tensor specs of trainable parameters owned by this operator.
 
void link_parameters (span< const TensorView > views) override
 Binds parameter views provided by the hosting layer.
 
void link_gradients (span< const TensorView > views) override
 Binds gradient views provided by the hosting layer.
 
void set_parameters_random () override
 Initializes parameters with random values.
 
void set_parameters_glorot () override
 Initializes parameters using Glorot (Xavier) initialization.
 
void forward_propagate (ForwardPropagation &fp, size_t layer, bool is_training) noexcept override
 Runs the operator's forward computation.
 
void back_propagate (ForwardPropagation &fp, BackPropagation &bp, size_t layer) const noexcept override
 Runs the operator's backward computation, accumulating into gradient/delta buffers.
 
void apply (const TensorView &input, TensorView &output, cublasLtEpilogue_t epilogue=CUBLASLT_EPILOGUE_BIAS)
 Computes output = input * weights + bias with an optional fused epilogue (ReLU, bias, etc.).
 
void apply_delta (const TensorView &output_delta, const TensorView &input, TensorView &input_delta, bool accumulate_input_delta=false) const
 Computes input_delta from output_delta and updates weight/bias gradients.
 
- Public Member Functions inherited from opennn::Operator
virtual ~Operator ()=default
 
virtual vector< TensorSpecstate_specs () const
 Returns the tensor specs of persistent state owned by this operator.
 
virtual void link_states (span< const TensorView >)
 Binds state views provided by the hosting layer.
 
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.
 
TensorViewget_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
 
TensorViewget_output (ForwardPropagation &fp, size_t layer, size_t i=0) const noexcept
 
TensorViewget_output_delta (BackPropagation &bp, size_t layer, size_t i=0) const noexcept
 
TensorViewget_input_delta (BackPropagation &bp, size_t layer, size_t i=0) const noexcept
 

Public Attributes

Index input_features = 0
 
Index output_features = 0
 
Type weight_type = Type::FP32
 
TensorView weights
 
TensorView bias
 
TensorView weight_gradient
 
TensorView bias_gradient
 
- Public Attributes inherited from opennn::Operator
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

Affine combination output = input * weights + bias (the dense matmul building block).

Member Function Documentation

◆ apply()

void opennn::CombinationOp::apply ( const TensorView & input,
TensorView & output,
cublasLtEpilogue_t epilogue = CUBLASLT_EPILOGUE_BIAS )

Computes output = input * weights + bias with an optional fused epilogue (ReLU, bias, etc.).

◆ apply_delta()

void opennn::CombinationOp::apply_delta ( const TensorView & output_delta,
const TensorView & input,
TensorView & input_delta,
bool accumulate_input_delta = false ) const

Computes input_delta from output_delta and updates weight/bias gradients.

Parameters
output_deltaGradient w.r.t. the operator's output.
inputForward-pass input (needed for the weight gradient).
input_deltaOutput: gradient w.r.t. the operator's input.
accumulate_input_deltaIf true, accumulates into input_delta instead of overwriting.

◆ back_propagate()

void opennn::CombinationOp::back_propagate ( ForwardPropagation & fp,
BackPropagation & bp,
size_t layer ) const
overridevirtualnoexcept

Runs the operator's backward computation, accumulating into gradient/delta buffers.

Parameters
fpForward propagation workspace (read-only).
bpBack propagation workspace receiving gradients and deltas.
layerIndex of the hosting layer in the workspace.

Reimplemented from opennn::Operator.

◆ forward_propagate()

void opennn::CombinationOp::forward_propagate ( ForwardPropagation & fp,
size_t layer,
bool is_training )
overridevirtualnoexcept

Runs the operator's forward computation.

Parameters
fpForward propagation workspace.
layerIndex of the hosting layer in the workspace.
is_trainingIf true, enables training-only behavior (e.g. dropout sampling).

Reimplemented from opennn::Operator.

◆ link_gradients()

void opennn::CombinationOp::link_gradients ( span< const TensorView > )
overridevirtual

Binds gradient views provided by the hosting layer.

Reimplemented from opennn::Operator.

◆ link_parameters()

void opennn::CombinationOp::link_parameters ( span< const TensorView > )
overridevirtual

Binds parameter views provided by the hosting layer.

Reimplemented from opennn::Operator.

◆ parameter_specs()

vector< TensorSpec > opennn::CombinationOp::parameter_specs ( ) const
overridevirtual

Returns the tensor specs of trainable parameters owned by this operator.

Reimplemented from opennn::Operator.

◆ set()

void opennn::CombinationOp::set ( Index new_input_features,
Index new_output_features,
Type new_weight_type = Type::FP32 )

Configures input/output dimensions and the weight storage dtype.

Parameters
new_input_featuresNumber of input features.
new_output_featuresNumber of output features.
new_weight_typeStorage dtype of the weight matrix.

◆ set_parameters_glorot()

void opennn::CombinationOp::set_parameters_glorot ( )
overridevirtual

Initializes parameters using Glorot (Xavier) initialization.

Reimplemented from opennn::Operator.

◆ set_parameters_random()

void opennn::CombinationOp::set_parameters_random ( )
overridevirtual

Initializes parameters with random values.

Reimplemented from opennn::Operator.

Member Data Documentation

◆ bias

TensorView opennn::CombinationOp::bias

◆ bias_gradient

TensorView opennn::CombinationOp::bias_gradient

◆ input_features

Index opennn::CombinationOp::input_features = 0

◆ output_features

Index opennn::CombinationOp::output_features = 0

◆ weight_gradient

TensorView opennn::CombinationOp::weight_gradient

◆ weight_type

Type opennn::CombinationOp::weight_type = Type::FP32

◆ weights

TensorView opennn::CombinationOp::weights