MCPcopy
hub / github.com/tinygrad/tinygrad / empty

Method empty

tinygrad/uop/ops.py:717–721  ·  view source on GitHub ↗
(shape:tuple[sint, ...], dtype:DTypeLike|None=None, device:str|tuple[str, ...]|None=None, axis:int|None=None, num=None)

Source from the content-addressed store, hash-verified

715 return uop
716 @staticmethod
717 def empty(shape:tuple[sint, ...], dtype:DTypeLike|None=None, device:str|tuple[str, ...]|None=None, axis:int|None=None, num=None) -> UOp:
718 dtype, device = to_dtype(dtype) if dtype is not None else dtypes.default_float, canonicalize_device(device)
719 max_shape = to_max_shape(shape)
720 ret = UOp.new_buffer(device, prod(max_shape), dtype, num).reshape(max_shape).shrink_to(shape)
721 return ret.multi(axis) if isinstance(device, tuple) and axis is not None else ret
722 def empty_like(self, dtype:DTypeLike|None=None, device:str|tuple[str, ...]|None=None) -> UOp:
723 device = canonicalize_device(self.device if device is None else device)
724 axis = self.axis if isinstance(device, tuple) else None

Callers 15

_init_stateMethod · 0.45
_init_stateMethod · 0.45
safe_saveFunction · 0.45
get_empty_input_dataMethod · 0.45
_embedding_bwdFunction · 0.45
empty_likeMethod · 0.45
_allocMethod · 0.45
finalizeMethod · 0.45
index.jsFile · 0.45
test_mnist_backwardMethod · 0.45
derandomize_modelFunction · 0.45

Calls 8

to_dtypeFunction · 0.90
canonicalize_deviceFunction · 0.90
prodFunction · 0.90
to_max_shapeFunction · 0.85
shrink_toMethod · 0.80
reshapeMethod · 0.80
new_bufferMethod · 0.80
multiMethod · 0.80

Tested by 15

test_mnist_backwardMethod · 0.36
test_buffer_refcountMethod · 0.36
test_codegen_tracingMethod · 0.36
test_metadata_tracingMethod · 0.36
test_recurseMethod · 0.36
test_jitMethod · 0.36
fxnMethod · 0.36
test_python_markerMethod · 0.36
_allocFunction · 0.36