pytorch / executorch

On-device AI across mobile, embedded and edge for PyTorch
https://pytorch.org/executorch/
Other
2.22k stars 368 forks source link

Interpretable Error Message for ScalarType Mismatch #6850

Open proshian opened 1 week ago

proshian commented 1 week ago

🚀 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