mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-08-30 17:06:06 +00:00
Div mod recombine test for issue (#7957)
* Add test for failing div_mod recombine * Add test case when there is gcd in div/mod
This commit is contained in:
@@ -423,6 +423,19 @@ class TestSymbolic(unittest.TestCase):
|
||||
self.helper_test_variable(gidx%4+(gidx//4)*4, 0, 124, "gidx")
|
||||
self.helper_test_variable((gidx//4)*4+gidx%4, 0, 124, "gidx")
|
||||
|
||||
def test_div_mod_recombine_folded_mod(self):
|
||||
a = Variable("a", 0, 2)
|
||||
b = Variable("b", 0, 100)
|
||||
with self.assertRaises(AssertionError):
|
||||
self.helper_test_variable((31 * a + 1) % 30 + ((31 * a + 1) // 30) * 30, 1, 63, "((a*31)+1)")
|
||||
with self.assertRaises(AssertionError):
|
||||
self.helper_test_variable((31 * b + 1) % 18 + ((31 * b + 1) // 18) * 18, 1, 3101, "((b*31)+1)")
|
||||
|
||||
def test_div_mod_recombine_with_gcd(self):
|
||||
b = Variable("b", 0, 100)
|
||||
with self.assertRaises(AssertionError):
|
||||
self.helper_test_variable((30 * b + 1) % 18 + ((30 * b + 1) // 18) * 18, 1, 3001, "((b*30)+1)")
|
||||
|
||||
def test_arange_unrolled4(self):
|
||||
gidx = Variable("gidx", 0, 2559)
|
||||
unrolled_div = (gidx+2561)//4+(gidx+2562)//4+(gidx+2560)//4+(gidx+2559)//4
|
||||
|
||||
Reference in New Issue
Block a user