MCPcopy
hub / github.com/tinygrad/tinygrad / import_module

Function import_module

tinygrad/runtime/support/amd.py:31–37  ·  view source on GitHub ↗
(name:str, target:tuple[int, int, int], submod="")

Source from the content-addressed store, hash-verified

29# this is not universally correct, see below for an example, but appears reliable for most recent gpus
30# https://github.com/torvalds/linux/blob/9207d47f966be9f4d52e7e0119ac2b7a7e366f3e/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c#L3163
31def import_module(name:str, target:tuple[int, int, int], submod=""):
32 # version overrides
33 target = {("smu", (13, 0, 7)): (13, 0, 0)}.get((name, target), target)
34 mod = getattr(tinygrad.runtime.autogen.am, submod) if submod else tinygrad.runtime.autogen.am
35 if (children:=[c for c in mod.__all__ if c.startswith(name) and (v:=tuple(map(int, c.split('_')[1:])))[0] == target[0] and v <= target]):
36 return getattr(mod, children[-1])
37 raise ImportError(f"Failed to import {submod+'.' if submod else ''}{name} {'.'.join(map(str, target))}")
38
39def import_soc(ip): return getattr(tinygrad.runtime.autogen.am, f"soc_{ip[0]}")
40

Callers 4

__init__Method · 0.90
_ip_moduleMethod · 0.90
__init__Method · 0.90
import_asic_regsFunction · 0.85

Calls 2

splitMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…