MCPcopy
hub / github.com/tinygrad/tinygrad / const_like

Method const_like

tinygrad/tensor.py:160–160  ·  view source on GitHub ↗
(self, b:ConstType)

Source from the content-addressed store, hash-verified

158 # alu and const_like are used by the mixins
159 def alu(self, op: Ops, *src: Tensor) -> Tensor: return self._apply_uop(lambda *u: u[0].alu(op, *u[1:]), *src)
160 def const_like(self, b:ConstType) -> Tensor: return Tensor(self.uop.const_like(b))
161 @staticmethod
162 def const(dtype:DType, b:ConstType|UOp, device:str|tuple[str, ...]|None=None) -> Tensor:
163 return Tensor(b if isinstance(b, UOp) else UOp.const(dtype, b, device))

Callers 3

dropoutMethod · 0.95
gradientMethod · 0.45

Calls 1

TensorClass · 0.85

Tested by

no test coverage detected