MCPcopy Index your code
hub / github.com/tinygrad/tinygrad / alloc

Method alloc

tinygrad/device.py:230–234  ·  view source on GitHub ↗
(self, size:int, options:BufferSpec|None=None)

Source from the content-addressed store, hash-verified

228 self.supports_copy_from_disk, self.supports_transfer = supports_copy_from_disk, supports_transfer
229 # overridden in LRUAllocator
230 def alloc(self, size:int, options:BufferSpec|None=None):
231 assert size > 0, f"alloc size must be positive, getting {size}"
232 try: return self._alloc(size, options if options is not None else self.default_buffer_spec)
233 except (RuntimeError, MemoryError) as e: raise MemoryError(f"Allocation of {size_to_str(size)} failed on {self.dev.device}. "
234 f"Used: {size_to_str(GlobalCounters.mem_used_per_device[self.dev.device])}") from e
235 def free(self, opaque, size:int, options:BufferSpec|None=None):
236 self._free(opaque, options if options is not None else self.default_buffer_spec)
237

Callers 15

allocateMethod · 0.45
allocMethod · 0.45
eval_uopFunction · 0.45
_run_hwFunction · 0.45
_run_hwFunction · 0.45
_run_wave64_hwFunction · 0.45
run_program_hwFunction · 0.45
test_alloc_oomMethod · 0.45
test_freeMethod · 0.45
test_oomMethod · 0.45
_runMethod · 0.45
fuzz_kfd.pyFile · 0.45

Calls 2

_allocMethod · 0.95
size_to_strFunction · 0.90

Tested by 15

_run_hwFunction · 0.36
_run_hwFunction · 0.36
_run_wave64_hwFunction · 0.36
test_alloc_oomMethod · 0.36
test_freeMethod · 0.36
test_oomMethod · 0.36
_runMethod · 0.36
testMethod · 0.36
test_basic_alloc_freeMethod · 0.36
test_merge_blocksMethod · 0.36
test_split_blocksMethod · 0.36