ThanatosShinji / onnx-tool

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

Some question about node profile #6

Closed smallccn closed 2 years ago

smallccn commented 2 years ago

https://github.com/ThanatosShinji/onnx-tool/blob/b6f2ef777d89dd4e294a6e29a16b29fb74fb5ca4/onnx_tool/__init__.py#L192-L208

Dear sir,

About those codes, I have some questions, after call node_profile, the return value _params_c is not used. And _params is used as the params of this node, for some nets(ex. Retinanet), this will lead to some Conv's params is 0.

When I use _params_c to replace _params, it seems that I can get a correct result.

So could you please help to share some ideas about this? Thanks.

ThanatosShinji commented 2 years ago

_params_c is counted by the NodeProfiler which may be wrong sometimes. e.g. the convolution weight is shared among nodes. And if both inputs of Matmul are dynamic tensors, _params_c should be zero but it won't. That's the reason why I deprecated it.

About your problem, I believe it's the case that the convolution weight is shared by multiple nodes. You can check the console logs for "Weight Sharing is detected".