repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
tinygrad
tinygrad/runtime/autogen/amdgpu_drm.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c drm_handle_t: TypeAlias = ctypes.c_uint32 drm_context_t: TypeAlias = ctypes.c_uint32 drm_dra...
1,660
72,478
tinygrad
tinygrad/runtime/autogen/amd_gpu.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG(c.Struct): SIZE = 28 HEADER_UNION: roc...
12,924
474,629
tinygrad
tinygrad/runtime/autogen/comgr_3.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c import os dll = c.DLL('comgr_3', [os.getenv('ROCM_PATH', '/opt/rocm')+'/lib/libamd_comgr.so'...
205
23,093
tinygrad
tinygrad/runtime/autogen/webgpu.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c from tinygrad.helpers import WIN, OSX import sysconfig, os dll = c.DLL('webgpu', os.path.joi...
2,609
248,826
tinygrad
tinygrad/runtime/autogen/iokit.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c dll = c.DLL('iokit', 'IOKit') class struct_IONotificationPort(c.Struct): pass IONotification...
276
23,437
tinygrad
tinygrad/runtime/autogen/kgsl.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c enum_kgsl_user_mem_type: dict[int, str] = {(KGSL_USER_MEM_TYPE_PMEM:=0): 'KGSL_USER_MEM_TYPE...
787
34,357
tinygrad
tinygrad/runtime/autogen/hip.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c import os dll = c.DLL('hip', os.getenv('ROCM_PATH', '/opt/rocm')+'/lib/libamdhip64.so') hipE...
2,241
208,168
tinygrad
tinygrad/runtime/autogen/libclang.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c from tinygrad.helpers import WIN, OSX dll = c.DLL('libclang', 'C:\\Program Files\\LLVM\\bin\...
1,019
115,076
tinygrad
tinygrad/runtime/autogen/metal.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c from tinygrad.runtime.support import objc dll = c.DLL('metal', 'Metal') @c.record class MTLD...
1,465
108,596
tinygrad
tinygrad/runtime/autogen/amdgpu_kd.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c uint8_t: TypeAlias = ctypes.c_ubyte _anonenum0: dict[int, str] = {(FLOAT_ROUND_MODE_NEAR_EVE...
38
25,157
tinygrad
tinygrad/runtime/autogen/nvjitlink.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c import sysconfig dll = c.DLL('nvjitlink', 'nvJitLink', [f'/{pre}/cuda/targets/{tgt}/lib' for...
43
4,036
tinygrad
tinygrad/runtime/autogen/hsa.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c import os enum_SQ_RSRC_BUF_TYPE: dict[int, str] = {(SQ_RSRC_BUF:=0): 'SQ_RSRC_BUF', (SQ_RSRC...
1,108
140,382
tinygrad
tinygrad/runtime/autogen/__init__.py
.py
import glob, importlib, os, pathlib, subprocess 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": "https...
187
18,133
tinygrad
tinygrad/runtime/autogen/nv.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class MCTP_HEADER(c.Struct): SIZE = 7 constBlob: int msgType: int vendorId...
4,929
319,545
tinygrad
tinygrad/runtime/autogen/sqtt.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class struct_sqtt_data_info(c.Struct): SIZE = 12 cur_offset: int trace_statu...
524
38,391
tinygrad
tinygrad/runtime/autogen/corefoundation.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c dll = c.DLL('corefoundation', 'CoreFoundation') CFStringEncoding: TypeAlias = ctypes.c_uint3...
313
26,037
tinygrad
tinygrad/runtime/autogen/libusb.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c dll = c.DLL('libusb', 'usb-1.0') enum_libusb_class_code: dict[int, str] = {(LIBUSB_CLASS_PER...
490
41,559
tinygrad
tinygrad/runtime/autogen/opencl.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c dll = c.DLL('opencl', 'OpenCL') class struct__cl_platform_id(c.Struct): pass cl_platform_id:...
812
53,387
tinygrad
tinygrad/runtime/autogen/comgr.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c import os dll = c.DLL('comgr', [os.getenv('ROCM_PATH', '/opt/rocm')+'/lib/libamd_comgr.so', ...
205
23,227
tinygrad
tinygrad/runtime/autogen/io_uring.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class struct_io_uring_sq(c.Struct): SIZE = 104 khead: c.POINTER[ctypes.c_uint3...
904
39,077
tinygrad
tinygrad/runtime/autogen/pci.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c PCI_CFG_SPACE_SIZE = 256 PCI_CFG_SPACE_EXP_SIZE = 4096 PCI_STD_HEADER_SIZEOF = 64 PCI_STD_NU...
1,043
31,995
tinygrad
tinygrad/runtime/autogen/qcom_dsp.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c ion_user_handle_t: TypeAlias = ctypes.c_int32 enum_ion_heap_type: dict[int, str] = {(ION_HEA...
559
27,189
tinygrad
tinygrad/runtime/autogen/kfd.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class struct_kfd_ioctl_get_version_args(c.Struct): SIZE = 8 major_version: int...
819
50,503
tinygrad
tinygrad/runtime/autogen/libc.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c dll = c.DLL('libc', 'c', use_errno=True) off_t: TypeAlias = ctypes.c_int64 mode_t: TypeAlias...
4,458
148,575
tinygrad
tinygrad/runtime/autogen/ggml_common.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c ggml_half: TypeAlias = ctypes.c_uint16 ggml_half2: TypeAlias = ctypes.c_uint32 @c.record cla...
219
92,744
tinygrad
tinygrad/runtime/autogen/cuda.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c from tinygrad.helpers import WIN dll = c.DLL('cuda', 'nvcuda' if WIN else 'cuda') cuuint32_t...
2,156
210,276
tinygrad
tinygrad/runtime/autogen/vfio.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class struct_vfio_info_cap_header(c.Struct): SIZE = 8 id: int version: int ...
587
26,409
tinygrad
tinygrad/runtime/autogen/llvm.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c from tinygrad.helpers import WIN, OSX dll = c.DLL('llvm', 'C:\\Program Files\\LLVM\\bin\\LLV...
3,191
265,275
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_fbif_v4.py
.py
ga102 = { 'NV_PFALCON_FBIF_TRANSCFG': (0x600, lambda i: (0x00000000+(i)*4), {'target': (0, 1), 'mem_type': (2, 2)}), 'NV_PFALCON_FBIF_TRANSCFG__SIZE_1': 8, 'NV_PFALCON_FBIF_TRANSCFG_TARGET_COHERENT_SYSMEM': 0x00000001, 'NV_PFALCON_FBIF_TRANSCFG_MEM_TYPE_PHYSICAL': 0x00000001, 'NV_PFALCON_FBIF_CTL': (0x600, 0x...
8
424
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_gsp.py
.py
ga102 = { 'NV_PGSP_FALCON_MAILBOX0': (0x0, 0x110040, {'data': (0, 31)}), 'NV_PGSP_FALCON_MAILBOX1': (0x0, 0x110044, {'data': (0, 31)}), 'NV_PGSP_FALCON_ENGINE': (0x0, 0x1103c0, {'reset': (0, 0)}), 'NV_PGSP_FALCON_ENGINE_RESET_TRUE': 0x00000001, 'NV_PGSP_FALCON_ENGINE_RESET_FALSE': 0x00000000, 'NV_PGSP_MAILB...
10
453
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_mmu.py
.py
tu102 = { 'NV_MMU_PDE': (None, None, {'aperture_big': ((0*32+0), (0*32+1)), 'size': ((0*32+2), (0*32+3)), 'address_big_sys': ((0*32+4), (0*32+31)), 'address_big_vid': ((0*32+4), (0*32+31-3)), 'address_big_vid_peer': ((0*32+32-3), (0*32+31)), 'aperture_small': ((1*32+0), (1*32+1)), 'vol_small': ((1*32+2), (1*32+2)), '...
895
50,968
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_sec_pri.py
.py
ga102 = { 'NV_PSEC_FALCON_ENGINE': (0x0, 0x008403c0, {'reset': (0, 0)}), 'NV_PSEC_FALCON_ENGINE_RESET_TRUE': 0x00000001, 'NV_PSEC_FALCON_ENGINE_RESET_FALSE': 0x00000000, 'NV_PSEC_MAILBOX__SIZE_1': 4, 'NV_PSEC_MAILBOX_DATA_INIT': 0x00000000, }
7
252
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_riscv_pri.py
.py
ga102 = { 'NV_FALCON2_GSP_BASE': 0x00111000, 'NV_PRISCV_RISCV_IRQMASK': (0x1000, 0x00000528, {}), 'NV_PRISCV_RISCV_IRQDEST': (0x1000, 0x0000052c, {}), 'NV_PRISCV_RISCV_CPUCTL': (0x1000, 0x00000388, {'active_stat': (7, 7), 'halted': (4, 4)}), 'NV_PRISCV_RISCV_CPUCTL_ACTIVE_STAT_ACTIVE': 0x00000001, 'NV_PRISC...
14
762
tinygrad
tinygrad/runtime/autogen/nv_regs/nv_ref.py
.py
regs = { 'NV_CONFIG_PCI_NV_0': 0x00000000, 'NV_CONFIG_PCI_NV_0_VENDOR_ID_NVIDIA': 0x000010DE, 'NV_CONFIG_PCI_NV_1': 0x00000004, 'NV_CONFIG_PCI_NV_1_IO_SPACE_DISABLED': 0x00000000, 'NV_CONFIG_PCI_NV_1_IO_SPACE_ENABLED': 0x00000001, 'NV_CONFIG_PCI_NV_1_MEMORY_SPACE_DISABLED': 0x00000000, 'NV_CONFIG_PCI_NV_1...
75
3,853
tinygrad
tinygrad/runtime/autogen/nv_regs/__init__.py
.py
import re, pathlib from tinygrad.runtime.autogen import load, nv_src swref_path, hwref_path = "{}/src/common/inc/swref/published", "{}/kernel-open/nvidia-uvm/hwref" swref = { "dev_therm": ["gb202"], "dev_vm": ["tu102", "gh100"], **{k:["tu102"] for k in ["dev_fb", "dev_bus"]}, **{k:["ga102"] for k in ["dev_gc6_isla...
44
3,108
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_therm.py
.py
gb202 = { 'NV_THERM_I2CS_SCRATCH': (0x0, 0x00ad00bc, {'data': (0, 31)}), 'NV_THERM_I2CS_SCRATCH_DATA_INIT': 0x00000000, }
4
125
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_bus.py
.py
tu102 = { 'NV_PBUS_VBIOS_SCRATCH': (0x0, lambda i: (0x00001400+(i)*4), {}), 'NV_PBUS_SW_SCRATCH': (0x0, lambda i: (0x00001400+(i)*4), {}), 'NV_PBUS_IFR_FMT_FIXED0': (0x0, 0x00000000, {'signature': (0, 31)}), 'NV_PBUS_IFR_FMT_FIXED0_SIGNATURE_VALUE': 0x4947564E, 'NV_PBUS_IFR_FMT_FIXED1': (0x0, 0x00000004, {'ve...
36
2,180
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_gc6_island.py
.py
ga102 = { 'NV_PGC6_AON_SECURE_SCRATCH_GROUP_05_PRIV_LEVEL_MASK': (0x0, 0x00118128, {'read_protection': (0, 3), 'read_protection_level0': (0, 0)}), 'NV_PGC6_AON_SECURE_SCRATCH_GROUP_05_PRIV_LEVEL_MASK_READ_PROTECTION_LEVEL0_ENABLE': 0x00000001, 'NV_PGC6_AON_SECURE_SCRATCH_GROUP_05_PRIV_LEVEL_MASK_READ_PROTECTION_L...
14
1,159
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_fb.py
.py
tu102 = { 'NV_PFB_NISO_ACCESS_COUNTER_NOTIFY_BUFFER_INFO': (0x0, 0x00100A18, {'full': (0, 0)}), 'NV_PFB_NISO_ACCESS_COUNTER_NOTIFY_BUFFER_INFO_FULL_FALSE': 0x0, 'NV_PFB_NISO_ACCESS_COUNTER_NOTIFY_BUFFER_INFO_FULL_TRUE': 0x1, 'NV_PFB_PRI_MMU_INT_VECTOR_FAULT_NOTIFY_REPLAYABLE': (0x0, 64, {}), 'NV_PFB_PRI_MMU_I...
27
1,907
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_fsp_pri.py
.py
gh100 = { 'NV_PFSP_EMEMC': (0x0, lambda i: (0x008F2ac0+(i)*8), {'offs': (2, 7), 'blk': (8, 15), 'aincw': (24, 24), 'aincr': (25, 25)}), 'NV_PFSP_EMEMC__SIZE_1': 8, 'NV_PFSP_EMEMC_OFFS_INIT': 0x00000000, 'NV_PFSP_EMEMC_BLK_INIT': 0x00000000, 'NV_PFSP_EMEMC_AINCW_INIT': 0x00000000, 'NV_PFSP_EMEMC_AINCW_TRUE':...
33
1,754
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_falcon_second_pri.py
.py
ga102 = { 'NV_FALCON2_GSP_BASE': 0x00111000, 'NV_FALCON2_NVDEC0_BASE': 0x00849c00, 'NV_FALCON2_SEC_BASE': 0x00841000, 'NV_PFALCON2_FALCON_MOD_SEL': (0x1000, 0x00000180, {'algo': (0, 7)}), 'NV_PFALCON2_FALCON_MOD_SEL_ALGO_RSA3K': 0x00000001, 'NV_PFALCON2_FALCON_BROM_CURR_UCODE_ID': (0x1000, 0x00000198, {'val...
10
481
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_falcon_v4.py
.py
ga102 = { 'NV_PFALCON_FALCON_IRQSCLR': (0x0, 0x00000004, {'halt': (4, 4), 'swgen0': (6, 6)}), 'NV_PFALCON_FALCON_IRQSCLR_HALT_SET': 0x00000001, 'NV_PFALCON_FALCON_IRQSCLR_SWGEN0_SET': 0x00000001, 'NV_PFALCON_FALCON_IRQSTAT': (0x0, 0x00000008, {'halt': (4, 4), 'swgen0': (6, 6)}), 'NV_PFALCON_FALCON_IRQSTAT_HAL...
113
7,449
tinygrad
tinygrad/runtime/autogen/nv_regs/dev_vm.py
.py
tu102 = { 'NV_VIRTUAL_FUNCTION_PRIV_L2_SYSMEM_INVALIDATE': (0xB80000, 0x00000F00, {}), 'NV_VIRTUAL_FUNCTION_PRIV_L2_PEERMEM_INVALIDATE': (0xB80000, 0x00000F04, {}), 'NV_VIRTUAL_FUNCTION_PRIV_CPU_INTR_TOP': (0xB80000, lambda i: (0x1600+(i)*4), {'value': (0, 31), 'en_set_value': (0, 31), 'en_clear_value': (0, 31)})...
246
20,790
tinygrad
tinygrad/runtime/autogen/am/pm4_nv.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c class union_PM4_MES_TYPE_3_HEADER(c.Struct): pass enum_mes_set_resources_queue_type_enum: di...
487
34,189
tinygrad
tinygrad/runtime/autogen/am/vega_offsets.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class struct_IP_BASE_INSTANCE(c.Struct): SIZE = 24 segment: c.Array[ctypes.c_u...
774
20,430
tinygrad
tinygrad/runtime/autogen/am/sdma_6_0_0.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG(c.Struct): SIZE = 28 HEADER_UNION: roc...
3,882
313,833
tinygrad
tinygrad/runtime/autogen/am/am.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class struct_v11_gfx_mqd(c.Struct): SIZE = 2048 shadow_base_lo: int shadow_b...
4,468
292,361
tinygrad
tinygrad/runtime/autogen/am/fw.py
.py
hashes = { 'psp_13_0_0_sos.bin': 'b5592f46885585b935e013f46c949db8ff2f15c0b346caf70e7fcd2776623d13', 'psp_13_0_10_sos.bin': '0bcaaad9cd8578d3841ae69155a6bd4fc3ceae8f4fb5a6ba4f576e7ace94d1d9', 'psp_13_0_12_sos.bin': '89da90bf4286b38678b1fd175c78462a426afa3d258d15872cd14072d7098b9b', 'psp_13_0_14_sos.bin': 'a4f0d...
106
9,421
tinygrad
tinygrad/runtime/autogen/am/smu_13_0_12.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c PPSMC_Result: TypeAlias = ctypes.c_uint32 PPSMC_MSG: TypeAlias = ctypes.c_uint32 FEATURE_LIS...
532
40,067
tinygrad
tinygrad/runtime/autogen/am/soc_9.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c enum_MTYPE: dict[int, str] = {(MTYPE_NC:=0): 'MTYPE_NC', (MTYPE_WC:=1): 'MTYPE_WC', (MTYPE_R...
17
4,294
tinygrad
tinygrad/runtime/autogen/am/__init__.py
.py
import pathlib, hashlib, re, itertools from tinygrad.runtime.autogen import load, root __all__ = ["am", "pm4_soc15", "pm4_nv", "sdma_4_0_0", "sdma_5_0_0", "sdma_6_0_0", "smu_13_0_0", "smu_13_0_6", "smu_13_0_12", "smu_14_0_2", "fw", "navi_offsets", "vega_offsets", "regs", "soc_9", "soc_11", "soc_12", "pmc"] ...
103
8,634
tinygrad
tinygrad/runtime/autogen/am/pmc.py
.py
counters = { 'CPC_CPC_STAT_BUSY': { 'gfx90a': ('CPC', 25), 'gfx908': ('CPC', 25), 'gfx940': ('CPC', 25), 'gfx941': ('CPC', 25), 'gfx942': ('CPC', 25), 'gfx950': ('CPC', 25), }, 'CPC_CPC_STAT_IDLE': { 'gfx90a': ('CPC', 26), 'gfx908': ('CPC', 26), 'gfx940': ('CPC', 26), 'gfx9...
3,350
79,355
tinygrad
tinygrad/runtime/autogen/am/soc_12.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c enum_MTYPE: dict[int, str] = {(MTYPE_C_RW_US:=0): 'MTYPE_C_RW_US', (MTYPE_RESERVED_1:=1): 'M...
25
5,680
tinygrad
tinygrad/runtime/autogen/am/soc_11.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c enum_MTYPE: dict[int, str] = {(MTYPE_C_RW_US:=0): 'MTYPE_C_RW_US', (MTYPE_RESERVED_1:=1): 'M...
45
10,493
tinygrad
tinygrad/runtime/autogen/am/pm4_soc15.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c class union_PM4_MES_TYPE_3_HEADER(c.Struct): pass enum_mes_set_resources_queue_type_enum: di...
412
30,375
tinygrad
tinygrad/runtime/autogen/am/smu_13_0_0.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c FEATURE_PWR_DOMAIN_e: dict[int, str] = {(FEATURE_PWR_ALL:=0): 'FEATURE_PWR_ALL', (FEATURE_PW...
1,225
85,556
tinygrad
tinygrad/runtime/autogen/am/smu_14_0_2.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class struct_SMU14_Firmware_Footer(c.Struct): SIZE = 4 Signature: int uint32_t...
1,563
106,527
tinygrad
tinygrad/runtime/autogen/am/smu_13_0_6.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c PPSMC_Result: TypeAlias = ctypes.c_uint32 PPSMC_MSG: TypeAlias = ctypes.c_uint32 FEATURE_LIS...
617
45,725
tinygrad
tinygrad/runtime/autogen/am/sdma_5_0_0.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG(c.Struct): SIZE = 28 HEADER_UNION: roc...
3,386
270,344
tinygrad
tinygrad/runtime/autogen/am/sdma_4_0_0.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class rocr_AMD_SDMA_PKT_COPY_LINEAR_TAG(c.Struct): SIZE = 28 HEADER_UNION: roc...
2,434
189,857
tinygrad
tinygrad/runtime/autogen/am/navi_offsets.py
.py
# mypy: disable-error-code="empty-body" from __future__ import annotations import ctypes from typing import Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c @c.record class struct_IP_BASE_INSTANCE(c.Struct): SIZE = 20 segment: c.Array[ctypes.c_u...
823
22,286
tinygrad
tinygrad/runtime/support/compiler_mesa.py
.py
import base64, ctypes, pathlib, tempfile, hashlib from tinygrad.device import Compiler from tinygrad.helpers import cpu_objdump, system, data64 from tinygrad.runtime.autogen import mesa, llvm, libc from tinygrad.runtime.support.compiler_llvm import CPULLVMCompiler, expect, cerr # NB: compilers assume mesa's glsl type ...
134
7,807
tinygrad
tinygrad/runtime/support/compiler_amd.py
.py
import ctypes, hashlib, tempfile, subprocess, pathlib from tinygrad.helpers import amdgpu_disassemble, getenv 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 o...
110
6,829
tinygrad
tinygrad/runtime/support/hcq2.py
.py
from __future__ import annotations from typing import cast, Callable, TypeVar, Generic, Any, Sequence, Iterable import struct, functools, time, collections, itertools, decimal, statistics from dataclasses import replace, dataclass from tinygrad.helpers import DEV, getenv, select_first_inited, select_by_name, suppress_f...
650
37,242
tinygrad
tinygrad/runtime/support/autogen.py
.py
import ctypes, itertools, re, functools, os, keyword from tinygrad.helpers import unwrap import tinygrad.runtime.autogen.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.CX...
290
19,364
tinygrad
tinygrad/runtime/support/c.py
.py
from __future__ import annotations import ctypes, functools, os, pathlib, re, sys, sysconfig from tinygrad.helpers import ceildiv, getenv, DEBUG, OSX, WIN from typing import TYPE_CHECKING, get_args, Generic, ParamSpec, TypeVar def _do_ioctl(__idir, __base, __nr, __struct, __fd, *args, __payload=None, **kwargs): asse...
142
7,397
tinygrad
tinygrad/runtime/support/elf.py
.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|libc.Elf32_Shdr; content:bytes # noqa: E702 def link_sym(sym:str, libs:list[str]) ...
83
5,263
tinygrad
tinygrad/runtime/support/system.py
.py
from __future__ import annotations import os, mmap, array, functools, ctypes, ctypes.util, select, contextlib, dataclasses, sys, itertools, struct, socket import subprocess, time, enum, atexit from tinygrad.helpers import round_up, getenv, OSX, temp, ceildiv, unwrap, fetch, system, _ensure_downloads_dir, DEBUG, flatten...
446
28,616
tinygrad
tinygrad/runtime/support/objc.py
.py
import ctypes, ctypes.util, functools, sys from typing import TYPE_CHECKING, Any if TYPE_CHECKING: id_ = ctypes.c_void_p else: class id_(ctypes.c_void_p): _is_finalizing = sys.is_finalizing # FIXME: why is this needed retain: bool = False # This prevents ctypes from converting response to plain int, and...
74
3,226
tinygrad
tinygrad/runtime/support/compiler_llvm.py
.py
import ctypes from tinygrad.device import Compiler, CompileError from tinygrad.helpers import getenv, capstone_flatdump, amdgpu_disassemble, unwrap, DEBUG from tinygrad.runtime.support.elf import jit_loader from tinygrad.runtime.autogen import llvm def cerr(): return ctypes.pointer(ctypes.pointer(ctypes.c_char())) de...
95
5,357
tinygrad
tinygrad/runtime/support/compiler_qcom.py
.py
import ctypes, struct, platform, pathlib, shutil, subprocess, sys, tarfile, tempfile from tinygrad.device import Compiler from tinygrad.helpers import DEBUG, system, fetch, unwrap from tinygrad.runtime.support.compiler_mesa import disas_adreno # see https://github.com/sirhcm/tinydreno from tinygrad.runtime.autogen impo...
60
3,838
tinygrad
tinygrad/runtime/support/hcq.py
.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, itertools from dataclasses import replace try: import fcntl # windows misses that except ImportError: fcntl = None #type:igno...
645
32,464
tinygrad
tinygrad/runtime/support/compiler_cpu.py
.py
import subprocess from tinygrad.device import Compiler from tinygrad.helpers import getenv, capstone_flatdump from tinygrad.runtime.support.elf import jit_loader class ClangCompiler(Compiler): def __init__(self, arch:list[str], cachekey="compile_clang_jit"): assert len(arch) >= 2, f"invalid arch string: {','.joi...
34
2,063
tinygrad
tinygrad/runtime/support/amd.py
.py
import functools, tinygrad.runtime.autogen.am from dataclasses import dataclass from tinygrad.helpers import getbits @dataclass class AMDReg: name:str; offset:int; segment:int; fields:dict[str, tuple[int, int]]; bases:dict[int, tuple[int, ...]] # noqa: E702 def __post_init__(self): self.addr:dict[int, int] = { ins...
48
2,889
tinygrad
tinygrad/runtime/support/usb.py
.py
import ctypes, struct, time, functools, itertools from tinygrad.runtime.autogen import libusb from tinygrad.helpers import DEBUG, DEV, to_mv, round_up, ceildiv from tinygrad.runtime.support.hcq import MMIOInterface from tinygrad.runtime.support import c def alloc_cbuffer(sz:int) -> tuple[ctypes.Array, memoryview]: ret...
204
11,136
tinygrad
tinygrad/runtime/support/compiler_cuda.py
.py
import hashlib, tempfile, ctypes, re, pathlib from tinygrad.helpers import to_char_p_p, colored, getenv, system from tinygrad.runtime.support.c import init_c_var from tinygrad.runtime.autogen import nvrtc, nvjitlink as jitlink from tinygrad.device import Compiler, CompileError CUDA_PATH = getenv("CUDA_PATH", "") def ...
93
5,995
tinygrad
tinygrad/runtime/support/memory.py
.py
import collections, functools, dataclasses, enum from typing import Any, ClassVar from tinygrad.helpers import round_up, getenv class BumpAllocator: def __init__(self, size:int, base:int=0, wrap:bool=True): self.size, self.ptr, self.base, self.wrap = size, 0, base, wrap def alloc(self, size:int, alignment:int=1) -...
282
15,268
tinygrad
tinygrad/runtime/support/nv/nvdev.py
.py
from __future__ import annotations import time, functools, tinygrad.runtime.autogen.nv_regs from tinygrad.helpers import getenv, DEBUG, getbits, round_up from tinygrad.runtime.autogen import pci from tinygrad.runtime.support.memory import TLSFAllocator, MemoryManager, AddrSpace from tinygrad.runtime.support.nv.ip impor...
164
8,717
tinygrad
tinygrad/runtime/support/nv/ip.py
.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 lo32, hi32, DEBUG, round_up, round_down, fetch_fw, wait_cond, ceildiv from tinygrad.runtime.support.syste...
651
41,645
tinygrad
tinygrad/runtime/support/mlx/mlxdev.py
.py
from __future__ import annotations import struct, random, socket, ctypes, functools, itertools from tinygrad.helpers import getenv, wait_cond, round_up, next_power2, ceildiv, DEBUG, hi32, lo32, to_be32, to_be64 from tinygrad.runtime.support.memory import BumpAllocator from tinygrad.runtime.support.system import PCIDevi...
249
15,297
tinygrad
tinygrad/runtime/support/am/amdev.py
.py
from __future__ import annotations import ctypes, collections, dataclasses, functools, hashlib, array from tinygrad.helpers import mv_address, getenv, DEBUG, lo32, hi32, fetch_fw from tinygrad.runtime.autogen import pci from tinygrad.runtime.autogen.am import am, fw from tinygrad.runtime.support.amd import AMDReg, impo...
335
18,705
tinygrad
tinygrad/runtime/support/am/ip.py
.py
import ctypes, time, contextlib, functools from typing import Literal from tinygrad.helpers import to_mv, data64, lo32, hi32, DEBUG, wait_cond, pad_bytes, getbits from tinygrad.runtime.autogen.am import am from tinygrad.runtime.support.amd import import_soc from tinygrad.runtime.support.memory import AddrSpace class A...
704
43,101
tinygrad
tinygrad/runtime/graph/metal.py
.py
from typing import Any, cast import ctypes, decimal, struct from tinygrad.helpers import dedup, getenv, unwrap, PROFILE from tinygrad.device import Buffer, Device, ProfileGraphEntry, ProfileGraphEvent from tinygrad.uop.ops import UOp, Ops from tinygrad.engine.jit import GraphRunner, GraphException from tinygrad.runtime...
119
7,001
tinygrad
tinygrad/runtime/graph/hcq.py
.py
import collections, time from typing import Any, cast from tinygrad.helpers import round_up, PROFILE, ALL2ALL, merge_dicts, getenv, suppress_finalizing, TracingKey, unwrap from tinygrad.runtime.support.hcq import HCQCompiled, HCQAllocator, HCQSignal, HCQBuffer, HWQueue, HCQArgsState, BumpAllocator, MMIOInterface from t...
337
20,959
tinygrad
tinygrad/runtime/graph/cuda.py
.py
import ctypes from typing import Any, cast import tinygrad.runtime.autogen.cuda as cuda from tinygrad.runtime.support.c import init_c_var from tinygrad.device import Device, MultiBuffer from tinygrad.uop.ops import UOp, Ops from tinygrad.runtime.ops_cuda import CUDADevice, check, encode_args, cu_time_execution from tin...
75
4,399
tinygrad
tinygrad/mixin/creation.py
.py
from typing import TYPE_CHECKING, Callable, Self from tinygrad.dtype import ConstType, DType, DTypeLike, Invalid, dtypes, to_dtype from tinygrad.helpers import argfix, prod from tinygrad.mixin.dtype import DTypeMixin from tinygrad.mixin.movement import MovementMixin if TYPE_CHECKING: from tinygrad.uop.ops import sin...
164
7,059
tinygrad
tinygrad/mixin/rand.py
.py
from __future__ import annotations import math from typing import Self, cast from tinygrad.dtype import DType, DTypeLike, dtypes, least_upper_dtype, to_dtype, bitcast from tinygrad.helpers import all_int, argfix, ceildiv, prod, TRAINING from tinygrad.mixin.op import OpMixin from tinygrad.device import canonicalize_devi...
328
15,504
tinygrad
tinygrad/mixin/movement.py
.py
# mixins add syntactic sugar to Tensor and UOp from __future__ import annotations from typing import TYPE_CHECKING, Self, Sequence from tinygrad.uop import Ops from tinygrad.helpers import prod, argfix, argsort, flatten, dedup, make_tuple, ceildiv, round_up, all_int from tinygrad.uop.ops import resolve, smax, _align_le...
640
30,985
tinygrad
tinygrad/mixin/elementwise.py
.py
import math, functools, operator from typing import TYPE_CHECKING, Literal, Self from tinygrad.uop import Ops from tinygrad.dtype import dtypes, ConstType, PyConst, least_upper_dtype, least_upper_float, weak_dtype from tinygrad.helpers import argfix, polyN from tinygrad.mixin.creation import CreationMixin if TYPE_CHEC...
1,090
38,375
tinygrad
tinygrad/mixin/gradient.py
.py
from typing import cast import math, dataclasses from tinygrad.uop.ops import UOp, PatternMatcher, UPat, Ops, all_metadata, broadcast_axes from tinygrad.helpers import argsort from tinygrad.dtype import sum_acc_dtype from tinygrad.function import renumber_invalid_outputs def reduce_gradient(ctx:UOp, ret:UOp, op:Ops): ...
136
9,402
tinygrad
tinygrad/mixin/op.py
.py
from __future__ import annotations import functools, itertools, math, string from typing import TYPE_CHECKING, Callable, Self, Sequence, Literal, get_args from tinygrad.mixin.elementwise import ElementwiseMixin from tinygrad.mixin.movement import MovementMixin from tinygrad.mixin.reduce import ReduceMixin from tinygrad...
1,985
101,510
tinygrad
tinygrad/mixin/dtype.py
.py
from typing import TYPE_CHECKING, Self from tinygrad.dtype import DType, DTypeLike, dtypes, to_dtype from tinygrad.uop import Ops if TYPE_CHECKING: from tinygrad.uop.ops import UOp class DTypeMixin: @property def dtype(self) -> DType: raise NotImplementedError @property def _uop(self) -> 'UOp': raise NotImp...
140
4,538
tinygrad
tinygrad/mixin/reduce.py
.py
from typing import Self, Sequence from tinygrad.uop import Ops from tinygrad.dtype import DTypeLike, dtypes, strong_dtype, sum_acc_dtype, to_dtype from tinygrad.helpers import make_tuple from tinygrad.mixin.dtype import DTypeMixin from tinygrad.mixin.movement import MovementMixin class ReduceMixin(DTypeMixin, Movemen...
139
5,900
tinygrad
test/test_tiny.py
.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 getenv, OSX class TestTiny(unittest.TestCase): # *** basic functionality *** def test_const(self): const = Te...
166
5,546
tinygrad
test/helpers.py
.py
import os, time, struct, functools, unittest from dataclasses import replace from typing import Any, Callable import numpy as np from tinygrad import Tensor, dtypes, Device from tinygrad.uop.ops import UOp, Ops, KernelInfo from tinygrad.tensor import _to_np_dtype from tinygrad.codegen import to_program from tinygrad.dt...
148
6,631
tinygrad
test/testextra/test_fp8_linear.py
.py
#!/usr/bin/env python import unittest import numpy as np from tinygrad import Tensor, dtypes, Device from tinygrad.nn import Linear from extra.fp8.fp8_linear import FP8Linear, convert_to_float8_training from test.helpers import not_support_multi_device, needs_second_gpu BS, T, in_dim, out_dim = 16, 4, 128, 128 @unitt...
91
3,951
tinygrad
test/testextra/test_mockgpu.py
.py
from tinygrad.helpers import DEV import unittest, importlib @unittest.skipUnless(DEV.interface.startswith("MOCK"), 'Testing mockgpu') class TestMockGPU(unittest.TestCase): # https://github.com/tinygrad/tinygrad/pull/7627 def test_import_typing_extensions(self): import test.mockgpu.mockgpu # noqa: F401 # pylin...
13
508
tinygrad
test/testextra/test_hk_fa.py
.py
import unittest, time from tinygrad import Tensor, Device, dtypes, Context from tinygrad.engine.jit import TinyJit import numpy as np from extra.thunder.amd.fa import flash_attention def assert_allclose(cmp:Tensor, ref:Tensor, **kwargs) -> None: if Device.DEFAULT == "NULL": Tensor.realize(cmp, ref) else: np.test...
227
8,195
tinygrad
test/testextra/test_f16_decompress.py
.py
import unittest from extra.f16_decompress import u32_to_f16 from tinygrad.tensor import Tensor from tinygrad import dtypes import numpy as np class TestF16Decompression(unittest.TestCase): def test_u32_to_f16(self): a = Tensor.randn(50, dtype=dtypes.float16) f16_as_u32 = a.bitcast(dtypes.uint32) f16 = u3...
15
443
tinygrad
test/testextra/test_bench_log.py
.py
import unittest, time from unittest.case import skipIf from extra.bench_log import BenchEvent, InstantBenchEvent, WallTimeEvent, KernelTimeEvent, log_event_instant, _events, clear_events from tinygrad.helpers import Context, DEV from tinygrad.tensor import Tensor from tinygrad.device import Device # WEBGPU kernel tim...
112
3,898