bf0_hal_nn_acc.h

Header file -.

Author

Sifli software development team

Typedefs

typedef struct __NNACC_HandleTypeDef NNACC_HandleTypeDef

Enums

enum HAL_NNACC_StateTypeDef

HAL NNACC State structures definition.

Values:

enumerator HAL_NNACC_STATE_RESET

NN_ACC not yet initialized or disabled

enumerator HAL_NNACC_STATE_READY

Peripheral Initialized and ready for use

enumerator HAL_NNACC_STATE_BUSY

An internal process is ongoing

enumerator HAL_NNACC_STATE_TIMEOUT

Timeout state

enumerator HAL_NNACC_STATE_ERROR

NN_ACC state error

enumerator HAL_NNACC_STATE_SUSPEND

NN_ACC process is suspended

enum HAL_NNACC_ModeTypeDef

Values:

enumerator HAL_NNACC_MODE_CONV2D
enumerator HAL_NNACC_MODE_CONV2D_UNSIGNED
enumerator HAL_NNACC_MODE_DEPTHWISE_CONV2D
enumerator HAL_NNACC_MODE_DEPTHWISE_CONV2D_UNSIGNED

Functions

HAL_StatusTypeDef HAL_NNACC_Init(NNACC_HandleTypeDef *nn_acc)

initialize the Neural network accelerator

参数:
  • nn_acc[in] The Neural network accelerator instance

返回值:

HAL_OK – if success, otherwise failed.

HAL_StatusTypeDef HAL_NNACC_Start(NNACC_HandleTypeDef *nn_acc, NNACC_ConfigTypeDef *config)

Start Neural network CNN calulation.

参数:
  • nn_acc[in] The Neural network accelerator instance

  • config[in] CNN configuration

返回值:

HAL_OK – if success, otherwise failed.

HAL_StatusTypeDef HAL_NNACC_Start_IT(NNACC_HandleTypeDef *nn_acc, NNACC_ConfigTypeDef *config)

Start Neural network CNN calulation with interrupt mode.

参数:
  • nn_acc[in] The Neural network accelerator instance

  • config[in] CNN configuration

返回值:

HAL_OK – if success, otherwise failed.

void HAL_NNACC_IRQHandler(NNACC_HandleTypeDef *nn_acc)

CNN calulation interrupt handler.

参数:
  • nn_acc[in] The Neural network accelerator instance

返回值:

None.

struct NNACC_ConfigTypeDef
#include <bf0_hal_nn_acc.h>

Neural nextwork calulation configuration.

Public Members

const int8_t *input

Input vector.

const int8_t *wt

Weights.

const int8_t *bias

Bias.

int8_t *output

output

uint16_t in_dim_x

Input x dimension.

uint16_t in_dim_y

Input y dimension.

uint16_t in_ch_num

Input channel number.

uint16_t kernel_dim_x

CNN kernel x dimension.

uint16_t kernel_dim_y

CNN kernel y dimension.

uint16_t padding_x

x padding

uint16_t padding_y

y padding

uint16_t stride_x

x stride

uint16_t stride_y

y stride

uint16_t out_dim_x

Output x dimension.

uint16_t out_dim_y

Output y dimension.

uint16_t out_ch_num

Output channel number.

uint16_t bias_shift

Output bias shift.

uint16_t out_shift

Output shift.

HAL_NNACC_ModeTypeDef mode
struct __NNACC_HandleTypeDef

Public Members

NN_ACC_TypeDef *instance
HAL_NNACC_StateTypeDef state
void (*CpltCallback)(struct __NNACC_HandleTypeDef *nn_acc)

NNACC complete callback.

void (*ErrorCallback)(struct __NNACC_HandleTypeDef *nn_acc)

NNACC Error callback.