Skip to content

Commit

Permalink
Specialize symfloats that flow through is_integer (#139572)
Browse files Browse the repository at this point in the history
Summary:
Fixes `python test/dynamo/test_dynamic_shapes.py DynamicShapesFunctionTests.test_number_method_method_is_integer_num_type6_dynamic_shapes` when specialize_float = False

X-link: pytorch/pytorch#139572
Approved by: https://github.com/ezyang
ghstack dependencies: #139569, #139457, #139568

Reviewed By: ZainRizvi

Differential Revision: D65492888

Pulled By: bobrenjc93

fbshipit-source-id: 9a9881caa5905686c44d8508ce5edab46ab03f28
  • Loading branch information
bobrenjc93 authored and facebook-github-bot committed Nov 6, 2024
1 parent 4a42e06 commit 3d3b7bb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,15 @@ def get_fake_value(node, tx, allow_non_graph_fake=False):
# no matter it's lazy module or not, we should copy to fake mode.
nnmodule = deepcopy_to_fake_tensor(nnmodule, tx.fake_mode)

if node.name in ["interpolate", "is_integer"]:
# We need to specialize symfloats for now. Eventually we should do a tensorify pass in dynamo.
args = tuple(
float(arg)
if isinstance(arg, torch.SymFloat) and arg.node.hint is not None
else arg
for arg in args
)

try:
with tx.fake_mode, enable_python_dispatcher():
ret_val = wrap_fake_exception(
Expand Down

0 comments on commit 3d3b7bb

Please sign in to comment.