mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-06-24 02:14:17 +00: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:
parent
631dc98b52
commit
04bee97d2a
1 changed files with 2 additions and 1 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue