Skip to content

Commit

Permalink
[fximporter] Avoid importing from _torchMlir (#3685)
Browse files Browse the repository at this point in the history
Downstream projects don't necessarily register this C++ module. This
package removes the dependency and uses `torch.iinfo` to access the max
and min values instead.
  • Loading branch information
zjgarvey committed Sep 3, 2024
1 parent b3942ff commit 2960538
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions python/torch_mlir/extras/fx_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
func as func_dialect,
)

from .._mlir_libs._torchMlir import get_int64_max, get_int64_min

__all__ = [
"FxImporter",
Expand Down Expand Up @@ -1186,9 +1185,9 @@ def set_symbolic_guards(
def _sympy_int_to_int(val: sympy.Expr, adjust_func: Callable):
# Convert simple sympy Integers into concrete int
if val in infs:
return get_int64_max()
return torch.iinfo(torch.int64).max
if val in tuple(-inf for inf in infs):
return get_int64_min()
return torch.iinfo(torch.int64).min
if isinstance(val, sympy.Integer):
return int(val)
# TODO: Remove this adjustment when fractional ranges are removed
Expand Down

0 comments on commit 2960538

Please sign in to comment.