mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-09 15:08:02 -05:00
fix transfer to mapped buffers (#1923)
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import numpy as np
|
||||
import torch
|
||||
import struct
|
||||
import unittest, copy
|
||||
from tinygrad.tensor import Tensor, Device
|
||||
from tinygrad.helpers import dtypes
|
||||
from extra.gradcheck import numerical_jacobian, jacobian, gradcheck
|
||||
from extra.utils import temp
|
||||
|
||||
x_init = np.random.randn(1,3).astype(np.float32)
|
||||
U_init = np.random.randn(3,3).astype(np.float32)
|
||||
@@ -240,5 +242,11 @@ class TestTinygrad(unittest.TestCase):
|
||||
x = copy.deepcopy(Tensor.ones((3,3,3)))
|
||||
np.testing.assert_allclose(x.numpy(), np.ones((3,3,3)))
|
||||
|
||||
def test_copy_from_disk(self):
|
||||
t = Tensor.randn(30, device="CPU").to(f"disk:{temp('test_copy_from_disk')}")
|
||||
a = t[10:20]
|
||||
dev = a.to(Device.DEFAULT)
|
||||
np.testing.assert_allclose(a.numpy(), dev.numpy())
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user