MCPcopy
hub / github.com/tinygrad/tinygrad / new_buffer

Method new_buffer

tinygrad/uop/ops.py:710–711  ·  view source on GitHub ↗
(device:str|tuple[str, ...], size:int, dtype:DType, num=None)

Source from the content-addressed store, hash-verified

708
709 @staticmethod
710 def new_buffer(device:str|tuple[str, ...], size:int, dtype:DType, num=None):
711 return UOp(Ops.BUFFER, dtype, (UOp.unique(num), UOp(Ops.DEVICE, arg=device)), size)
712 @staticmethod
713 def from_buffer(opaque:Buffer, device:str|tuple[str, ...]|None=None):
714 buffers[uop:=UOp.new_buffer(device or opaque.device, opaque.size, opaque.dtype)] = opaque.ref(1)

Callers 15

_fromnpFunction · 0.80
_frompyFunction · 0.80
__init__Method · 0.80
_validateFunction · 0.80
_copy_inputFunction · 0.80
from_bufferMethod · 0.80
emptyMethod · 0.80
memory_plan_rewriteFunction · 0.80
create_new_bufferFunction · 0.80
uopMethod · 0.80
add_signalsFunction · 0.80
amd_build_programFunction · 0.80

Calls 2

UOpClass · 0.85
uniqueMethod · 0.80

Tested by 10

test_gcMethod · 0.64
test_gc_uop_in_argMethod · 0.64
test_nestedMethod · 0.64
bFunction · 0.64
_test_uop_resultFunction · 0.64
get_buf_uopFunction · 0.64
run_uopsFunction · 0.64
test_supports_uopMethod · 0.64
run_programFunction · 0.64