83 lines
3.6 KiB
C
83 lines
3.6 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
#ifndef CNN_MACHINE_CODE_DRIVER_H
|
|
#define CNN_MACHINE_CODE_DRIVER_H
|
|
|
|
/* os shim includes */
|
|
#include "os_types_api.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/** \defgroup cnn machine code driver APIs
|
|
* @brief cnn machine code driver
|
|
* These functions are for running CNN engine in machine code mode. In machine code mode, CNN engine can run a whole net whose operations are all CNN-completable.
|
|
* To run this mode, it is necessary that CNN machine code be written into DDR, please find CNN machine code in machine_code.kl, which is generated by our model transfer tool running on PC.
|
|
*/
|
|
|
|
/** @addtogroup cnn_machine_code_APIs
|
|
* @{
|
|
*/
|
|
|
|
/* @brief cnn_prepare_machine_code() - to prepare machine code for running, cache flushing after this function is needed, the original machine code will be overridden
|
|
* @param machine_code_addr: where CNN machine code is put
|
|
* @param feature_addr: where features of the net are put
|
|
* @param weight_addr: where weights of the net are put
|
|
* @param machine_code_size: the size of machine code, this infomation is in the log when running model converter tool
|
|
* @return: None
|
|
*/
|
|
void cnn_prepare_machine_code(uint32_t config_addr, uint32_t feature_addr,
|
|
uint32_t weight_addr, uint32_t machine_code_size);
|
|
|
|
/* @brief cnn_prepare_machine_code_copy() - to prepare machine code for running, cache flushing after this function is needed, the original machine code will be kept
|
|
* @param src_machine_code_addr: where the original CNN machine code is put
|
|
* @param dst_machine_code_addr: where the prepared CNN machine code is put
|
|
* @param feature_addr: where features of the net are put
|
|
* @param weight_addr: where weights of the net are put
|
|
* @param machine_code_size: the size of machine code, this infomation is in the log when running model converter tool
|
|
* @return: None
|
|
*/
|
|
void cnn_prepare_machine_code_copy(uint32_t src_machine_code_addr,
|
|
uint32_t dst_machine_code_addr, uint32_t feature_addr, uint32_t weight_addr,
|
|
uint32_t machine_code_size);
|
|
|
|
/* @brief cnn_run_machine_code() - to run cnn engine in machine code mode, this function will not return until cnn completes running
|
|
* @param machine_code_addr: where CNN machine code is put
|
|
* @return: None
|
|
*/
|
|
void cnn_run_machine_code(uint32_t machine_code_addr);
|
|
|
|
/* @brief cnn_start_machine_code() - to run cnn engine in machine code mode, this function will return immediately without waiting for cnn completing running
|
|
* @param machine_code_addr: where CNN machine code is put
|
|
* @return: None
|
|
*/
|
|
void cnn_start_machine_code(uint32_t machine_code_addr);
|
|
|
|
/* @brief cnn_get_status() - to check if CNN is running
|
|
* @return 0 -- cnn is not running
|
|
* @return non-zero -- cnn is running
|
|
*/
|
|
int8_t cnn_get_status();
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|