My proposal is now implemented.

I ended up completely replacing the content of graph_plan_memory.cc with a 
python implementation:
- Redirect to Python: 
https://github.com/tum-ei-eda/tvm/blob/e9184d948edd58635e79c3f21355f2b83b361401/src/relay/backend/graph_plan_memory.cc#L890
- Main implementation: 
https://github.com/tum-ei-eda/tvm/blob/tumeda_memplan/python/tvm/relay/memplan.py
- Support code: 
https://github.com/tum-ei-eda/tvm/tree/tumeda_memplan/python/tvm/relay/memopt

To work with the data-flow graph more conveniently this adds `networkx` as 
dependency. For the optimal solution, this would drag in the optimizer 
`OR-Tools` as well. The code is currently also pretty filled with debug 
functionality that might not be wanted by TVM.

How to contribute this back?

- I have started a PR to add the possibility to return offsets for buffers: 
https://github.com/apache/tvm/pull/8134
- Suggestion: Add the TFLM inspired heuristic as default and leave the 
optimized version as external extension that plugs into an interface? That 
would drop a lot of code and could be implemented without pretty much anything 
in the memopt folder.
- How should the interface to a memory planning implementation look? How about 
a registered function that is called only if it exists? Are there any similar 
_optional extension_ interfaces?
- Any other suggestions?

First results are shown below. This is evaluated on RISC-V and using the [code 
generator](https://github.com/tum-ei-eda/utvm_staticrt_codegen/). There still 
might be some issue, because I would not expect the RAM usage to rise in any 
example. But looks promising so far with 10% reduction for a cifar10 model and 
18% for resnet!

![BVcditJ6Uc|690x107](upload://jFqGuZQ0S8hl8a7ezjPv5HiDBdW.png)





---
[Visit 
Topic](https://discuss.tvm.apache.org/t/discussion-alignment-memory-planning/9730/6)
 to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.tvm.apache.org/email/unsubscribe/ee3839259e6f0cc652c7af0922fbe09a6e74837bce826f633d12f7d2f97860fc).

Reply via email to