Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add value_infer Support for OP 'Pad', 'Resize' and 'InstanceNormalization' #63

Open
hollyaoyaozi opened this issue Jan 4, 2024 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@hollyaoyaozi
Copy link

hollyaoyaozi commented Jan 4, 2024

Hi,

When i ran shape_infer & profile for detic's onnx model, it reported that PadNode, ResizeNode and InstanceNormalizationNode`s value_infer are not implemented.
It would be appreciated that value_infer implemented for these OPs.

Thank you !

@ThanatosShinji
Copy link
Owner

Is that a public ONNX model?

@hollyaoyaozi
Copy link
Author

hollyaoyaozi commented Jan 5, 2024

Is that a public ONNX model?

It is facebook/Detic's model and generated by someone: facebookresearch/Detic#113
The onnx file i used was downloaded from link: https://drive.google.com/file/d/1hYz19lZk4ugLrUGO0HIP9M2RbXs5A4O-/view?usp=sharing

Besides, it seems OP If is not implemented either, which resides in the onnx file downloaded from link above. I am afraid when shape_infer proceeds and arrives at If node, it will report error.
image

@ThanatosShinji
Copy link
Owner

I've viewed the model myself. The biggest problem is the If operator which requires the support for the subgraph. Supporting one or some operators won't take much time. But the subgraph support is a long-term story. It requires architecture change to support an operator that has a small ONNX graph in its attribute data.

@hollyaoyaozi
Copy link
Author

hollyaoyaozi commented Jan 7, 2024

I've viewed the model myself. The biggest problem is the If operator which requires the support for the subgraph. Supporting one or some operators won't take much time. But the subgraph support is a long-term story. It requires architecture change to support an operator that has a small ONNX graph in its attribute data.

Got it, and thanks for your reply.

I come up with a solution and it may be a workaround to solve my problem considering current onnx-tool's architect does not support subgraph and 'If' node. I have viewed the model in netron.app that each 'If' node has at least a simple branch which only contains one OP, such as 'Identity', 'Squeeze' and 'Constant', which means I can fix which branch to be entered and implement 'If' node's value_infer by using corresponding OP in that branch according to node.name (also need use corresponding input as intensors of value_infer).

My main purpose is to profile this onnx model and get its FLOPS, and fixing these branches will not be a problem (computation in these 'If' nodes is small compared to the whole model). So I wonder if this method will work.

@ThanatosShinji
Copy link
Owner

@hollyaoyaozi it's a good idea! You can have a try. And I have one suggestion: export backbone only. These ops contain If are most likely created by roi_heads. And I believe backbone should contain most FLOPs.

@ThanatosShinji ThanatosShinji added the enhancement New feature or request label Jan 21, 2024
@ThanatosShinji ThanatosShinji self-assigned this Jan 21, 2024
@ThanatosShinji
Copy link
Owner

@hollyaoyaozi here is one workaround link for removing If operator. I hope it can help your case.

@ThanatosShinji
Copy link
Owner

If node is not the only issue of this model. Another issue is that this model needs to compute the value K of TopK node, which is very slow to finish the compute and also useless for profiling. So I set the K to 1000 as the maximum value. Then I can get the profile table.
detic.txt

@ThanatosShinji
Copy link
Owner

@hollyaoyaozi I've updated the example code here

@hollyaoyaozi
Copy link
Author

@ThanatosShinji Thank you very much !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants