MCPcopy
hub / github.com/tinygrad/tinygrad / unwrap_multi

Function unwrap_multi

tinygrad/engine/realize.py:142–147  ·  view source on GitHub ↗
(call:UOp, resolved:list[UOp])

Source from the content-addressed store, hash-verified

140def resolve_params(call:UOp, inputs:tuple[UOp, ...]) -> list[UOp]: return [_resolve(b, inputs) for b in get_call_arg_uops(call)]
141
142def unwrap_multi(call:UOp, resolved:list[UOp]) -> Iterator[tuple[list[Buffer], dict[str, int]]]:
143 bufs = [b.buffer for b in resolved]
144 if not any(isinstance(b, MultiBuffer) for b in bufs): yield cast(list[Buffer], bufs), {}
145 else:
146 dnum = next((x.expr for x in call.src[0].variables() if x.expr == '_device_num'), None)
147 for j, per_dev in enumerate(zip(*[cast(MultiBuffer, b).bufs for b in bufs])): yield list(per_dev), {dnum: j} if dnum else {}
148
149def exec_view(ctx:ExecContext, call:UOp, ast:UOp) -> float|None:
150 resolved = resolve_params(call, ctx.input_uops)

Callers 5

__init__Method · 0.90
exec_copyFunction · 0.85
exec_kernelFunction · 0.85
exec_validateFunction · 0.85

Calls 2

castFunction · 0.85
variablesMethod · 0.80

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…