fix transfer to mapped buffers (#1923)

This commit is contained in:
nimlgen
2023-09-29 10:50:24 +03:00
committed by GitHub
parent f445e056ed
commit 2a49f7e456
2 changed files with 14 additions and 4 deletions

View File

@@ -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()