torch.nn.functional.one_hot has inconsistent behavior between eager and torch.compile when num_classes=0 #146274
Labels
actionable
module: fakeTensor
module: pt2-dispatcher
PT2 dispatcher-related issues (e.g., aotdispatch, functionalization, faketensor, custom-op,
oncall: pt2
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
🐛 Describe the bug
When
num_classes=0
,torch.nn.functional.one_hot
will throwClass values must be smaller than num_classes.
under eager but outputs empty tensor under torch.compile.Error logs
Error on eager: Class values must be smaller than num_classes.
Output under torch.compile: tensor([], size=(5, 0), dtype=torch.int64)
Versions
cc @chauhang @penguinwu @eellison @zou3519 @bdhirsh @yf225
The text was updated successfully, but these errors were encountered: