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 is_floating_point() test and better type support in verify_model_vm() #7134

Merged
merged 7 commits into from
Dec 22, 2020

Conversation

TylerADavis
Copy link
Contributor

This PR builds upon #7128 , adding a test for is_floating_point() following masahi's recommendation to look at verify_script_model().

In addition to the test, this PR makes the following changes:

  • verify_script_model() can now pass a dtype to verify_model_vm()
  • verify_model_vm() can now generate random inputs for bool and int dtypes.
  • verify_model_vm() includes TVM dtype information in input_shapes, providing additional type information to operators such as is_floating_point().

These additional changes were made because verify_model_vm() does not currently pass type information to relay.frontend.from_pytorch(), preventing is_floating_point() from working correctly. The changes to random tensor generation were required as torch.randn() does not support bool or int dtypes, and my test requires inputs with these dtypes.

If it would be helpful, I can split the addition of the test and the changes to testing infrastructure out into two separate PRs.

verify_model_vm(script_module, ishapes, idtype=idtype, targets=targets)
else:
verify_model_vm(script_module, ishapes, targets=targets)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need this if/else, just verify_model_vm(script_module, ishapes, idtype=idtype, targets=targets) even if idtype is None should work.

Copy link
Contributor Author

@TylerADavis TylerADavis Dec 21, 2020

Choose a reason for hiding this comment

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

Done. I've cleaned up verify_script_model() and changed the handling of default arguments in verify_model_vm() so that passing in None will result in a torch.float being used. Let me know if the new approach looks good.

@masahi masahi merged commit 968b6f6 into apache:main Dec 22, 2020
@masahi
Copy link
Member

masahi commented Dec 22, 2020

Thanks @TylerADavis

masahi pushed a commit to masahi/tvm that referenced this pull request Dec 24, 2020
…el_vm()` (apache#7134)

* Add div_ and is_floating_point operators

* Add handling of exprs to op, update tests

* add test + supporting functions

* Revert whitespace changes

* Properly assign dtype to random integers

* Reformat with black

* Switched default dtype logic, removed extra line
tkonolige pushed a commit to tkonolige/incubator-tvm that referenced this pull request Jan 11, 2021
…el_vm()` (apache#7134)

* Add div_ and is_floating_point operators

* Add handling of exprs to op, update tests

* add test + supporting functions

* Revert whitespace changes

* Properly assign dtype to random integers

* Reformat with black

* Switched default dtype logic, removed extra line
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Jan 20, 2021
…el_vm()` (apache#7134)

* Add div_ and is_floating_point operators

* Add handling of exprs to op, update tests

* add test + supporting functions

* Revert whitespace changes

* Properly assign dtype to random integers

* Reformat with black

* Switched default dtype logic, removed extra line
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jan 21, 2021
…el_vm()` (apache#7134)

* Add div_ and is_floating_point operators

* Add handling of exprs to op, update tests

* add test + supporting functions

* Revert whitespace changes

* Properly assign dtype to random integers

* Reformat with black

* Switched default dtype logic, removed extra line
electriclilies pushed a commit to electriclilies/tvm that referenced this pull request Feb 18, 2021
…el_vm()` (apache#7134)

* Add div_ and is_floating_point operators

* Add handling of exprs to op, update tests

* add test + supporting functions

* Revert whitespace changes

* Properly assign dtype to random integers

* Reformat with black

* Switched default dtype logic, removed extra line
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.

2 participants