Skip to content

Commit 9919932

Browse files
bobrenjc93pytorchmergebot
authored andcommitted
Specialize symfloats that flow through is_integer (pytorch#139572)
Fixes `python test/dynamo/test_dynamic_shapes.py DynamicShapesFunctionTests.test_number_method_method_is_integer_num_type6_dynamic_shapes` when specialize_float = False Pull Request resolved: pytorch#139572 Approved by: https://github.com/ezyang ghstack dependencies: pytorch#139569, pytorch#139457, pytorch#139568
1 parent 350bc2a commit 9919932

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

torch/_dynamo/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,6 +2185,15 @@ def get_fake_value(node, tx, allow_non_graph_fake=False):
21852185
# no matter it's lazy module or not, we should copy to fake mode.
21862186
nnmodule = deepcopy_to_fake_tensor(nnmodule, tx.fake_mode)
21872187

2188+
if node.name in ["interpolate", "is_integer"]:
2189+
# We need to specialize symfloats for now. Eventually we should do a tensorify pass in dynamo.
2190+
args = tuple(
2191+
float(arg)
2192+
if isinstance(arg, torch.SymFloat) and arg.node.hint is not None
2193+
else arg
2194+
for arg in args
2195+
)
2196+
21882197
try:
21892198
with tx.fake_mode, enable_python_dispatcher():
21902199
ret_val = wrap_fake_exception(

0 commit comments

Comments
 (0)