Remove dead expect_rational (#135105)
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/135105
Approved by: https://github.com/malfet
diff --git a/torch/fx/experimental/sym_node.py b/torch/fx/experimental/sym_node.py
index add6ced..268f56e 100644
--- a/torch/fx/experimental/sym_node.py
+++ b/torch/fx/experimental/sym_node.py
@@ -436,9 +436,7 @@
def guard_float(self, file, line):
# TODO: use the file/line for some useful diagnostic on why a
# guard occurred
- r = self.shape_env.evaluate_expr(
- self.expr, self.hint, fx_node=self.fx_node, expect_rational=False
- )
+ r = self.shape_env.evaluate_expr(self.expr, self.hint, fx_node=self.fx_node)
try:
return float(r)
except Exception:
diff --git a/torch/fx/experimental/symbolic_shapes.py b/torch/fx/experimental/symbolic_shapes.py
index bc6645c..c6a228f 100644
--- a/torch/fx/experimental/symbolic_shapes.py
+++ b/torch/fx/experimental/symbolic_shapes.py
@@ -4428,7 +4428,7 @@
@_lru_cache
def _maybe_evaluate_static(
self, expr: "sympy.Expr", *, unbacked_only: bool = False, compute_hint: bool = False,
- expect_rational=True, size_oblivious: bool = False, axioms: Optional[Tuple[sympy.Expr]] = None,
+ size_oblivious: bool = False, axioms: Optional[Tuple[sympy.Expr]] = None,
var_to_range: Optional[Tuple[Tuple[sympy.Symbol, ValueRanges]]] = None
) -> "Optional[sympy.Expr]":
"""
@@ -5121,18 +5121,18 @@
@lru_cache(256)
@record_shapeenv_event(save_tracked_fakes=True)
def evaluate_expr(self, orig_expr: "sympy.Expr", hint=None, fx_node=None,
- expect_rational=True, size_oblivious: bool = False, *, forcing_spec: bool = False):
+ size_oblivious: bool = False, *, forcing_spec: bool = False):
try:
- return self._evaluate_expr(orig_expr, hint, fx_node, expect_rational, size_oblivious, forcing_spec=forcing_spec)
+ return self._evaluate_expr(orig_expr, hint, fx_node, size_oblivious, forcing_spec=forcing_spec)
except Exception:
self.log.warning(
- "failed during evaluate_expr(%s, hint=%s, expect_rational=%s, size_oblivious=%s, forcing_spec=%s",
- orig_expr, hint, expect_rational, size_oblivious, forcing_spec
+ "failed during evaluate_expr(%s, hint=%s, size_oblivious=%s, forcing_spec=%s",
+ orig_expr, hint, size_oblivious, forcing_spec
)
raise
def _evaluate_expr(self, orig_expr: "sympy.Expr", hint=None, fx_node=None,
- expect_rational=True, size_oblivious: bool = False, *, forcing_spec: bool = False):
+ size_oblivious: bool = False, *, forcing_spec: bool = False):
"""
Given an expression, evaluates it, adding guards if necessary
"""
@@ -5200,7 +5200,6 @@
expr = orig_expr
static_expr = self._maybe_evaluate_static(expr,
- expect_rational=expect_rational,
size_oblivious=size_oblivious)
if static_expr is not None:
self.log.debug("eval %s == %s [statically known]", orig_expr, static_expr)
@@ -5220,7 +5219,6 @@
if not size_oblivious:
size_oblivious_result = self._maybe_evaluate_static(
expr,
- expect_rational=expect_rational,
size_oblivious=True
)