MCPcopy
hub / github.com/tinygrad/tinygrad / make_buffer

Function make_buffer

test/backend/test_graph.py:30–35  ·  view source on GitHub ↗
(device, size=BUF_SIZE, fill=False)

Source from the content-addressed store, hash-verified

28 return cached_asts[(device, num_inputs)]
29
30def make_buffer(device, size=BUF_SIZE, fill=False):
31 buf = Buffer(device, size, dtypes.int).ensure_allocated()
32 if fill:
33 with Context(DEBUG=0):
34 buf.copyin(Tensor(np.random.randint(-10000, 10000, size=size, dtype=np.int32)).realize().uop.base.realized.as_memoryview())
35 return buf
36
37def make_view(base, offset_elems, size_elems):
38 return Buffer(base.device, size_elems, base.dtype, base=base, offset=offset_elems * base.dtype.itemsize).ensure_allocated()

Calls 8

BufferClass · 0.90
ContextClass · 0.90
TensorClass · 0.90
ensure_allocatedMethod · 0.80
copyinMethod · 0.80
as_memoryviewMethod · 0.80
realizeMethod · 0.80
randintMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…