Closed tjmc closed 5 years ago
You have encountered a memory fragment issue. Currently nncase uses a first-fit allocator. The 2nd conv2d's output occupies the middle range of the KPU memory, neither of the rest 2 free memory slices are enough to be allocated for the 3rd conv2d's output.
nncase now has a experimental allocator (https://github.com/kendryte/nncase/tree/features/best-alloc) which uses a CP solver to solve the NP-hard allocation problem. You can compile from sources or download prebuilt binaries from CI (https://dev.azure.com/sunnycase/nncase/_build?definitionId=1).
I think there might be a dependency problem. best-alloc build is failing https://dev.azure.com/sunnycase/nncase/_build/results?buildId=23
/home/vsts/.conan/data/cbc/2.10/sunnycase/testing/package/346b7f78d3e4c19940cf936de17de5c2948ede92/lib/libCbcSolver.a(CbcSolver.cpp.o): In function
CbcMain1(int, char const**, CbcModel&, int (*)(CbcModel*, int), CbcSolverUsefulData&)': CbcSolver.cpp:(.text+0xcd27): undefined reference to
CbcHeuristicGreedyCover::CbcHeuristicGreedyCover(CbcModel&)' CbcSolver.cpp:(.text+0xcd76): undefined reference to `CbcHeuristicGreedyEquality::CbcHeuristicGreedyEquality(CbcModel&)'
I see the same error when I build locally.
@tjmc The build issue has been solved now.
Thanks! I'm able to generate the kmodel with the latest changes.
nncase is failing when using a graph with intermediate tensors in: 32x128x128 out: 64x128x128.
Sample tflite graph
./ncc compile detect.tflite detect.kmodel --dataset images/ -i tflite --dump-ir
Fatal: Allocator has ran out of memory
32x128x128 + 64x128x128 = 1048576 + 524288 = 1,572,864
I'd expect this to work since it's less than 2,097,152 bytes.
ir_optimize_2:
ir_import: