repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/compiler_cuda.py
tinygrad/runtime/support/compiler_cuda.py
import subprocess, hashlib, tempfile, ctypes, re, pathlib from typing import Callable from tinygrad.helpers import to_char_p_p, colored, init_c_var, getenv, system from tinygrad.runtime.autogen import nvrtc, nvjitlink as jitlink from tinygrad.device import Compiler, CompileError CUDA_PATH = getenv("CUDA_PATH", "") de...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/compiler_cpu.py
tinygrad/runtime/support/compiler_cpu.py
import ctypes, platform, sys, subprocess from tinygrad.device import Compiler from tinygrad.helpers import OSX, getenv, capstone_flatdump, DEBUG, unwrap from tinygrad.runtime.support.elf import jit_loader from tinygrad.runtime.autogen import llvm class ClangJITCompiler(Compiler): def __init__(self, cachekey="compile...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/system.py
tinygrad/runtime/support/system.py
import os, mmap, array, functools, ctypes, select, contextlib, dataclasses, sys, errno, itertools from typing import cast, ClassVar from tinygrad.helpers import round_up, getenv, OSX, temp, ceildiv from tinygrad.runtime.autogen import libc, vfio, pci from tinygrad.runtime.support.hcq import FileIOInterface, MMIOInterfa...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/elf.py
tinygrad/runtime/support/elf.py
import struct, ctypes, ctypes.util from dataclasses import dataclass from tinygrad.helpers import getbits, i2u, unwrap from tinygrad.runtime.autogen import libc @dataclass(frozen=True) class ElfSection: name:str; header:libc.Elf64_Shdr; content:bytes # noqa: E702 def link_sym(sym:str, libs:list[str]) -> int: for li...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/hcq.py
tinygrad/runtime/support/hcq.py
from __future__ import annotations from typing import cast, Callable, Type, TypeVar, Generic, Any import contextlib, decimal, statistics, time, ctypes, array, os, struct, collections, functools try: import fcntl # windows misses that except ImportError: fcntl = None #type:ignore[assignment] from tinygrad.helpers import...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/__init__.py
tinygrad/runtime/support/__init__.py
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/usb.py
tinygrad/runtime/support/usb.py
import ctypes, struct, dataclasses, array, itertools from typing import Sequence from tinygrad.runtime.autogen import libusb from tinygrad.helpers import DEBUG, to_mv, round_up, OSX from tinygrad.runtime.support.hcq import MMIOInterface class USB3: def __init__(self, vendor:int, dev:int, ep_data_in:int, ep_stat_in:i...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/autogen.py
tinygrad/runtime/support/autogen.py
import ctypes, itertools, re, functools, os from tinygrad.helpers import unwrap from tinygrad.runtime.autogen import libclang as clang # use REGEN=1 to regenerate libclang bindings def unwrap_cursor(c: clang.CXCursor) -> clang.CXCursor: assert c != clang.clang_getNullCursor() return c def children(c: clang.CXCurs...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/compiler_amd.py
tinygrad/runtime/support/compiler_amd.py
import ctypes, hashlib, tempfile, subprocess, pathlib, shutil from tinygrad.helpers import system from tinygrad.runtime.autogen import comgr try: comgr.amd_comgr_get_version(ctypes.byref(major:=ctypes.c_uint64()), ctypes.byref(minor:=ctypes.c_uint64())) if major.value >= 3: # in comgr 3 the values of enums in h...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/c.py
tinygrad/runtime/support/c.py
import ctypes, functools, os, pathlib, re, sys, sysconfig from typing import TYPE_CHECKING from tinygrad.helpers import flatten, getenv, DEBUG, OSX, WIN from _ctypes import _SimpleCData def _do_ioctl(__idir, __base, __nr, __struct, __fd, *args, __payload=None, **kwargs): assert not WIN, "ioctl not supported" impor...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/amd.py
tinygrad/runtime/support/amd.py
import functools, re, urllib, tinygrad.runtime.autogen from collections import defaultdict from dataclasses import dataclass from tinygrad.helpers import getbits, fetch AMDGPU_URL = "https://gitlab.com/linux-kernel/linux-next/-/raw/cf6d949a409e09539477d32dbe7c954e4852e744/drivers/gpu/drm/amd" ROCM_URL = "https://raw.g...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/nv/nvdev.py
tinygrad/runtime/support/nv/nvdev.py
from __future__ import annotations import ctypes, time, functools, re, gzip, struct from tinygrad.helpers import getenv, DEBUG, fetch, getbits from tinygrad.runtime.support.memory import TLSFAllocator, MemoryManager, AddrSpace from tinygrad.runtime.support.nv.ip import NV_FLCN, NV_FLCN_COT, NV_GSP from tinygrad.runtime...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/nv/__init__.py
tinygrad/runtime/support/nv/__init__.py
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/nv/ip.py
tinygrad/runtime/support/nv/ip.py
from __future__ import annotations import ctypes, time, array, struct, itertools, dataclasses from typing import cast, Any from tinygrad.runtime.autogen import nv, nv_570 as nv_gpu, pci from tinygrad.helpers import to_mv, lo32, hi32, DEBUG, round_up, round_down, mv_address, fetch, wait_cond from tinygrad.runtime.suppor...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/am/amdev.py
tinygrad/runtime/support/am/amdev.py
from __future__ import annotations import ctypes, collections, dataclasses, functools, hashlib, array from tinygrad.helpers import mv_address, getenv, DEBUG, fetch, lo32, hi32 from tinygrad.runtime.autogen.am import am from tinygrad.runtime.support.hcq import MMIOInterface from tinygrad.runtime.support.amd import AMDRe...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/am/__init__.py
tinygrad/runtime/support/am/__init__.py
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/am/ip.py
tinygrad/runtime/support/am/ip.py
import ctypes, time, contextlib, functools from typing import Literal from tinygrad.helpers import to_mv, data64, lo32, hi32, DEBUG, wait_cond, pad_bytes from tinygrad.runtime.autogen.am import am from tinygrad.runtime.support.amd import import_soc from tinygrad.runtime.support.memory import AddrSpace class AM_IP: d...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/graph/cuda.py
tinygrad/runtime/graph/cuda.py
import ctypes from typing import Any, cast import tinygrad.runtime.autogen.cuda as cuda from tinygrad.helpers import init_c_var, dedup from tinygrad.device import Buffer, Device from tinygrad.runtime.ops_cuda import CUDADevice, check, encode_args, cu_time_execution from tinygrad.engine.realize import ExecItem, BufferXf...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/graph/metal.py
tinygrad/runtime/graph/metal.py
from typing import Any, cast import ctypes, re, decimal from tinygrad.dtype import dtypes from tinygrad.helpers import dedup, getenv, merge_dicts, PROFILE from tinygrad.device import Buffer, ProfileGraphEntry, ProfileGraphEvent from tinygrad.engine.realize import ExecItem, CompiledRunner from tinygrad.engine.jit import...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/graph/hcq.py
tinygrad/runtime/graph/hcq.py
import collections, time from typing import Any, cast from tinygrad.helpers import round_up, PROFILE, ALL2ALL, merge_dicts, getenv, dedup, suppress_finalizing from tinygrad.runtime.support.hcq import HCQCompiled, HCQAllocator, HCQSignal, HCQBuffer, HWQueue, HCQArgsState, BumpAllocator, MMIOInterface from tinygrad.devic...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/graph/__init__.py
tinygrad/runtime/graph/__init__.py
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/amd_gpu.py
tinygrad/runtime/autogen/amd_gpu.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG(Struct): pass class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG_HEADER_UNION(ctypes.Union): pass class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG_HEADER_UNION_0(Struct): pass rocr_A...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/avcodec.py
tinygrad/runtime/autogen/avcodec.py
# mypy: ignore-errors import ctypes from tinygrad.helpers import unwrap from tinygrad.runtime.support.c import Struct, CEnum, _IO, _IOW, _IOR, _IOWR enum_HEVCNALUnitType = CEnum(ctypes.c_uint32) HEVC_NAL_TRAIL_N = enum_HEVCNALUnitType.define('HEVC_NAL_TRAIL_N', 0) HEVC_NAL_TRAIL_R = enum_HEVCNALUnitType.define('HEVC_NA...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/cuda.py
tinygrad/runtime/autogen/cuda.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR dll = DLL('cuda', 'cuda') cuuint32_t = ctypes.c_uint32 cuuint64_t = ctypes.c_uint64 CUdeviceptr_v2 = ctypes.c_uint64 CUdeviceptr = ctypes.c_uint64 CUdevice_v1 = ctypes.c_int32 CUdevice = ctypes.c_int32 ...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/metal.py
tinygrad/runtime/autogen/metal.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import objc dll = DLL('metal', 'Metal') class MTLDispatchThreadgroupsIndirectArguments(Struct): pass uint32_t = ctypes.c_uint32 MTLDispatchThreadgroupsIndirectArguments._fi...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/rocprof.py
tinygrad/runtime/autogen/rocprof.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR dll = DLL('rocprof', ['rocprof-trace-decoder', p:='/usr/local/lib/rocprof-trace-decoder.so', p.replace('so','dylib')]) rocprofiler_thread_trace_decoder_status_t = CEnum(ctypes.c_uint32) ROCPROFILER_THRE...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/nv_570.py
tinygrad/runtime/autogen/nv_570.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR _anonenum0 = CEnum(ctypes.c_uint32) AES128_NONE = _anonenum0.define('AES128_NONE', 0) AES128_CTR = _anonenum0.define('AES128_CTR', 1) AES128_CBC = _anonenum0.define('AES128_CBC', 2) AES128_ECB = _anonen...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/kfd.py
tinygrad/runtime/autogen/kfd.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class struct_kfd_ioctl_get_version_args(Struct): pass __u32 = ctypes.c_uint32 struct_kfd_ioctl_get_version_args._fields_ = [ ('major_version', ctypes.c_uint32), ('minor_version', ctypes.c_uint32), ]...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/io_uring.py
tinygrad/runtime/autogen/io_uring.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class struct_io_uring_sq(Struct): pass class struct_io_uring_sqe(Struct): pass __u8 = ctypes.c_ubyte __u16 = ctypes.c_uint16 __s32 = ctypes.c_int32 class struct_io_uring_sqe_0(ctypes.Union): pass __u64 ...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/llvm.py
tinygrad/runtime/autogen/llvm.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR from tinygrad.helpers import WIN, OSX dll = DLL('llvm', 'C:\\Program Files\\LLVM\\bin\\LLVM-C.dll' if WIN else '/opt/homebrew/opt/llvm@20/lib/libLLVM.dylib' if OSX else ['LLVM', 'LLVM-21', 'LLVM-20', 'L...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/libusb.py
tinygrad/runtime/autogen/libusb.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR dll = DLL('libusb', 'usb-1.0') enum_libusb_class_code = CEnum(ctypes.c_uint32) LIBUSB_CLASS_PER_INTERFACE = enum_libusb_class_code.define('LIBUSB_CLASS_PER_INTERFACE', 0) LIBUSB_CLASS_AUDIO = enum_libus...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/nvjitlink.py
tinygrad/runtime/autogen/nvjitlink.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR import sysconfig dll = DLL('nvjitlink', 'nvJitLink', f'/usr/local/cuda/targets/{sysconfig.get_config_vars().get("MULTIARCH", "").rsplit("-", 1)[0]}/lib') nvJitLinkResult = CEnum(ctypes.c_uint32) NVJITLI...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/hsa.py
tinygrad/runtime/autogen/hsa.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR import os dll = DLL('hsa', [os.getenv('ROCM_PATH', '/opt/rocm')+'/lib/libhsa-runtime64.so', 'hsa-runtime64']) enum_SQ_RSRC_BUF_TYPE = CEnum(ctypes.c_uint32) SQ_RSRC_BUF = enum_SQ_RSRC_BUF_TYPE.define('S...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/hip.py
tinygrad/runtime/autogen/hip.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR import os dll = DLL('hip', os.getenv('ROCM_PATH', '/opt/rocm')+'/lib/libamdhip64.so') hipError_t = CEnum(ctypes.c_uint32) hipSuccess = hipError_t.define('hipSuccess', 0) hipErrorInvalidValue = hipError_...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/mesa.py
tinygrad/runtime/autogen/mesa.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR import gzip, base64 dll = DLL('mesa', ['tinymesa_cpu', 'tinymesa']) class struct_u_printf_info(Struct): pass u_printf_info = struct_u_printf_info uint32_t = ctypes.c_uint32 try: nir_debug = uint32_t.in_...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/libc.py
tinygrad/runtime/autogen/libc.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR dll = DLL('libc', 'c', use_errno=True) off_t = ctypes.c_int64 mode_t = ctypes.c_uint32 size_t = ctypes.c_uint64 __off_t = ctypes.c_int64 try: (mmap:=dll.mmap).restype, mmap.argtypes = ctypes.c_void_p, [...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/nvrtc.py
tinygrad/runtime/autogen/nvrtc.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR import sysconfig dll = DLL('nvrtc', 'nvrtc', f'/usr/local/cuda/targets/{sysconfig.get_config_vars().get("MULTIARCH", "").rsplit("-", 1)[0]}/lib') nvrtcResult = CEnum(ctypes.c_uint32) NVRTC_SUCCESS = nvr...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/pci.py
tinygrad/runtime/autogen/pci.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR PCI_CFG_SPACE_SIZE = 256 PCI_CFG_SPACE_EXP_SIZE = 4096 PCI_STD_HEADER_SIZEOF = 64 PCI_STD_NUM_BARS = 6 PCI_VENDOR_ID = 0x00 PCI_DEVICE_ID = 0x02 PCI_COMMAND = 0x04 PCI_COMMAND_IO = 0x1 PCI_COMMAND_MEMOR...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/comgr.py
tinygrad/runtime/autogen/comgr.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR import os dll = DLL('comgr', [os.getenv('ROCM_PATH', '/opt/rocm')+'/lib/libamd_comgr.so', 'amd_comgr']) amd_comgr_status_s = CEnum(ctypes.c_uint32) AMD_COMGR_STATUS_SUCCESS = amd_comgr_status_s.define('...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/sqtt.py
tinygrad/runtime/autogen/sqtt.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class struct_sqtt_data_info(Struct): pass uint32_t = ctypes.c_uint32 class struct_sqtt_data_info_0(ctypes.Union): pass struct_sqtt_data_info_0._fields_ = [ ('gfx9_write_counter', uint32_t), ('gfx10_...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/opencl.py
tinygrad/runtime/autogen/opencl.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR dll = DLL('opencl', 'OpenCL') class struct__cl_platform_id(Struct): pass cl_platform_id = ctypes.POINTER(struct__cl_platform_id) class struct__cl_device_id(Struct): pass cl_device_id = ctypes.POINTER(st...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/nv.py
tinygrad/runtime/autogen/nv.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class MCTP_HEADER(Struct): pass NvU32 = ctypes.c_uint32 NvU8 = ctypes.c_ubyte NvU16 = ctypes.c_uint16 MCTP_HEADER._packed_ = True MCTP_HEADER._fields_ = [ ('constBlob', NvU32), ('msgType', NvU8), ...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/nv_580.py
tinygrad/runtime/autogen/nv_580.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR _anonenum0 = CEnum(ctypes.c_uint32) AES128_NONE = _anonenum0.define('AES128_NONE', 0) AES128_CTR = _anonenum0.define('AES128_CTR', 1) AES128_CBC = _anonenum0.define('AES128_CBC', 2) AES128_ECB = _anonen...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/qcom_dsp.py
tinygrad/runtime/autogen/qcom_dsp.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR ion_user_handle_t = ctypes.c_int32 enum_ion_heap_type = CEnum(ctypes.c_uint32) ION_HEAP_TYPE_SYSTEM = enum_ion_heap_type.define('ION_HEAP_TYPE_SYSTEM', 0) ION_HEAP_TYPE_SYSTEM_CONTIG = enum_ion_heap_typ...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/ib.py
tinygrad/runtime/autogen/ib.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR dll = DLL('ib', 'ibverbs', use_errno=True) class union_ibv_gid(ctypes.Union): pass uint8_t = ctypes.c_ubyte class union_ibv_gid_global(Struct): pass __be64 = ctypes.c_uint64 union_ibv_gid_global._fields...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/kgsl.py
tinygrad/runtime/autogen/kgsl.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR enum_kgsl_user_mem_type = CEnum(ctypes.c_uint32) KGSL_USER_MEM_TYPE_PMEM = enum_kgsl_user_mem_type.define('KGSL_USER_MEM_TYPE_PMEM', 0) KGSL_USER_MEM_TYPE_ASHMEM = enum_kgsl_user_mem_type.define('KGSL_U...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/__init__.py
tinygrad/runtime/autogen/__init__.py
import glob, importlib, pathlib, subprocess, tarfile from tinygrad.helpers import fetch, flatten, system, getenv root = (here:=pathlib.Path(__file__).parent).parents[2] nv_src = {"nv_570": "https://github.com/NVIDIA/open-gpu-kernel-modules/archive/81fe4fb417c8ac3b9bdcc1d56827d116743892a5.tar.gz", "nv_580": "...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/libclang.py
tinygrad/runtime/autogen/libclang.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR dll = DLL('libclang', 'clang-20') CXIndex = ctypes.c_void_p class struct_CXTargetInfoImpl(Struct): pass CXTargetInfo = ctypes.POINTER(struct_CXTargetInfoImpl) class struct_CXTranslationUnitImpl(Struct):...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/comgr_3.py
tinygrad/runtime/autogen/comgr_3.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR import os dll = DLL('comgr_3', [os.getenv('ROCM_PATH', '/opt/rocm')+'/lib/libamd_comgr.so', 'amd_comgr']) amd_comgr_status_s = CEnum(ctypes.c_uint32) AMD_COMGR_STATUS_SUCCESS = amd_comgr_status_s.define...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/webgpu.py
tinygrad/runtime/autogen/webgpu.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR from tinygrad.helpers import WIN, OSX import sysconfig, os dll = DLL('webgpu', os.path.join(sysconfig.get_paths()['purelib'], 'pydawn', 'lib', 'libwebgpu_dawn.dll') if WIN else 'webgpu_dawn') WGPUFlags ...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/vfio.py
tinygrad/runtime/autogen/vfio.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class struct_vfio_info_cap_header(Struct): pass __u16 = ctypes.c_uint16 __u32 = ctypes.c_uint32 struct_vfio_info_cap_header._fields_ = [ ('id', ctypes.c_uint16), ('version', ctypes.c_uint16), ('ne...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/am/smu_v13_0_0.py
tinygrad/runtime/autogen/am/smu_v13_0_0.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR FEATURE_PWR_DOMAIN_e = CEnum(ctypes.c_uint32) FEATURE_PWR_ALL = FEATURE_PWR_DOMAIN_e.define('FEATURE_PWR_ALL', 0) FEATURE_PWR_S5 = FEATURE_PWR_DOMAIN_e.define('FEATURE_PWR_S5', 1) FEATURE_PWR_BACO = FEA...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/am/smu_v13_0_6.py
tinygrad/runtime/autogen/am/smu_v13_0_6.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR PPSMC_Result = ctypes.c_uint32 PPSMC_MSG = ctypes.c_uint32 FEATURE_LIST_e = CEnum(ctypes.c_uint32) FEATURE_DATA_CALCULATION = FEATURE_LIST_e.define('FEATURE_DATA_CALCULATION', 0) FEATURE_DPM_CCLK = FEAT...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/am/pm4_nv.py
tinygrad/runtime/autogen/am/pm4_nv.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class union_PM4_MES_TYPE_3_HEADER(ctypes.Union): pass enum_mes_set_resources_queue_type_enum = CEnum(ctypes.c_uint32) queue_type__mes_set_resources__kernel_interface_queue_kiq = enum_mes_set_resources_q...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/am/sdma_4_0_0.py
tinygrad/runtime/autogen/am/sdma_4_0_0.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG(Struct): pass class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG_HEADER_UNION(ctypes.Union): pass class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG_HEADER_UNION_0(Struct): pass rocr_A...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/am/pm4_soc15.py
tinygrad/runtime/autogen/am/pm4_soc15.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class union_PM4_MES_TYPE_3_HEADER(ctypes.Union): pass enum_mes_set_resources_queue_type_enum = CEnum(ctypes.c_uint32) queue_type__mes_set_resources__kernel_interface_queue_kiq = enum_mes_set_resources_q...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/am/sdma_5_0_0.py
tinygrad/runtime/autogen/am/sdma_5_0_0.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG(Struct): pass class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG_HEADER_UNION(ctypes.Union): pass class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG_HEADER_UNION_0(Struct): pass rocr_A...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/am/__init__.py
tinygrad/runtime/autogen/am/__init__.py
from tinygrad.runtime.autogen import load, root am_src="https://github.com/ROCm/ROCK-Kernel-Driver/archive/ceb12c04e2b5b53ec0779362831f5ee40c4921e4.tar.gz" AMD="{}/drivers/gpu/drm/amd" inc = ["-include", "stdint.h"] def __getattr__(nm): match nm: case "am": return load("am/am", [], [root/f"extra/amdpci/headers/...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/am/am.py
tinygrad/runtime/autogen/am/am.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class struct_v11_gfx_mqd(Struct): pass struct_v11_gfx_mqd._fields_ = [ ('shadow_base_lo', ctypes.c_uint32), ('shadow_base_hi', ctypes.c_uint32), ('gds_bkup_base_lo', ctypes.c_uint32), ('gds_bkup...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/am/smu_v14_0_2.py
tinygrad/runtime/autogen/am/smu_v14_0_2.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class struct_SMU14_Firmware_Footer(Struct): pass uint32_t = ctypes.c_uint32 struct_SMU14_Firmware_Footer._packed_ = True struct_SMU14_Firmware_Footer._fields_ = [ ('Signature', uint32_t), ] SMU14_Firm...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/autogen/am/sdma_6_0_0.py
tinygrad/runtime/autogen/am/sdma_6_0_0.py
# mypy: ignore-errors import ctypes from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG(Struct): pass class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG_HEADER_UNION(ctypes.Union): pass class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG_HEADER_UNION_0(Struct): pass rocr_A...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/schedule/rangeify.py
tinygrad/schedule/rangeify.py
from dataclasses import dataclass, field import itertools from tinygrad.dtype import dtypes, PtrDType, ImageDType, AddrSpace from tinygrad.uop.ops import PatternMatcher, UPat, Ops, UOp, resolve, GroupOp, _substitute, KernelInfo from tinygrad.uop.ops import graph_rewrite, identity_element, sint, AxisType, BottomUpGate, ...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/schedule/multi.py
tinygrad/schedule/multi.py
from typing import cast import functools, itertools, operator from tinygrad.helpers import all_same, all_int, prod, DEBUG, RING, ALL2ALL, getenv from tinygrad.uop.ops import Ops, UOp, sint, PatternMatcher, UPat, GroupOp, graph_rewrite_map, graph_rewrite from tinygrad.device import Device # *** allreduce implementation...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/schedule/__init__.py
tinygrad/schedule/__init__.py
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/schedule/indexing.py
tinygrad/schedule/indexing.py
from typing import Iterator import functools, operator, itertools from dataclasses import dataclass, field from tinygrad.dtype import dtypes, AddrSpace from tinygrad.uop.ops import PatternMatcher, UPat, Ops, UOp, resolve, GroupOp, graph_rewrite, sint, AxisType, profile_matches from tinygrad.uop.ops import consumer_map_...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/mixin/__init__.py
tinygrad/mixin/__init__.py
from tinygrad.mixin.math import MathMixin from tinygrad.mixin.movement import MovementMixin class OpMixin(MathMixin, MovementMixin): pass
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/mixin/math.py
tinygrad/mixin/math.py
import math from typing import Self from tinygrad.uop import Ops from tinygrad.dtype import dtypes, ConstType class MathMixin: # required to implement def alu(self, op: Ops, *src: Self) -> Self: raise NotImplementedError def const_like(self, b: ConstType) -> Self: raise NotImplementedError # great f...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/mixin/movement.py
tinygrad/mixin/movement.py
# mixins add syntactic sugar to Tensor and UOp from typing import TypeAlias, TYPE_CHECKING, Self from tinygrad.uop import Ops from tinygrad.helpers import prod, argfix, flatten, dedup, make_tuple, ceildiv from tinygrad.uop.ops import resolve, smax if TYPE_CHECKING: from tinygrad.uop.ops import UOp sint: TypeAlias = ...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/nn/datasets.py
tinygrad/nn/datasets.py
from tinygrad.tensor import Tensor from tinygrad.nn.state import tar_extract def mnist(device=None, fashion=False): base_url = "http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/" if fashion else "https://storage.googleapis.com/cvdf-datasets/mnist/" def _mnist(file): return Tensor.from_url(base_url+file, ...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/nn/optim.py
tinygrad/nn/optim.py
# sorted in order of increasing complexity import itertools from tinygrad.helpers import dedup, flatten, getenv, unwrap, FUSE_OPTIM from tinygrad.tensor import Tensor from tinygrad.dtype import dtypes, least_upper_dtype, to_dtype class Optimizer: """ Base class for all optimizers. """ def __init__(self, params...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/nn/state.py
tinygrad/nn/state.py
import json, pathlib, zipfile, pickle, tarfile, struct, functools, io, zlib from collections import OrderedDict from typing import Any, Callable, BinaryIO, Iterable, cast from tinygrad.tensor import Tensor from tinygrad.dtype import dtypes from tinygrad.helpers import prod, argsort, DEBUG, Timing, CI, unwrap, GlobalCou...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/nn/__init__.py
tinygrad/nn/__init__.py
from __future__ import annotations import math from tinygrad.tensor import Tensor from tinygrad.dtype import dtypes from tinygrad.device import is_dtype_supported from tinygrad.helpers import prod, make_tuple, flatten from tinygrad.nn import optim, state, datasets # noqa: F401 class BatchNorm: """ Applies Batch N...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/nn/torch.py
tinygrad/nn/torch.py
# type: ignore import sys, pathlib sys.path.append(pathlib.Path(__file__).parent.parent.as_posix()) try: import extra.torch_backend.backend # noqa: F401 # pylint: disable=unused-import except ImportError as e: raise ImportError("torch frontend not in release\nTo fix, install tinygrad from a git checkout with pip insta...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/nn/onnx.py
tinygrad/nn/onnx.py
# pylint: disable=possibly-unused-variable from typing import Any, Sequence, cast, Literal, NamedTuple, Generator import dataclasses, functools, io, math, types, warnings, pathlib, sys, os, struct, enum from io import BufferedReader from tinygrad.nn.state import TensorIO from tinygrad.tensor import Tensor, _broadcast_s...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/engine/memory.py
tinygrad/engine/memory.py
from typing import cast from collections import defaultdict from tinygrad.engine.realize import ExecItem from tinygrad.device import Device, Buffer from tinygrad.helpers import NO_MEMORY_PLANNER, dedup, DEBUG, round_up from tinygrad.uop.ops import Ops from tinygrad.dtype import dtypes, ImageDType from tinygrad.runtime....
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/engine/schedule.py
tinygrad/engine/schedule.py
import time from typing import cast from collections import deque from tinygrad.uop.ops import UOp, Ops, buffers, UOpMetaClass, track_rewrites, PatternMatcher, UPat, graph_rewrite, graph_rewrite_map from tinygrad.uop.spec import type_verify, tensor_spec from tinygrad.device import Buffer, MultiBuffer from tinygrad.help...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/engine/jit.py
tinygrad/engine/jit.py
from typing import TypeVar, Generic, Callable, cast, Any import functools, collections from tinygrad.tensor import Tensor from tinygrad.helpers import flatten, merge_dicts, DEBUG, Context, BEAM, getenv, colored, JIT, JIT_BATCH_SIZE, dedup, partition, unwrap from tinygrad.device import Buffer, Compiled, Device, MultiBuf...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/engine/__init__.py
tinygrad/engine/__init__.py
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/engine/realize.py
tinygrad/engine/realize.py
from typing import cast, Callable import time, pprint, random, itertools, math from dataclasses import dataclass, replace, field from tinygrad.helpers import all_same, colored, DEBUG, GlobalCounters, ansilen, BEAM, NOOPT, all_int, CAPTURING, Metadata, TRACEMETA, TracingKey from tinygrad.helpers import DEVECTORIZE, time...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_tiny.py
test/test_tiny.py
# basic self-contained tests of the external functionality of tinygrad import unittest, random from tinygrad import Tensor, Context, Variable, TinyJit, dtypes, Device, nn from tinygrad.helpers import IMAGE, CI, getenv class TestTiny(unittest.TestCase): # *** basic functionality *** def test_const(self): cons...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_uops.py
test/test_uops.py
from typing import Optional, Any import unittest, math import numpy as np from tinygrad.tensor import Tensor, _to_np_dtype from tinygrad.helpers import CI, DEBUG, getenv, Timing, Context from tinygrad.dtype import dtypes, DType, AddrSpace from tinygrad.device import Buffer, Device from tinygrad.uop.ops import Ops, UOp,...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_custom_kernel.py
test/test_custom_kernel.py
import unittest from tinygrad import Tensor, UOp from tinygrad.dtype import AddrSpace from tinygrad.uop.ops import KernelInfo, AxisType # **** kernels **** def custom_arange_kernel(C:UOp) -> UOp: i = UOp.range(C.size, 0) return C[i].store(i.cast(C.dtype.base)).end(i).sink(arg=KernelInfo(name=f"custom_arange_{C.si...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_interop.py
test/test_interop.py
#!/usr/bin/env python import unittest import torch import numpy as np from tinygrad.helpers import getenv, CI from tinygrad.tensor import Tensor from tinygrad.device import Device from tinygrad.dtype import _from_torch_dtype, _to_torch_dtype MOCKGPU = getenv("MOCKGPU") @unittest.skipIf(Device.DEFAULT not in ["METAL"...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_transcendental.py
test/test_transcendental.py
import unittest from tinygrad import Tensor, Device, dtypes from tinygrad.tensor import _to_np_dtype from tinygrad.helpers import Context, getenv, CI, OSX from test.test_schedule import check_schedule from test.test_dtype_alu import ht, dtypes_float from tinygrad.device import is_dtype_supported import numpy as np impo...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_tensor.py
test/test_tensor.py
import numpy as np import torch import unittest, copy, mmap, random, math, array from tinygrad import Tensor, Device, dtypes from tinygrad.tensor import _METADATA from tinygrad.helpers import Context, getenv, temp, mv_address from extra.gradcheck import numerical_jacobian, jacobian, gradcheck from hypothesis import giv...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_opt_gemm.py
test/test_opt_gemm.py
import numpy as np import unittest from tinygrad import Tensor, Device from tinygrad.helpers import get_single_element from tinygrad.codegen.opt import Opt, OptOps from tinygrad.engine.realize import CompiledRunner, get_program from tinygrad.engine.schedule import ExecItem class TestOptGemm(unittest.TestCase): @clas...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_tensor_variable.py
test/test_tensor_variable.py
import unittest import numpy as np from tinygrad import Tensor, Variable class TestTensorVariable(unittest.TestCase): def test_add_tvar(self): vv = Variable("a", 0, 10).bind(1) ret = (Tensor(vv) + 3).item() assert ret == 4 def test_inner_tvar_node(self): vv = Variable("w", 0, 10).bind(2) ret =...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_multitensor.py
test/test_multitensor.py
import unittest, functools, random from tinygrad import Tensor, Device, nn, GlobalCounters, TinyJit, dtypes, Variable from tinygrad.device import is_dtype_supported from tinygrad.uop.ops import Ops, UOp from tinygrad.helpers import getenv, prod, Context from tinygrad.nn.state import get_parameters, get_state_dict from ...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
true
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_dtype_alu.py
test/test_dtype_alu.py
import unittest, operator, math from tinygrad import Tensor, dtypes, Device from tinygrad.dtype import DType, truncate from tinygrad.helpers import CI, getenv from tinygrad.tensor import _to_np_dtype from tinygrad.device import is_dtype_supported from tinygrad.runtime.ops_python import from_storage_scalar from tinygrad...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_memory_planner.py
test/test_memory_planner.py
import unittest from tinygrad import dtypes, Device from tinygrad.device import Buffer from tinygrad.engine.memory import _internal_memory_planner global_map = {} def b(i, base=None, offset=0, pin=False, size=16): global global_map if i in global_map: return global_map[i] global_map[i] = Buffer(Device.DEFAULT, s...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_zero_copy.py
test/test_zero_copy.py
import unittest from tinygrad import Tensor, Device import time def time_tensor_numpy(out:Tensor): times = [] for _ in range(5): st = time.perf_counter() out.uop.base.realized.as_buffer(allow_zero_copy=True) et = time.perf_counter() - st times.append(et) return min(times) N = 4096 class TestZero...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_assign.py
test/test_assign.py
#!/usr/bin/env python import unittest import numpy as np from tinygrad import dtypes, Tensor, TinyJit, GlobalCounters, Variable from tinygrad.device import is_dtype_supported from tinygrad.helpers import temp, CI, CPU_LVP N = 200 # has to be bigger than the cache to fail class TestAssign(unittest.TestCase): def te...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_const_folding.py
test/test_const_folding.py
import unittest, itertools, math from tinygrad import Tensor, Device, dtypes, Context from tinygrad.dtype import DType, ConstType from tinygrad.uop.ops import Ops, UOp from tinygrad.codegen import full_rewrite_to_sink from tinygrad.device import is_dtype_supported import numpy as np from test.helpers import not_support...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_optim.py
test/test_optim.py
import numpy as np import torch import unittest from tinygrad import Tensor, Device, dtypes from tinygrad.nn.optim import Adam, SGD, AdamW, Muon, LAMB from tinygrad.device import is_dtype_supported from test.helpers import needs_second_gpu, slow np.random.seed(1337) x_init = np.random.randn(1,4).astype(np.float32) W_i...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_quantize_onnx.py
test/test_quantize_onnx.py
# ruff: noqa: E501 import numpy as np import unittest from dataclasses import replace from tinygrad import Tensor, Context, Device, dtypes from tinygrad.uop.ops import Ops from tinygrad.codegen.opt import Opt, OptOps from tinygrad.engine.realize import CompiledRunner, get_program from tinygrad.engine.schedule import Ex...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_subbuffer.py
test/test_subbuffer.py
import unittest from tinygrad import Device, dtypes, Tensor from tinygrad.device import Buffer from tinygrad.helpers import Context from test.helpers import REAL_DEV, needs_second_gpu @unittest.skipUnless(hasattr(Device[Device.DEFAULT].allocator, "_offset"), "subbuffer not supported") class TestSubBuffer(unittest.Test...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_rangeify.py
test/test_rangeify.py
import unittest from tinygrad import Tensor, nn, Device from tinygrad.helpers import Context, GlobalCounters, getenv, PCONTIG, DEBUG from tinygrad.uop.ops import graph_rewrite, PatternMatcher, UPat, Ops from tinygrad.codegen.opt import OptOps, Opt from tinygrad.renderer.ptx import PTXRenderer from tinygrad.renderer.nir...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_stunning.py
test/test_stunning.py
import unittest from tinygrad import nn, Tensor, Variable, Context, Device from tinygrad.helpers import trange class Model: def __init__(self): self.layer = nn.Linear(28*28, 10) def __call__(self, x:Tensor) -> Tensor: return self.layer(x.flatten(1)) class TestStunning(unittest.TestCase): def test_indexing_varia...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_outerworld_range.py
test/test_outerworld_range.py
import unittest from tinygrad import Tensor, nn, Variable, UOp # outerworld range should support three things # 1. full optimizer steps (test_model_bound_range) # 2. gradient accumulation (you want to end the range before running the optimizer) # 3. stacked linear layers class Model: def __init__(self): self.w = nn...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false
tinygrad/tinygrad
https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/test/test_dtype.py
test/test_dtype.py
import unittest, math import numpy as np import torch from typing import Any, List from tinygrad.device import is_dtype_supported from tinygrad.helpers import getenv, DEBUG, CI from tinygrad.dtype import DType, DTYPES_DICT, least_upper_dtype, fp8_to_float, float_to_fp8, _to_np_dtype, _to_torch_dtype, truncate from tiny...
python
MIT
bf356ae99621f42ad218b902ae7afdcb1f4a2f03
2026-01-04T14:43:17.197982Z
false