ThanatosShinji / onnx-tool

A parser, editor and profiler tool for ONNX models.
https://pypi.org/project/onnx-tool/
MIT License
399 stars 52 forks source link

Make onnx-tool support backward propagation MACs calculation #42

Open YuRuiii opened 1 year ago

YuRuiii commented 1 year ago

I've been using onnx-tool for theoretical analysis of ONNX models, and I have a question: Is it possible to enable onnx-tool to calculate the MACs during backward propagation? If onnx-tool supports this feature, it would greatly enhance our ability to analyze the performance of models during training. I am willing to assist if you think it is feasible to implement this feature.

ThanatosShinji commented 1 year ago

That's a good suggestion! I think the backward propagation MACs can be calculated also in the profile function. The profile can return a list of [Forward MACs, Backward MACs]. Before this feature, I was thinking about a new shape inference architecture, because the current shape inference does not create a correct tensor data type. I can create a template profile function this week, which returns both forward and backward MACs. Then you are welcome to add each node's backward MACs calculation codes.

ThanatosShinji commented 1 year ago

Now, the main branch code Node.profile function supports backward MACs calculation. Return the backward MACs will activate the backward_MACs column of the profile table.

YuRuiii commented 1 year ago

Thanks for taking my advice! I'll make pull requests when I am available :)