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

Method alloc

tinygrad/runtime/support/memory.py:7–12  ·  view source on GitHub ↗
(self, size:int, alignment:int=1)

Source from the content-addressed store, hash-verified

5class BumpAllocator:
6 def __init__(self, size:int, base:int=0, wrap:bool=True): self.size, self.ptr, self.base, self.wrap = size, 0, base, wrap
7 def alloc(self, size:int, alignment:int=1) -> int:
8 if round_up(self.ptr, alignment) + size > self.size:
9 if not self.wrap: raise RuntimeError("Out of memory")
10 self.ptr = 0
11 self.ptr = (res:=round_up(self.ptr, alignment)) + size
12 return res + self.base
13
14class TLSFAllocator:
15 """

Callers 2

alloc_vaddrMethod · 0.45
pallocMethod · 0.45

Calls 1

round_upFunction · 0.90

Tested by

no test coverage detected