Skip to content

Interpretable Error Message for ScalarType Mismatch #6850

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

Closed
proshian opened this issue Nov 14, 2024 · 2 comments
Closed

Interpretable Error Message for ScalarType Mismatch #6850

proshian opened this issue Nov 14, 2024 · 2 comments
Labels
actionable Items in the backlog waiting for an appropriate impl/fix good first issue Good for newcomers module: runtime Issues related to the core runtime and code under runtime/ triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@proshian
Copy link

🚀 The feature, motivation and pitch

Currently, when a module is provided with input of a wrong type (ex. long instead of integer), an error is raised with a message like below:

The 0-th input tensor's scalartype does not meet requirement: found 3 but expected 4

It is not immediately obvious that 3 corresponds to Int and 4 corresponds to Long. This lack of clarity can cause confusion

Possible solutions

  1. Replace numbers with string representations. For example by defining a function with a switch condition for every enum value. I see that this may become a maintainance disaster, but there are better options too like boost/preprocessor usage in this stack overflow answer.
  2. Just provide a link to the file containing the ScalarType class (as far as I can see the link is: https://github.com/pytorch/pytorch/blob/main/torchgen/executorch/model.py)

While this is a small improvement, I believe it would make the error message more clear and helpful

Thank you for executorch :)

Alternatives

No response

Additional context

No response

RFC (Optional)

No response

@GregoryComer GregoryComer added feature actionable Items in the backlog waiting for an appropriate impl/fix triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module module: runtime Issues related to the core runtime and code under runtime/ good first issue Good for newcomers labels Nov 14, 2024
@JacobSzwejbka
Copy link
Contributor

Scalartypes originate here https://github.com/pytorch/executorch/blob/main/runtime/core/portable_type/scalar_type.h (which is a pseudo mirror of the types defined in pytorch/pytorch). But point taken on the readability of the error.

@GregoryComer
Copy link
Member

Should be resolved now with #7537.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Items in the backlog waiting for an appropriate impl/fix good first issue Good for newcomers module: runtime Issues related to the core runtime and code under runtime/ triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

3 participants