MCPcopy Index your code
hub / github.com/tinygrad/tinygrad / exec_copy

Function exec_copy

tinygrad/engine/realize.py:156–168  ·  view source on GitHub ↗
(ctx:ExecContext, call:UOp, ast:UOp)

Source from the content-addressed store, hash-verified

154 return None
155
156def exec_copy(ctx:ExecContext, call:UOp, ast:UOp) -> float|None:
157 for bufs, device_vars in unwrap_multi(call, resolve_params(call, ctx.input_uops)):
158 dest, src = bufs[0].ensure_allocated(), bufs[1].ensure_allocated()
159 with track_stats(ctx, call, dest.device, [dest, src], ctx.var_vals):
160 if hasattr(dest.allocator,'_transfer') and dest.allocator.supports_transfer and dest.device.split(":")[0] == src.device.split(":")[0]:
161 dest.allocator._transfer(dest._buf, src._buf, dest.nbytes, src_dev=src.allocator.dev, dest_dev=dest.allocator.dev) # type:ignore[attr-defined]
162 elif src.device.startswith("DISK") and getattr(src.allocator.dev, 'fd', None) is not None \
163 and hasattr(dest.allocator, 'copy_from_disk') and src.nbytes >= 4096 and dest.allocator.supports_copy_from_disk:
164 dest.allocator.copy_from_disk(dest._buf, src._buf, src.nbytes)
165 elif src.device.startswith(("DISK", "TINYFS")) and hasattr(dest.allocator, '_as_buffer'):
166 src.allocator._copyout(dest.allocator._as_buffer(dest._buf), src._buf)
167 else: dest.copyin(src.as_memoryview(allow_zero_copy=True))
168 return None
169
170def exec_kernel(ctx:ExecContext, call:UOp, ast:UOp) -> float|None:
171 et = None

Callers

nothing calls this directly

Calls 11

unwrap_multiFunction · 0.85
resolve_paramsFunction · 0.85
track_statsFunction · 0.85
ensure_allocatedMethod · 0.80
splitMethod · 0.80
copy_from_diskMethod · 0.80
copyinMethod · 0.80
as_memoryviewMethod · 0.80
_transferMethod · 0.45
_copyoutMethod · 0.45
_as_bufferMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…