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

[Relay] Remove FTVMCompute from TNonComputational ops #9334

Merged

Conversation

electriclilies
Copy link
Contributor

Some non computational ops have the FTVMCompute attr set to the TOPI identity function. Since the ops are noncomputational, this compute function should do nothing. In this PR, I remove the FTVMCompute attribute from all noncomputational Relay ops.

@AndrewZhaoLuo
Copy link
Contributor

Can you go into a little more detail on why these have FTVMCompute? My worry is that there is some pass somewhere which grabs this attribute for these and this change will break things.

@electriclilies
Copy link
Contributor Author

electriclilies commented Oct 20, 2021

@AndrewZhaoLuo Since they are marked non computational the compute shouldn't ever be running. If the compute is running then they shouldn't be marked as non computational.
I think that FTVMCompute ended up on some of these ops because people were just copy pasting from other ops, I don't think there is any "purpose" for the FTVMCompute attr in these cases.

@AndrewZhaoLuo
Copy link
Contributor

Makes sense, I just wanted an audit to make sure people aren't using the FTVMCompute attr willy nilly through the code base. It doesn't look like they are though.

Copy link
Member

@masahi masahi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also probably remove FInferCorrectLayout stuff from these ops.

@masahi masahi merged commit f4c146c into apache:main Oct 21, 2021
@electriclilies electriclilies deleted the remove-compute-from-noncomputational-ops branch October 21, 2021 16:30
@electriclilies
Copy link
Contributor Author

@masahi Thanks!

@electriclilies
Copy link
Contributor Author

electriclilies commented Oct 21, 2021

@masahi For removing FInferCorrectLayout, it looks like most of attrs are set to ElemwiseArbitraryLayout, but some of the QNN ops are set to custom layout methods (QNN concatenate has the method QnnConcatenateLayout). Do you know if that layout method is actually used?

(cc @AndrewZhaoLuo, you might be interested in this question :) )

@masahi
Copy link
Member

masahi commented Oct 21, 2021

For removing FInferCorrectLayout, it looks like most of attrs are set to ElemwiseArbitraryLayout, but some of the QNN ops are set to custom layout methods

Oh yes, InferLayout functions for QNN ops are used when a user calls ConvertLayout on a quantized model after the model is imported. So this is very important. QnnConcatenateLayout is indeed used and there are other QNN ops that have a specialized FInferCorrectLayout, such as RequantizeInferCorrectLayout.

On the other hand, the ops you removed FTVMCompute from in this PR are not "user-facing" in the same sense that QNN ops are, they are only used by VM during compilation and ConvertLayout pass will never see them. So it should be safe to remove FInferCorrectLayout from them.

I didn't realize that QNN ops are marked TNonComputational, but they are kind of distinct from other TNonComputational ops in this sense.

@electriclilies
Copy link
Contributor Author

@masahi Yeah I think I actually added the TNonComputational option to the QNN ops-- conceptually I guess they are more "symbolic" than non-computational, since they do conceptually compute something, but that compute is injected during legalization, which is wayyy before lowering.
I added it because when I was working on quantization, one time I accidentally skipped the legalize pass and then lowering broke in a weird way. But with the TNoncomputational attr set it would just throw an error.

ylc pushed a commit to ylc/tvm that referenced this pull request Jan 7, 2022
* remove FTVMCompute from noncomputational ops

* Remove injective schedule registration for on_device since it is non-computational

* lint
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
* remove FTVMCompute from noncomputational ops

* Remove injective schedule registration for on_device since it is non-computational

* lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants