Skip to content

feat(relax/frontend/torch): Add basic range constraint support #17898

Closed
demoncoder-crypto wants to merge 16 commits into
apache:mainfrom
demoncoder-crypto:fix/relax-pytorch-constraints-v2
Closed

feat(relax/frontend/torch): Add basic range constraint support #17898
demoncoder-crypto wants to merge 16 commits into
apache:mainfrom
demoncoder-crypto:fix/relax-pytorch-constraints-v2

Conversation

@demoncoder-crypto

Copy link
Copy Markdown

Addresses #17818

@mshr-h

mshr-h commented Apr 27, 2025

Copy link
Copy Markdown
Contributor

@demoncoder-crypto

Copy link
Copy Markdown
Author

done @mshr-h Please check if my implementation is up to expectation

Comment thread python/tvm/relax/frontend/torch/exported_program_translator.py Outdated
Comment thread python/tvm/relax/frontend/torch/exported_program_translator.py Outdated
Comment thread tests/python/relax/test_frontend_from_exported_program.py Outdated
@demoncoder-crypto

Copy link
Copy Markdown
Author

Understood @mshr-h I will fix it.

@demoncoder-crypto

Copy link
Copy Markdown
Author

@mshr-h I have made the changes requested by you

@demoncoder-crypto demoncoder-crypto requested a review from mshr-h May 2, 2025 12:40

@mshr-h mshr-h left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks for the update! Please fix the CI errors so that we can merge it. @demoncoder-crypto

@demoncoder-crypto

demoncoder-crypto commented May 3, 2025

Copy link
Copy Markdown
Author

Tried to fix the errors do let me know if it works now thanks @mshr-h

Edit - i also tried creating helper methods I don't know how to fix the lint error

@demoncoder-crypto demoncoder-crypto force-pushed the fix/relax-pytorch-constraints-v2 branch from 4145c11 to b66a89b Compare May 3, 2025 12:44
@demoncoder-crypto

demoncoder-crypto commented May 3, 2025

Copy link
Copy Markdown
Author

I cannot fix the lint/pr-head its expecting less nesting which would require me to make a helper method should I proceed and make it? @mshr-h

@demoncoder-crypto demoncoder-crypto force-pushed the fix/relax-pytorch-constraints-v2 branch 4 times, most recently from 594a7e4 to 30d49d8 Compare May 3, 2025 14:43
@demoncoder-crypto demoncoder-crypto requested a review from mshr-h May 3, 2025 14:58
@demoncoder-crypto demoncoder-crypto force-pushed the fix/relax-pytorch-constraints-v2 branch 3 times, most recently from 064f5d7 to dc4ebca Compare May 3, 2025 19:52
@demoncoder-crypto demoncoder-crypto force-pushed the fix/relax-pytorch-constraints-v2 branch from dc4ebca to 5c7758c Compare May 3, 2025 22:22

return parameters_buffers_constants, user_inputs, relax_range_constraints

# NEW HELPER METHOD

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove the unnecessary comment.

return parameters_buffers_constants, user_inputs, relax_range_constraints

# NEW HELPER METHOD
def _add_range_constraint(self, constraints_dict, relax_tir_var, min_val, max_val):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@staticmethod would be better since it doesn't access the instance variable or method.

@mshr-h

mshr-h commented May 4, 2025

Copy link
Copy Markdown
Contributor

Adding helper functions is totally fine as long as it's readable and maintainable. @demoncoder-crypto

@mshr-h

mshr-h commented May 4, 2025

Copy link
Copy Markdown
Contributor

I think we need multiple testcases so that we can cover all the possible cases:

  1. lower constraints only
  2. upper constraints only
  3. both the lower and upper constraints
  4. the constraints are overridden by another constraints (this is already in the test)

@yongwww

yongwww commented May 20, 2025

Copy link
Copy Markdown
Member

@demoncoder-crypto pls fix the conflicts and ci

@mshr-h mshr-h left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please fix the CI error and resolve the conflict.

@guan404ming

guan404ming commented Nov 7, 2025

Copy link
Copy Markdown
Member

Hi @mshr-h, it seems like this PR has been inactive for a while. Could I help with this? Thanks!

@mshr-h

mshr-h commented Nov 9, 2025

Copy link
Copy Markdown
Contributor

@guan404ming Feel free to take it over!

@mshr-h

mshr-h commented Nov 12, 2025

Copy link
Copy Markdown
Contributor

Closing as #18429 merged

@mshr-h mshr-h closed this Nov 12, 2025
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.

4 participants