MCPcopy
hub / github.com/tinygrad/tinygrad / _fromnp

Function _fromnp

tinygrad/tensor.py:41–45  ·  view source on GitHub ↗
(x: 'numpy.ndarray')

Source from the content-addressed store, hash-verified

39# **** Tensor helper functions ****
40
41def _fromnp(x: 'numpy.ndarray') -> UOp:
42 ret = UOp.new_buffer("NPY", x.size, _from_np_dtype(x.dtype))
43 # fake realize
44 ret.buffer.allocate(x)
45 return ret.reshape(x.shape)
46
47def get_shape(x) -> tuple[int, ...]:
48 # NOTE: str is special because iterating it still yields strs

Callers 1

__init__Method · 0.85

Calls 4

_from_np_dtypeFunction · 0.90
new_bufferMethod · 0.80
allocateMethod · 0.80
reshapeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…