pytorch
07cdea7c - inductor: fix guard_equals (#94506)

Commit
1 year ago
inductor: fix guard_equals (#94506) Fixes https://github.com/pytorch/pytorch/issues/94268. In the code before https://github.com/pytorch/pytorch/pull/92609, there was an assertion in the `guard_equals` function. ```python assert self.size_hint(expr) == 0, (expr, self.size_hint(expr)) ``` In https://github.com/pytorch/pytorch/pull/92609, `guard_equals` has been changed to ```python def guard_equals(self, left: Expr, right: Expr) -> Expr: self.shape_env.evaluate_expr(sympy.Eq(left, right)) return left ``` Considering the case where `left` and `right` are both concrete values for example, `left = 10` and `right = 20`. In the current code, `self.shape_env.evaluate_expr(sympy.Eq(left, right))` will directly return `False`: https://github.com/pytorch/pytorch/blob/a81cf49d9733b04a2931c85a154ab0bb698650b3/torch/fx/experimental/symbolic_shapes.py#L1380-L1385 This returned value is not used anywhere and the `guard_equals` function will still `return left` in this case even though `left != right`. Pull Request resolved: https://github.com/pytorch/pytorch/pull/94506 Approved by: https://github.com/jgong5, https://github.com/EikanWang, https://github.com/jansel, https://github.com/Chillee
Author
Committer
Parents
Loading