MCPcopy
hub / github.com/tinygrad/tinygrad / argfix

Function argfix

tinygrad/helpers.py:24–28  ·  view source on GitHub ↗
(*x)

Source from the content-addressed store, hash-verified

22
23def dedup(x:Iterable[T]): return list(dict.fromkeys(x)) # retains list order
24def argfix(*x):
25 if x and x[0].__class__ in (tuple, list):
26 if len(x) != 1: raise ValueError(f"bad arg {x}")
27 return tuple(x[0])
28 return x
29# https://stackoverflow.com/questions/3382352/equivalent-of-numpy-argsort-in-basic-python
30def argsort(x): return type(x)(sorted(range(len(x)), key=x.__getitem__))
31def all_same(items:Sequence): return all(x == items[0] for x in items) # works for empty input

Callers 15

emptyMethod · 0.90
randMethod · 0.90
uniformMethod · 0.90
scaled_uniformMethod · 0.90
glorot_uniformMethod · 0.90
kaiming_uniformMethod · 0.90
kaiming_normalMethod · 0.90
smaxFunction · 0.90
sminFunction · 0.90
__getitem__Method · 0.90
setMethod · 0.90
fullMethod · 0.90

Calls

no outgoing calls

Tested by 4

test_noneMethod · 0.72
test_tupleMethod · 0.72
test_listMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…