Skip to content

Commit d91f612

Browse files
authored
Add support for int_oo in exir serialization
Differential Revision: D61865297 Pull Request resolved: #4932
1 parent 7600f21 commit d91f612

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

exir/serde/export_serialize.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from torch.fx.experimental import symbolic_shapes
5252
from torch.utils import _pytree as pytree
5353
from torch.utils._pytree import treespec_dumps, treespec_loads
54+
from torch.utils._sympy.numbers import int_oo
5455
from torch.utils._sympy.value_ranges import ValueRanges
5556

5657
# pyre-ignore
@@ -332,9 +333,9 @@ def deserialize_torch_artifact(
332333

333334
def _sympy_int_to_int(val: sympy.Expr, adjust: str):
334335
# Convert simple sympy Integers into concrete int
335-
if val == sympy.oo:
336+
if val in (sympy.oo, int_oo):
336337
return math.inf
337-
if val == -sympy.oo:
338+
if val in (-sympy.oo, -int_oo):
338339
return -math.inf
339340
if isinstance(val, sympy.Integer):
340341
return int(val)
@@ -360,9 +361,9 @@ def _sympy_int_to_int(val: sympy.Expr, adjust: str):
360361
def _int_to_sympy_int(val) -> sympy.Expr:
361362
# Convert concrete int into simple sympy Integers
362363
if val == math.inf:
363-
return sympy.oo
364+
return int_oo
364365
if val == -math.inf:
365-
return -sympy.oo
366+
return -int_oo
366367
return sympy.Integer(val)
367368

368369

0 commit comments

Comments
 (0)