mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #2447 from openmv/tf_extra_padding
lib/tflm: Add extra padding to arena size.
This commit is contained in:
commit
7b64242e44
@ -51,6 +51,7 @@ extern "C" {
|
|||||||
#include "py_ml.h"
|
#include "py_ml.h"
|
||||||
|
|
||||||
using namespace tflite;
|
using namespace tflite;
|
||||||
|
#define TF_ARENA_EXTRA (512)
|
||||||
#define TF_ARENA_ALIGN (16 - 1)
|
#define TF_ARENA_ALIGN (16 - 1)
|
||||||
#define TF_ARENA_ROUND(x) (((x) + TF_ARENA_ALIGN) & ~(TF_ARENA_ALIGN))
|
#define TF_ARENA_ROUND(x) (((x) + TF_ARENA_ALIGN) & ~(TF_ARENA_ALIGN))
|
||||||
typedef MicroMutableOpResolver<113> MicroOpsResolver;
|
typedef MicroMutableOpResolver<113> MicroOpsResolver;
|
||||||
@ -235,7 +236,7 @@ int ml_backend_init_model(py_ml_model_obj_t *model) {
|
|||||||
mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Failed to allocate tensors"));
|
mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Failed to allocate tensors"));
|
||||||
}
|
}
|
||||||
// Round up the optimal arena size to a multiple of the alignment.
|
// Round up the optimal arena size to a multiple of the alignment.
|
||||||
arena_size = TF_ARENA_ROUND(interpreter.arena_used_bytes());
|
arena_size = TF_ARENA_ROUND(interpreter.arena_used_bytes()) + TF_ARENA_EXTRA;
|
||||||
m_free(arena_memory);
|
m_free(arena_memory);
|
||||||
|
|
||||||
// Allocate the persistent model state and interpreter.
|
// Allocate the persistent model state and interpreter.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user