mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-04-07 03:00:26 -04:00
Remove the toCPU copy (#2445)
* Remove the rawbuffer copy in runtime/lib.py on line 44 * remove buffer view * added metadata back, oops * delayed cpu testcase * whitespace * whitespace * buffer behavior as is * Update test_jit.py
This commit is contained in:
@@ -240,5 +240,18 @@ class TestJit(unittest.TestCase):
|
||||
assert len(cache.good_jitted.jit_cache) == 1
|
||||
assert len(cache.bad_jitted.jit_cache) == 1
|
||||
|
||||
def test_jit_buffer_behavior(self):
|
||||
@TinyJit
|
||||
def foo(x) -> Tensor: return x.sum().realize()
|
||||
|
||||
result_1 = foo(Tensor([1] * 2))
|
||||
result_2 = foo(Tensor([2] * 2))
|
||||
result_3 = foo(Tensor([3] * 2))
|
||||
|
||||
# expect the buffer to share underlying buffer
|
||||
np.testing.assert_allclose(result_1.numpy(), [2], atol=1e-4, rtol=1e-5)
|
||||
np.testing.assert_allclose(result_2.numpy(), [6], atol=1e-4, rtol=1e-5)
|
||||
np.testing.assert_allclose(result_3.numpy(), [6], atol=1e-4, rtol=1e-5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user