add destructor for infer
This commit is contained in:
parent
b589483cd1
commit
b9cc44ef16
|
@ -15,15 +15,26 @@
|
|||
*/
|
||||
#include "nnacl/infer/infer_register.h"
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((destructor)) void FreeInferFuncBuf() {
|
||||
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…
Reference in New Issue