MCPcopy
hub / github.com/tinygrad/tinygrad / prod

Function prod

tinygrad/helpers.py:13–13  ·  view source on GitHub ↗
(x:Iterable[T])

Source from the content-addressed store, hash-verified

11U = TypeVar("U")
12# NOTE: it returns int 1 if x is empty regardless of the type of x
13def prod(x:Iterable[T]) -> T|int: return functools.reduce(operator.mul, x, 1)
14
15# NOTE: helpers is not allowed to import from anything else in tinygrad
16OSX, WIN = platform.system() == "Darwin", sys.platform == "win32"

Callers 15

imagehMethod · 0.90
imagefMethod · 0.90
_frompyFunction · 0.90
_apply_winograd_matrixFunction · 0.90
randMethod · 0.90
scaled_uniformMethod · 0.90
glorot_uniformMethod · 0.90
kaiming_uniformMethod · 0.90
kaiming_normalMethod · 0.90
_getitemMethod · 0.90
keccakMethod · 0.90
image_dotMethod · 0.90

Calls 1

reduceMethod · 0.45

Tested by 8

test_tc_upMethod · 0.72
test_emptyMethod · 0.72
test_intsMethod · 0.72
test_variableMethod · 0.72
test_variable_orderMethod · 0.72
_test_uop_resultFunction · 0.72
test_fuzz_allreduceMethod · 0.72
consecFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…