From 41aea3ad361c0896db806a79de2145aabd5ba9a8 Mon Sep 17 00:00:00 2001 From: nimlgen <138685161+nimlgen@users.noreply.github.com> Date: Sat, 23 Sep 2023 09:36:59 +0300 Subject: [PATCH] require C-contiguous array for hip._copyin (#1902) --- tinygrad/runtime/ops_hip.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tinygrad/runtime/ops_hip.py b/tinygrad/runtime/ops_hip.py index 2529d4b79b..9d02a86974 100644 --- a/tinygrad/runtime/ops_hip.py +++ b/tinygrad/runtime/ops_hip.py @@ -30,7 +30,9 @@ HIP = _HIP() class RawHIPBuffer(RawBufferCopyInOut, RawBufferTransfer): def __init__(self, size, dtype, device=str(HIP.default_device)): super().__init__(size, dtype, allocator=HIP.allocator, **{'device': int(device)}) - def _copyin(self, x:np.ndarray): hip.hipMemcpyAsync(self._buf, x.ctypes.data, self.size * self.dtype.itemsize, hip.hipMemcpyHostToDevice, 0) + def _copyin(self, x:np.ndarray): + x = np.require(x, requirements='C') + hip.hipMemcpyAsync(self._buf, x.ctypes.data, self.size * self.dtype.itemsize, hip.hipMemcpyHostToDevice, 0) def _copyout(self, x:np.ndarray): hip.hipMemcpy(x.ctypes.data, self._buf, self.size * self.dtype.itemsize, hip.hipMemcpyDeviceToHost) def _transfer(self, x): hip.hipMemcpyAsync(self._buf, x._buf, self.size * self.dtype.itemsize, hip.hipMemcpyDeviceToDevice, 0)