MCPcopy
hub / github.com/tinygrad/tinygrad / c

Function c

tinygrad/renderer/nir.py:26–26  ·  view source on GitHub ↗
(t:DType, u:bool=True)

Source from the content-addressed store, hash-verified

24aop = {**{x:u_aop for x in (dtypes.bool,)+dtypes.uints}, **{x:s_aop for x in dtypes.sints}, **{x:f_aop for x in dtypes.floats}}
25
26def c(t:DType, u:bool=True) -> str: return "u" if t in dtypes.uints and u else ("i" if t in dtypes.ints else ("f" if t in dtypes.floats else "b"))
27def ncast(b:mesa.nir_builder, src:mesa.nir_def, it:DType, ot:DType) -> mesa.nir_def:
28 if isinstance(it, PtrDType) and ot == dtypes.long: return src
29 return nalu(b, f"{c(it)}2{c(it) if it in dtypes.ints and ot in dtypes.ints else c(ot, ot == dtypes.bool)}{ot.bitsize}", src)

Callers 3

ncastFunction · 0.70
dtype.pyFile · 0.50
test_biasMethod · 0.50

Calls

no outgoing calls

Tested by 1

test_biasMethod · 0.40