AIfES 2
2.0.0
|
Base layer implementation of the Reshape layer. More...
Go to the source code of this file.
Data Structures | |
struct | ailayer_reshape |
General layer structure. More... | |
struct | ailayer_flatten |
Structure of the Flatten layer, based on the reshape layer . More... | |
Typedefs | |
typedef struct ailayer_reshape | ailayer_reshape_t |
typedef struct ailayer_flatten | ailayer_flatten_t |
Functions | |
ailayer_t * | ailayer_reshape (ailayer_reshape_t *layer, ailayer_t *input_layer) |
Initialize and connect the given Reshape layer. More... | |
void | ailayer_reshape_forward (ailayer_t *self) |
Calculate the forward pass for given Reshape layer. More... | |
void | ailayer_reshape_backward (ailayer_t *self) |
Calculate the backward pass for given Reshape layer. More... | |
void | ailayer_reshape_calc_result_shape (ailayer_t *self) |
Calculate the shape of the result tensor (ailayer.result) More... | |
void | ailayer_reshape_print_specs (const ailayer_t *self) |
Print the layer specification. More... | |
Variables | |
const aicore_layertype_t * | ailayer_reshape_type |
Reshape layer type. More... | |
Base layer implementation of the Reshape layer.
This is an "abstract" data-type independent implementation. To use the layer use one of the provided implementations for a specific hardware and data-type (for example from ailayer_reshape_default.h) or set the required math functions on your own.
The Reshape layer (also used as Flatten layer) is used to reshape a tensor during the forward pass without changing any data. This can be useful for example to connect a Dense layer to a convolutional layer by using the Flatten layer.
The results of the forward pass of this layer are written to the result tensor of the base ailayer_t struct.
ailayer_t* ailayer_reshape | ( | ailayer_reshape_t * | layer, |
ailayer_t * | input_layer | ||
) |
Initialize and connect the given Reshape layer.
This function represents the "constructor" of the abstract Reshape layer. It initializes the layer structure and connects it to the previous layer.
This function is not intended to call it directly. Instead use one of the data type specific implementations (like for example ailayer_reshape_f32_default()).
*layer | The layer to initialize. |
*input_layer | The previous layer that provides the inputs to the layer. |
void ailayer_reshape_backward | ( | ailayer_t * | self | ) |
Calculate the backward pass for given Reshape layer.
Implementation of ailayer.backward.
It uses the deltas tensor of the next layer as input and writes the result of the backward pass to the deltas tensor (ailayer.deltas) of the given layer.
When no reshape function is given (ailayer_reshape.reshape = 0), this function does nothing (as the target shape is already defined).
Used math functions (optional; if set to zero, only the shape is changed):
*self | Layer to calculate the backward path for. |
void ailayer_reshape_calc_result_shape | ( | ailayer_t * | self | ) |
Calculate the shape of the result tensor (ailayer.result)
Implementation of ailayer.calc_result_shape.
Resulting shape is given by ailayer_reshape.output_shape and optionally the inferred axis ailayer_reshape.infer_axis.
*self | Layer to calculate the resulting shape for. |
void ailayer_reshape_forward | ( | ailayer_t * | self | ) |
Calculate the forward pass for given Reshape layer.
Implementation of ailayer.forward.
It uses the result tensor of the previous layer as input and writes the result of the forward pass to the result tensor (ailayer.result) of the given layer.
When no reshape function is given (ailayer_reshape.reshape = 0), this function does nothing (as the target shape is already defined).
Used math functions (optional; if set to zero, only the shape is changed):
*self | Layer to calculate the forward path for. |
void ailayer_reshape_print_specs | ( | const ailayer_t * | self | ) |
Print the layer specification.
*self | The layer to print the specification for |
|
extern |
Reshape layer type.
Defines the type of the layer (for example for type checks and debug prints). See aicore_layertype for more information about the layer type.