AIfES 2  2.0.0
ailayer_reshape.h File Reference

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_tailayer_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_tailayer_reshape_type
 Reshape layer type. More...
 

Detailed Description

Base layer implementation of the Reshape layer.

Version
2.2.0
Date
20.10.2020

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.

Function Documentation

◆ ailayer_reshape()

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()).

Parameters
*layerThe layer to initialize.
*input_layerThe previous layer that provides the inputs to the layer.
Returns
Pointer to the (successfully) initialized general layer structure (ailayer_reshape.base)

◆ ailayer_reshape_backward()

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):

Parameters
*selfLayer to calculate the backward path for.

◆ ailayer_reshape_calc_result_shape()

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.

Parameters
*selfLayer to calculate the resulting shape for.

◆ ailayer_reshape_forward()

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):

Parameters
*selfLayer to calculate the forward path for.

◆ ailayer_reshape_print_specs()

void ailayer_reshape_print_specs ( const ailayer_t self)

Print the layer specification.

Parameters
*selfThe layer to print the specification for

Variable Documentation

◆ ailayer_reshape_type

const aicore_layertype_t* ailayer_reshape_type
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.