mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
[inductor] Fix ModularIndexing assumptions (#152993)
Fixes https://github.com/pytorch/pytorch/issues/151198. Since the result of ModularIndexing can be zero due to the modulo operation, we should not make any assumption about ModularIndexing being positive Pull Request resolved: https://github.com/pytorch/pytorch/pull/152993 Approved by: https://github.com/yf225
This commit is contained in:
parent
d900c68ea6
commit
e5f869999c
|
|
@ -205,6 +205,13 @@ class TestIndexingSimplification(InductorTestCase):
|
|||
self.assertEqual(expr2, actual)
|
||||
self.assertNotEqual(ModularIndexing(x, 1, b), actual)
|
||||
|
||||
def test_modular_indexing_positive(self):
|
||||
x = sympy.Symbol("x", integer=True, positive=True)
|
||||
expr = ModularIndexing(x, 1, 1024) - 1
|
||||
expr2 = abs(expr)
|
||||
|
||||
self.assertNotEqual(expr2, expr)
|
||||
|
||||
def test_expand_floor_div_skipped(self):
|
||||
sizevars = SizeVarAllocator()
|
||||
x = sympy.Symbol("x", integer=True, positive=True)
|
||||
|
|
|
|||
|
|
@ -363,10 +363,6 @@ class ModularIndexing(sympy.Function):
|
|||
p, q = self.args[:2]
|
||||
return fuzzy_eq(p.is_nonnegative, q.is_nonnegative) # type: ignore[attr-defined]
|
||||
|
||||
def _eval_is_positive(self) -> Optional[bool]:
|
||||
p, q = self.args[:2]
|
||||
return fuzzy_eq(p.is_positive, q.is_positive) # type: ignore[attr-defined]
|
||||
|
||||
|
||||
class Where(sympy.Function):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user