MCPcopy
hub / github.com/tinygrad/tinygrad / canonicalize_device

Function canonicalize_device

tinygrad/device.py:57–59  ·  view source on GitHub ↗
(device:str|tuple|list|None)

Source from the content-addressed store, hash-verified

55atexit.register(lambda: [Device[dn].finalize() for dn in Device._opened_devices])
56
57def canonicalize_device(device:str|tuple|list|None) -> str|tuple[str, ...]:
58 if not isinstance(device, (tuple, list)): return Device.canonicalize(device)
59 return canonical[0] if len(canonical:=tuple(Device.canonicalize(d) for d in device)) == 1 else canonical
60
61# **************** Profile ****************
62

Callers 9

__init__Method · 0.90
toMethod · 0.90
shardMethod · 0.90
from_uopMethod · 0.90
randMethod · 0.90
unique_constMethod · 0.90
emptyMethod · 0.90
empty_likeMethod · 0.90
fullMethod · 0.90

Calls 1

canonicalizeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…