| @@ -15,15 +15,26 @@ | |||||
| */ | */ | ||||
| #include "nnacl/infer/infer_register.h" | #include "nnacl/infer/infer_register.h" | ||||
| InferShape *g_infer_func; | |||||
| InferShape *g_infer_func = NULL; | |||||
| __attribute__((constructor(101))) void InitInferFuncBuf() { | __attribute__((constructor(101))) void InitInferFuncBuf() { | ||||
| if (g_infer_func != NULL) { | |||||
| return; | |||||
| } | |||||
| g_infer_func = malloc(PrimType_MAX * sizeof(InferShape)); | g_infer_func = malloc(PrimType_MAX * sizeof(InferShape)); | ||||
| if (g_infer_func != NULL) { | if (g_infer_func != NULL) { | ||||
| memset(g_infer_func, 0, PrimType_MAX * sizeof(InferShape)); | memset(g_infer_func, 0, PrimType_MAX * sizeof(InferShape)); | ||||
| } | } | ||||
| } | } | ||||
| __attribute__((destructor)) void FreeInferFuncBuf() { | |||||
| if (g_infer_func == NULL) { | |||||
| return; | |||||
| } | |||||
| free(g_infer_func); | |||||
| g_infer_func = NULL; | |||||
| } | |||||
| InferShape GetInferFunc(int prim_type) { | InferShape GetInferFunc(int prim_type) { | ||||
| if (g_infer_func != NULL && prim_type < PrimType_MAX) { | if (g_infer_func != NULL && prim_type < PrimType_MAX) { | ||||
| return g_infer_func[prim_type]; | return g_infer_func[prim_type]; | ||||