mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-02-16 01:26:29 -05:00
hotfix ctypes.c_ulong(size) for metal _alloc (#7902)
fix `Tensor.ones(1000, 1000, 1000).contiguous().realize()` on METAL
This commit is contained in:
@@ -135,7 +135,8 @@ class MetalAllocator(LRUAllocator):
|
||||
super().__init__()
|
||||
def _alloc(self, size:int, options) -> MetalBuffer:
|
||||
# Buffer is explicitly released in _free() rather than garbage collected via reference count
|
||||
ret = msg(self.dev.sysdevice, "newBufferWithLength:options:", size, MTLResourceOptions.MTLResourceStorageModeShared, restype=objc_id)
|
||||
ret = msg(self.dev.sysdevice, "newBufferWithLength:options:", ctypes.c_ulong(size), MTLResourceOptions.MTLResourceStorageModeShared,
|
||||
restype=objc_id)
|
||||
if ret.value is None: raise MemoryError(f"Metal OOM while allocating {size=}")
|
||||
return MetalBuffer(ret, size)
|
||||
def _free(self, opaque:MetalBuffer, options): msg(opaque.buf, "release")
|
||||
|
||||
Reference in New Issue
Block a user