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

[Bug][Relax] Inconsistent IRs will be got when Load IRs with R.nn.pad operator #17483

Open
jikechao opened this issue Oct 22, 2024 · 4 comments
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug

Comments

@jikechao
Copy link
Contributor

jikechao commented Oct 22, 2024

Actual behavior

error: pad() got multiple values for argument 'pad_width'
 --> <str>:8:55
   |  
 8 |          gv: R.Tensor((2, 130, 30), dtype="float32") = R.nn.pad(x, R.const(0, "int32"), pad_width=[0, 0, 1, 1, 1, 1], pad_mode="constant")
   |                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Steps to reproduce

import tvm
from tvm import relax
from tvm.script import relax as R

@tvm.script.ir_module
class Module:
    @R.function
    def main(x: R.Tensor((2, 128, 28), "float32")) -> R.Tensor((2, 130, 30), "float32"):
        gv: R.Tensor((2, 130, 30), "float32") = R.nn.pad(x, (0, 0, 1, 1, 1, 1))
        return gv

m = Module
m.show()
m_str = m.script()
m2 = tvm.script.from_source(m_str)
m2.show()  # crash

@junrushao @tqchen @Lunderberg

@jikechao jikechao added needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug labels Oct 22, 2024
@jikechao jikechao changed the title [Bug][Relax] The script() API output wrong IRs with R.nn.pad operator [Bug][Relax] Inconsistent IRs will be got when Load IRs with R.nn.pad operator Oct 22, 2024
@yongwww
Copy link
Member

yongwww commented Oct 24, 2024

looks the nn.pad is not roundtrip-able with tvmscript, the ordering the parameters in parser is different from that in printer.

@jikechao
Copy link
Contributor Author

@yongwww Agree! Should we provide a PR to fix the nn.pad to a roundtrip-able operator?

BTW, R.nn.attention has a similar issue: #17486

@yongwww
Copy link
Member

yongwww commented Oct 26, 2024

@jikechao I'd appreciate it if you could submit a PR to fix this. No worries if you're busy, please let me know and I'll take care of it.

@jikechao
Copy link
Contributor Author

@yongwww I am not very familiar with the relevant source code, it would be better to assign it to other colleagues. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug
Projects
None yet
Development

No branches or pull requests

2 participants