Browse Source

free buffer when program exit

pull/14146/head
chenjianping 4 years ago
parent
commit
41698dbf39
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      mindspore/lite/nnacl/infer/infer_register.c

+ 12
- 1
mindspore/lite/nnacl/infer/infer_register.c View File

@@ -23,9 +23,12 @@ void RegisterInfer() {
_ReshapePrimType_Reshape();
}
#endif
InferShape *g_infer_func;
InferShape *g_infer_func = NULL;

__attribute__((constructor(101))) void InitInferFuncBuf() {
if (g_infer_func != NULL) {
return;
}
g_infer_func = malloc(PrimType_MAX * sizeof(InferShape));
if (g_infer_func != NULL) {
memset(g_infer_func, 0, PrimType_MAX * sizeof(InferShape));
@@ -35,6 +38,14 @@ __attribute__((constructor(101))) void InitInferFuncBuf() {
#endif
}

__attribute__((destructor)) void DestroyInferFuncBuf() {
if (g_infer_func == NULL) {
return;
}
free(g_infer_func);
g_infer_func = NULL;
}

InferShape GetInferFunc(int prim_type) {
if (g_infer_func != NULL && prim_type < PrimType_MAX) {
return g_infer_func[prim_type];


Loading…
Cancel
Save