Skip to content

Commit

Permalink
Fix eager evaluation of the Rank op | fix(torchlib) (#1303)
Browse files Browse the repository at this point in the history
I mistakenly copied the logic for `IsScalar` to `Rank`. `Rank` needs its
own logic.
  • Loading branch information
justinchuby authored Mar 14, 2024
1 parent d681dbd commit 7f53395
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion onnxscript/function_libs/torch_lib/graph_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,11 @@ def eval_function( # type: ignore[override]
# Fall to call add_function_call
pass
elif isinstance(args[0], Sequence):
return False
if all(isinstance(arg, (int, float)) for arg in args[0]):
return 1
else:
# Fall to call add_function_call
pass
else:
# Python constants are scalars
return 0
Expand Down

0 comments on commit 7f53395

Please sign in to comment.