(name:str, target:tuple[int, int, int], submod="")
| 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 |
| 31 | def 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 | |
| 39 | def import_soc(ip): return getattr(tinygrad.runtime.autogen.am, f"soc_{ip[0]}") |
| 40 |
no test coverage detected
searching dependent graphs…