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

Method empty

tinygrad/tensor.py:483–495  ·  view source on GitHub ↗

Creates an empty tensor with the given shape. You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor. Additionally, all other keyword arguments are passed to the constructor of the tensor. ```python exec="true" source="above" sessi

(*shape, device:str|tuple[str, ...]|None=None, dtype:DTypeLike|None=None, **kwargs)

Source from the content-addressed store, hash-verified

481
482 @staticmethod
483 def empty(*shape, device:str|tuple[str, ...]|None=None, dtype:DTypeLike|None=None, **kwargs) -> Tensor:
484 """
485 Creates an empty tensor with the given shape.
486
487 You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor.
488 Additionally, all other keyword arguments are passed to the constructor of the tensor.
489
490 ```python exec="true" source="above" session="tensor" result="python"
491 t = Tensor.empty(2, 3)
492 print(t.shape)
493 ```
494 """
495 return Tensor(UOp.empty(argfix(*shape), dtype, device), **kwargs)
496
497 def empty_like(self, dtype:DTypeLike|None=None, device:str|tuple[str, ...]|None=None, **kwargs) -> Tensor:
498 """

Callers 5

_frompyFunction · 0.45
numpyMethod · 0.45
from_blobMethod · 0.45
randnMethod · 0.45
decode_hevc_frameMethod · 0.45

Calls 2

argfixFunction · 0.90
TensorClass · 0.85

Tested by

no test coverage detected