Open wyanzhao opened 1 year ago
Thanks @wyanzhao for finding the memory leak issue. This is indeed something we have not considered before. We will look into the code and fix it soon.
After further investigation, I found that the hcl.reuse_at
pragma could also cause a memory leak. These include the blur
, blur5
, blur_x
, and conv2d
functions under the reuse.mlir
unit test, as well as the hcl.buffer_at
related unit tests buffer_conv.mlir
and buffer_gemm.mlir
.
Thank you for your attention to this matter.
Yes, we did not include dealloc
operations for all the alloc
operations for now, and expect the memory to be freed automatically after execution.
We identified a possible memory leak in the buffer_add.mlir unit test. The issue seems to be introduced by the hcl.buffer_at pragma. When we run hcl-opt -opt on the following input code:
We get the following output:
As you can see, the
hcl.buffer_at
transformation generates%0 = memref.alloc()
without generatingmemref::deallocs
. According to the documentation from MLIR (Buffer Deallocation Internals),deallocs
have to be placed to free allocated memory and avoid memory leaks, this code could cause memory leaks in some platforms.