Fence model data
parent
4f73860ea2
commit
9a6cbb6f41
|
@ -680,6 +680,8 @@ typedef struct
|
|||
const uint8_t *volatile current_body;
|
||||
dmac_channel_number_t dma_ch;
|
||||
kpu_done_callback_t done_callback;
|
||||
volatile uint8_t load_first;
|
||||
volatile uint8_t is_memory_cache;
|
||||
void *userdata;
|
||||
};
|
||||
|
||||
|
|
|
@ -1273,9 +1273,14 @@ static void kpu_logistic(const kpu_model_logistic_layer_argument_t *arg, kpu_mod
|
|||
static void kpu_conv(const kpu_model_conv_layer_argument_t *arg, kpu_model_context_t *ctx)
|
||||
{
|
||||
volatile kpu_layer_argument_t layer = *(const volatile kpu_layer_argument_t *)(ctx->model_buffer + arg->layer_offset);
|
||||
layer.kernel_load_cfg.data.para_start_addr = (uintptr_t)(ctx->model_buffer + arg->weights_offset);
|
||||
layer.kernel_pool_type_cfg.data.bwsx_base_addr = (uintptr_t)(ctx->model_buffer + arg->bn_offset);
|
||||
layer.kernel_calc_type_cfg.data.active_addr = (uintptr_t)(ctx->model_buffer + arg->act_offset);
|
||||
uintptr_t fix = 0;
|
||||
if(ctx->is_memory_cache)
|
||||
{
|
||||
fix = 0x40000000;
|
||||
}
|
||||
layer.kernel_load_cfg.data.para_start_addr = (uintptr_t)(ctx->model_buffer + arg->weights_offset) - fix;
|
||||
layer.kernel_pool_type_cfg.data.bwsx_base_addr = (uintptr_t)(ctx->model_buffer + arg->bn_offset) - fix;
|
||||
layer.kernel_calc_type_cfg.data.active_addr = (uintptr_t)(ctx->model_buffer + arg->act_offset) - fix;
|
||||
|
||||
if(arg->flags & KLF_MAIN_MEM_OUT)
|
||||
{
|
||||
|
@ -1367,12 +1372,15 @@ static void kpu_upload(const kpu_model_upload_layer_argument_t *arg, kpu_model_c
|
|||
|
||||
int kpu_load_kmodel(kpu_model_context_t *ctx, const uint8_t *buffer)
|
||||
{
|
||||
#if FIX_CACHE
|
||||
configASSERT(!is_memory_cache((uintptr_t)buffer));
|
||||
#endif
|
||||
uintptr_t base_addr = (uintptr_t)buffer;
|
||||
const kpu_kmodel_header_t *header = (const kpu_kmodel_header_t *)buffer;
|
||||
|
||||
if(is_memory_cache((uintptr_t)buffer))
|
||||
{
|
||||
ctx->load_first = 1;
|
||||
ctx->is_memory_cache = 1;
|
||||
}
|
||||
|
||||
if(header->version == 3 && header->arch == 0)
|
||||
{
|
||||
ctx->is_nncase = 0;
|
||||
|
@ -1489,6 +1497,7 @@ static int kpu_kmodel_done(kpu_model_context_t *ctx)
|
|||
.calc_done_int = 1,
|
||||
.layer_cfg_almost_empty_int = 1,
|
||||
.layer_cfg_almost_full_int = 1};
|
||||
ctx->load_first = 0;
|
||||
#if KPU_DEBUG
|
||||
uint32_t cnt_layer_id = ctx->current_layer - 1;
|
||||
uint64_t time = sysctl_get_time_us();
|
||||
|
@ -1588,6 +1597,10 @@ static int ai_step(void *userdata)
|
|||
kpu_logistic((const kpu_model_logistic_layer_argument_t *)layer_body, ctx);
|
||||
break;
|
||||
case KL_K210_CONV:
|
||||
if(ctx->load_first)
|
||||
{
|
||||
memcpy((void *)((uintptr_t)layer_body-0x40000000), layer_body, cnt_layer_header->body_size);
|
||||
}
|
||||
kpu_conv((const kpu_model_conv_layer_argument_t *)layer_body, ctx);
|
||||
return 0;
|
||||
case KL_K210_ADD_PADDING:
|
||||
|
|
Loading…
Reference in New Issue