Skip to content

Commit 3cfca30

Browse files
committed
Merge branch 'opt/reduce_mem' into 'master'
opt: reduce dl model internal memeory usage. See merge request ai/esp-dl!185
2 parents f7010ef + 28166a0 commit 3cfca30

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

esp-dl/dl/module/include/dl_module_base.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ class Module {
4646
*/
4747
virtual ~Module();
4848

49+
#if CONFIG_SPIRAM
50+
void *operator new(size_t size) { return heap_caps_malloc(size, MALLOC_CAP_SPIRAM); }
51+
52+
void operator delete(void *ptr) { heap_caps_free(ptr); }
53+
#endif
54+
4955
/**
5056
* @brief Get the tensor index of this module's outputs
5157
*

esp-dl/dl/tensor/include/dl_tensor_base.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ class TensorBase {
137137
}
138138
}
139139

140+
#if CONFIG_SPIRAM
141+
void *operator new(size_t size) { return heap_caps_malloc(size, MALLOC_CAP_SPIRAM); }
142+
143+
void operator delete(void *ptr) { heap_caps_free(ptr); }
144+
#endif
145+
140146
/**
141147
* @brief Assign tensor to this tensor
142148
*

0 commit comments

Comments
 (0)