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

[HEXAGON][QHL] Clippling the inputs of HVX version of QHL Sigmoid operation #12919

Merged
merged 4 commits into from
Sep 29, 2022

Conversation

rahul-utkoor
Copy link
Contributor

HVX version of QHL(Qualcomm Hexagon Library) sigmoid generates incorrect output if the input falls outside of [-8.0, 8.0]. To fix this, we need to clip the input to sigmoid in the range between >-8.0 and <8.0.

…enerates incorrect output if the input falls outside of [-8.0, 8.0]. To fix this, we need to clip the input to sigmoid in the range between >-8.0 and <8.0.
@masahi
Copy link
Member

masahi commented Sep 27, 2022

I believe we need to change

TIR_REGISTER_PURE_UNARY_OP("tir.sigmoid");
to enable sigmoid vectorization at the TIR level.


func_name = "sigmoid"
with tvm.transform.PassContext(opt_level=3):
runtime_module = tvm.build(tir_s.mod, target=target, name=func_name)
Copy link
Member

Choose a reason for hiding this comment

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

Can we check the generated asm to make sure that the HVX sigmoid is generated? It needs QHL to be enabled on Hexagon CI.

@rahul-utkoor
Copy link
Contributor Author

I believe we need to change

TIR_REGISTER_PURE_UNARY_OP("tir.sigmoid");

to enable sigmoid vectorization at the TIR level.

@masahi
If we set attribute, TIR_REGISTER_PURE_UNARY_OP("tir.sigmoid").set_attr("TVectorizable", true);, the change will reflect when compiling for other targets as well. Can you tell me how do you want me handle this change? Or the current change is sufficient?

@masahi
Copy link
Member

masahi commented Sep 28, 2022

Good point, I don't find a way to make this per-target registration. For now I think it's fine to make sigmoid vectorizable, since looking at other ops this attribute is set somewhat arbitrarily. It should be easy to scalarize either TIR or LLVM level if necessary.

@masahi masahi merged commit 595f0b3 into apache:main Sep 29, 2022
@rahul-utkoor rahul-utkoor deleted the rutkoor/qhlClippedSigmoid branch September 30, 2022 05:30
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
…ration (apache#12919)

* [HEXAGON][QHL] HVX version of QHL(Qualcomm Hexagon Library) sigmoid generates incorrect output if the input falls outside of [-8.0, 8.0]. To fix this, we need to clip the input to sigmoid in the range between >-8.0 and <8.0.

* setting vectorize attribute for tir.sigmoid to enable vectorization at TIR level

* Asserting if sigmoid/vmin/vmax are not generated

* formatting the test file

Co-authored-by: quic_rutkoor <quic_rutkoor@quicinc.com>
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