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
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/optimization/test_beam_search.py
tinygrad_repo/extra/optimization/test_beam_search.py
import unittest import numpy as np from tinygrad.helpers import BEAM, Timing, CI, Context from tinygrad import Variable, Tensor from tinygrad.nn import Conv2d def rand(*shape): return Tensor(np.random.rand(*shape).astype(np.float32)) class TestBeamSearch(unittest.TestCase): def setUp(self): self.old_beam = B...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/optimization/test_time_linearizer.py
tinygrad_repo/extra/optimization/test_time_linearizer.py
from extra.optimization.helpers import load_worlds, ast_str_to_lin, time_linearizer from tinygrad.codegen.opt.search import bufs_from_lin, get_kernel_actions if __name__ == "__main__": ast_strs = load_worlds() for i, ast_str in enumerate(ast_strs): lin = ast_str_to_lin(ast_str) rawbufs = bufs_from_lin(lin)...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/optimization/get_action_space.py
tinygrad_repo/extra/optimization/get_action_space.py
import random from extra.optimization.helpers import load_worlds, ast_str_to_lin from tinygrad.codegen.opt.search import actions from tinygrad.codegen.opt.kernel import Kernel from tinygrad.codegen.opt.heuristic import hand_coded_optimizations from tinygrad.helpers import tqdm tactions = set() def test_rebuild(lin): ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/optimization/helpers.py
tinygrad_repo/extra/optimization/helpers.py
# stuff needed to unpack a kernel from tinygrad import Variable from tinygrad.codegen.opt import Opt, OptOps from tinygrad.uop.ops import UOp, Ops, KernelInfo from tinygrad.dtype import dtypes, PtrDType from tinygrad.shape.shapetracker import ShapeTracker from tinygrad.shape.view import View from tinygrad.helpers impor...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/optimization/rl.py
tinygrad_repo/extra/optimization/rl.py
import os import numpy as np import math, random from tinygrad.tensor import Tensor from tinygrad.nn.state import get_parameters, get_state_dict, safe_save, safe_load, load_state_dict from tinygrad.codegen.opt.search import actions, bufs_from_lin, get_kernel_actions from tinygrad.nn.optim import Adam from extra.optimiz...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/optimization/extract_policynet.py
tinygrad_repo/extra/optimization/extract_policynet.py
import os, sys, sqlite3, pickle, random from tqdm import tqdm, trange from copy import deepcopy from tinygrad.nn import Linear from tinygrad.tensor import Tensor from tinygrad.nn.optim import Adam from tinygrad.nn.state import get_parameters, get_state_dict, safe_save, safe_load, load_state_dict from tinygrad.codegen.o...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/optimization/test_net.py
tinygrad_repo/extra/optimization/test_net.py
import numpy as np import math import random np.set_printoptions(suppress=True) from copy import deepcopy from tinygrad.helpers import getenv, colored from tinygrad.tensor import Tensor from tinygrad.nn.state import get_parameters, get_state_dict, safe_save, safe_load, load_state_dict from tinygrad.codegen.opt.search i...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/optimization/test_helpers.py
tinygrad_repo/extra/optimization/test_helpers.py
import unittest from extra.optimization.helpers import load_worlds class TestKernelDataset(unittest.TestCase): def test_load_worlds_filters(self): all_kernels = load_worlds(filter_reduce=False, filter_noimage=False, filter_novariable=False) reduce_kernels = load_worlds(filter_reduce=True, filter_noimage=Fa...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/optimization/run_qnet.py
tinygrad_repo/extra/optimization/run_qnet.py
from typing import List, Tuple from tinygrad.codegen.opt.kernel import Kernel from tinygrad.codegen.opt.search import get_kernel_actions, actions _net = None def beam_q_estimate(beam:List[Tuple[Kernel, float]]) -> List[Tuple[Kernel, float]]: global _net if _net is None: from tinygrad.nn.state import load_state...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/datasets/librispeech.py
tinygrad_repo/extra/datasets/librispeech.py
import json import pathlib import numpy as np import librosa import soundfile """ The dataset has to be downloaded manually from https://www.openslr.org/12/ and put in `extra/datasets/librispeech`. For mlperf validation the dev-clean dataset is used. Then all the flacs have to be converted to wav using something like...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/datasets/wikipedia.py
tinygrad_repo/extra/datasets/wikipedia.py
# Preprocessing of downloaded text from Wikipedia for MLPerf BERT training # This is a modified version of the original script: # https://github.com/mlcommons/training/blob/master/language_model/tensorflow/bert/cleanup_scripts/create_pretraining_data.py # ENV VARS: # MAX_SEQ_LENGTH - Maximum sequence length # ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/datasets/preprocess_imagenet.py
tinygrad_repo/extra/datasets/preprocess_imagenet.py
from tinygrad import Tensor, dtypes from extra.datasets.imagenet import iterate, get_val_files if __name__ == "__main__": #sz = len(get_val_files()) sz = 32*100 X,Y = None, None idx = 0 for x,y in iterate(shuffle=False): print(x.shape, y.shape, x.dtype, y.dtype) assert x.shape[0] == y.shape[0] b...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/datasets/coco.py
tinygrad_repo/extra/datasets/coco.py
import json import pathlib import zipfile import numpy as np from tinygrad.helpers import fetch import pycocotools._mask as _mask from examples.mask_rcnn import Masker from pycocotools.coco import COCO from pycocotools.cocoeval import COCOeval iou = _mask.iou merge = _mask.merge frPyObjects = _mask.frPyO...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/datasets/imagenet_download.py
tinygrad_repo/extra/datasets/imagenet_download.py
# Python version of https://gist.github.com/antoinebrl/7d00d5cb6c95ef194c737392ef7e476a from tinygrad.helpers import fetch from pathlib import Path from tqdm import tqdm import tarfile, os def imagenet_extract(file, path, small=False): with tarfile.open(name=file) as tar: if small: # Show progressbar only for bi...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/datasets/fake_imagenet_from_mnist.py
tinygrad_repo/extra/datasets/fake_imagenet_from_mnist.py
#!/usr/bin/env python3 import pathlib, json from tinygrad.helpers import trange from extra.datasets import fetch_mnist from PIL import Image import numpy as np from multiprocessing import Pool X_train, Y_train, X_test, Y_test = fetch_mnist() def act(arg): (basedir, i, train) = arg if train: img = np.uint8(X_t...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/datasets/wikipedia_download.py
tinygrad_repo/extra/datasets/wikipedia_download.py
# pip install gdown # Downloads the 2020 wikipedia dataset used for MLPerf BERT training import os, hashlib from pathlib import Path import tarfile import gdown from tqdm import tqdm from tinygrad.helpers import getenv def gdrive_download(url:str, path:str): if not os.path.exists(path): gdown.download(url, path) de...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/datasets/squad.py
tinygrad_repo/extra/datasets/squad.py
import json import os from pathlib import Path from transformers import BertTokenizer import numpy as np from tinygrad.helpers import fetch BASEDIR = Path(__file__).parent / "squad" def init_dataset(): os.makedirs(BASEDIR, exist_ok=True) fetch("https://rajpurkar.github.io/SQuAD-explorer/dataset/dev-v1.1.json", BAS...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/datasets/kits19.py
tinygrad_repo/extra/datasets/kits19.py
import random import functools from pathlib import Path import numpy as np import nibabel as nib from scipy import signal, ndimage import os import torch import torch.nn.functional as F from tqdm import tqdm from tinygrad.tensor import Tensor from tinygrad.helpers import fetch BASEDIR = Path(__file__).parent / "kits19...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/datasets/openimages.py
tinygrad_repo/extra/datasets/openimages.py
import glob import sys import json import numpy as np from PIL import Image from pathlib import Path import boto3, botocore from tinygrad import Tensor, dtypes from tinygrad.helpers import fetch, tqdm, getenv import pandas as pd import concurrent.futures BASEDIR = Path(__file__).parent / "open-images-v6-mlperf" BUCKET...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/datasets/__init__.py
tinygrad_repo/extra/datasets/__init__.py
import os, gzip, tarfile, pickle import numpy as np from tinygrad import Tensor, dtypes from tinygrad.helpers import fetch def fetch_mnist(tensors=False): parse = lambda file: np.frombuffer(gzip.open(file).read(), dtype=np.uint8).copy() BASE_URL = "https://storage.googleapis.com/cvdf-datasets/mnist/" # http://ya...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/datasets/imagenet.py
tinygrad_repo/extra/datasets/imagenet.py
# for imagenet download prepare.sh and run it import glob, random, json, math import numpy as np from PIL import Image import functools, pathlib from tinygrad.helpers import diskcache, getenv @functools.cache def get_imagenet_categories(): ci = json.load(open(BASEDIR / "imagenet_class_index.json")) return {v[0]: i...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/efficientnet.py
tinygrad_repo/extra/models/efficientnet.py
import math from tinygrad.tensor import Tensor from tinygrad.nn import BatchNorm2d from tinygrad.helpers import get_child, fetch from tinygrad.nn.state import torch_load class MBConvBlock: def __init__(self, kernel_size, strides, expand_ratio, input_filters, output_filters, se_ratio, has_se, track_running_stats=True...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/unet.py
tinygrad_repo/extra/models/unet.py
from tinygrad import Tensor, dtypes from tinygrad.nn import Linear, Conv2d, GroupNorm, LayerNorm from tinygrad.device import is_dtype_supported from typing import Optional, Union, List, Any, Tuple import math # https://github.com/Stability-AI/generative-models/blob/fbdc58cab9f4ee2be7a5e1f2e2787ecd9311942f/sgm/modules/...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/mask_rcnn.py
tinygrad_repo/extra/models/mask_rcnn.py
import re import math import os import numpy as np from pathlib import Path from tinygrad import nn, Tensor, dtypes from tinygrad.tensor import _to_np_dtype from tinygrad.helpers import get_child, fetch from tinygrad.nn.state import torch_load from examples.mlperf.helpers import BoxCoder from extra.models.resnet import...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
true
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/bert.py
tinygrad_repo/extra/models/bert.py
import re, os from pathlib import Path from tinygrad.tensor import Tensor, cast from tinygrad import nn, dtypes from tinygrad.helpers import fetch, get_child from tinygrad.nn.state import get_parameters # allow for monkeypatching Embedding = nn.Embedding Linear = nn.Linear LayerNorm = nn.LayerNorm class BertForQuesti...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/t5.py
tinygrad_repo/extra/models/t5.py
# pip3 install sentencepiece # adapted from https://github.com/huggingface/transformers/blob/main/src/transformers/models/t5/modeling_t5.py # coding=utf-8 # Copyright 2018 Mesh TensorFlow authors, T5 Authors and HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not u...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/llama.py
tinygrad_repo/extra/models/llama.py
from typing import Union, Optional, Any import collections, math from tinygrad import Tensor, Variable, TinyJit, dtypes, nn, Device from tinygrad.helpers import getenv, DEBUG # https://github.com/facebookresearch/llama/blob/1076b9c51c77ad06e9d7ba8a4c6df775741732bd/llama/model.py#L47 def precompute_freqs_cis(dim: int, ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/retinanet.py
tinygrad_repo/extra/models/retinanet.py
import math from tinygrad import Tensor, dtypes from tinygrad.helpers import flatten, get_child from examples.mlperf.helpers import generate_anchors, BoxCoder from examples.mlperf.losses import sigmoid_focal_loss, l1_loss from extra.models.resnet import ResNet import tinygrad.nn as nn import numpy as np ConvFPN = Conv...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/vit.py
tinygrad_repo/extra/models/vit.py
import numpy as np from tinygrad.tensor import Tensor from tinygrad.helpers import fetch from extra.models.transformer import TransformerBlock class ViT: def __init__(self, layers=12, embed_dim=192, num_heads=3): self.embedding = (Tensor.uniform(embed_dim, 3, 16, 16), Tensor.zeros(embed_dim)) self.embed_dim ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/inception.py
tinygrad_repo/extra/models/inception.py
from tinygrad import Tensor from tinygrad.nn import Conv2d, BatchNorm2d, Linear from tinygrad.nn.state import load_state_dict, torch_load from tinygrad.helpers import fetch from typing import Optional, Dict import numpy as np from scipy import linalg # Base Inception Model class BasicConv2d: def __init__(self, in_...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/unet3d.py
tinygrad_repo/extra/models/unet3d.py
from pathlib import Path import torch from tinygrad import nn from tinygrad.tensor import Tensor from tinygrad.helpers import fetch, get_child class DownsampleBlock: def __init__(self, c0, c1, stride=2): self.conv1 = [nn.Conv2d(c0, c1, kernel_size=(3,3,3), stride=stride, padding=(1,1,1,1,1,1), bias=False), nn.In...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/resnet.py
tinygrad_repo/extra/models/resnet.py
import tinygrad.nn as nn from tinygrad import Tensor, dtypes from tinygrad.nn.state import torch_load from tinygrad.helpers import fetch, get_child # allow monkeypatching in layer implementations BatchNorm = nn.BatchNorm2d Conv2d = nn.Conv2d Linear = nn.Linear class BasicBlock: expansion = 1 def __init__(self, ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/convnext.py
tinygrad_repo/extra/models/convnext.py
from tinygrad.tensor import Tensor from tinygrad.nn import Conv2d, LayerNorm, LayerNorm2d, Linear from tinygrad.helpers import fetch, get_child class Block: def __init__(self, dim): self.dwconv = Conv2d(dim, dim, kernel_size=7, padding=3, groups=dim) self.norm = LayerNorm(dim, eps=1e-6) self.pwconv1 = Li...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/transformer.py
tinygrad_repo/extra/models/transformer.py
from tinygrad import Tensor class TransformerBlock: def __init__(self, embed_dim, num_heads, ff_dim, prenorm=False, act=lambda x: x.relu(), dropout=0.1): assert embed_dim % num_heads == 0, "embed_dim must be divisible by num_heads" self.num_heads = num_heads self.head_size = embed_dim // num_heads s...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/rnnt.py
tinygrad_repo/extra/models/rnnt.py
from tinygrad.tensor import Tensor from tinygrad.engine.jit import TinyJit from tinygrad.nn import Linear, Embedding from tinygrad.helpers import fetch import numpy as np from pathlib import Path class RNNT: def __init__(self, input_features=240, vocab_size=29, enc_hidden_size=1024, pred_hidden_size=320, joint_hidd...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/models/clip.py
tinygrad_repo/extra/models/clip.py
from tinygrad import Tensor, dtypes from tinygrad.helpers import fetch from tinygrad.nn import Linear, LayerNorm, Embedding, Conv2d from typing import List, Optional, Union, Tuple, Dict from abc import ABC, abstractmethod from functools import lru_cache from PIL import Image import numpy as np import re, gzip @lru_ca...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/sqtt/rgptool.py
tinygrad_repo/extra/sqtt/rgptool.py
#!/usr/bin/env python3 from __future__ import annotations import argparse, ctypes, struct, hashlib, pickle, code, typing, functools import tinygrad.runtime.autogen.sqtt as sqtt from tinygrad.device import ProfileEvent, ProfileDeviceEvent, ProfileProgramEvent from tinygrad.runtime.ops_amd import ProfileSQTTEvent from ti...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/torch_hook/hook_torch.py
tinygrad_repo/extra/torch_hook/hook_torch.py
import ctypes, struct, platform, pathlib, os, binascii, itertools from hexdump import hexdump from tinygrad.device import Device from tinygrad import Tensor from tinygrad.dtype import _from_torch_dtype from tinygrad.helpers import to_mv, DEBUG, getenv, colored, time_to_str import extra.torch_hook.hook_cuda as hook_cud...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/torch_hook/hook_cuda.py
tinygrad_repo/extra/torch_hook/hook_cuda.py
import ctypes, struct, platform, pathlib, os, binascii, itertools from hexdump import hexdump from tinygrad.helpers import to_mv, DEBUG, getenv, colored, time_to_str from tinygrad.runtime.autogen import libc, cuda from tinygrad.device import CPUProgram, Device from tinygrad.runtime.support.elf import elf_loader from ti...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/sched/fuzz_schedule.py
tinygrad_repo/extra/sched/fuzz_schedule.py
import itertools import numpy as np from typing import DefaultDict, Dict, List, Set, Tuple, TypeVar, Union from tinygrad.device import Buffer from tinygrad.engine.realize import capturing, lower_schedule_item from tinygrad.helpers import DEBUG, MULTIOUTPUT, colored, getenv from tinygrad.engine.schedule import LBSchedul...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/assembly/assembly_arm64.py
tinygrad_repo/extra/assembly/assembly_arm64.py
import struct from platform import system from typing import Tuple, Dict, List, Optional from tinygrad import dtypes from tinygrad.uop.ops import BinaryOps, UnaryOps, TernaryOps from tinygrad.codegen.opt.kernel import Ops, UOp from tinygrad.helpers import CI from tinygrad.codegen.assembly import uops_to_asmstyle, Assem...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/assembly/assembly.py
tinygrad_repo/extra/assembly/assembly.py
from typing import Tuple, List, NamedTuple, Any, Dict, Optional, Union, DefaultDict, cast from tinygrad.codegen.opt.kernel import Ops, MemOp, UOp from tinygrad.uop.ops import BinaryOps, UnaryOps from tinygrad.dtype import DType, dtypes from tinygrad.helpers import DEBUG from tinygrad.uop.ops import Variable, NumNode, M...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/assembly/assembly_rdna.py
tinygrad_repo/extra/assembly/assembly_rdna.py
import yaml from typing import Tuple, Set, Dict from tinygrad import dtypes from tinygrad.codegen.assembly import AssemblyCodegen, Register from tinygrad.codegen.opt.kernel import Ops from tinygrad.uop.ops import BinaryOps, UnaryOps, TernaryOps from tinygrad.runtime.ops_cl import ROCM_LLVM_PATH # ugh, is this really n...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/assembly/assembly_ptx.py
tinygrad_repo/extra/assembly/assembly_ptx.py
from typing import List import struct from tinygrad.codegen.assembly import uops_to_asmstyle, AssemblyLanguage from tinygrad.codegen.opt.kernel import Ops, UOp from tinygrad import dtypes from tinygrad.uop.ops import BinaryOps, UnaryOps, TernaryOps from tinygrad.runtime.ops_cuda import arch dtype_to_nvtype = {dtypes.f...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/assembly/ptx/test.py
tinygrad_repo/extra/assembly/ptx/test.py
#!/usr/bin/env python3 import numpy as np from tinygrad.runtime.ops_cuda import CUDAProgram, RawCUDABuffer if __name__ == "__main__": test = RawCUDABuffer.fromCPU(np.zeros(10, np.float32)) prg = CUDAProgram("test", """ .version 7.8 .target sm_86 .address_size 64 .visible .entry test(.param .u64 x) { .r...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/assembly/rocm/rdna3/asm.py
tinygrad_repo/extra/assembly/rocm/rdna3/asm.py
import numpy as np import pathlib from hexdump import hexdump from tinygrad.helpers import colored from extra.helpers import enable_early_exec early_exec = enable_early_exec() from tinygrad.runtime.ops_cl import CLProgram, CLBuffer, ROCM_LLVM_PATH ENABLE_NON_ASM = False WMMA = True DUAL_ALU = True F32 = True if ENA...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/tinygrad_nv_matmul.py
tinygrad_repo/extra/gemm/tinygrad_nv_matmul.py
from tinygrad import Tensor, dtypes, Device from tinygrad.helpers import getenv, DEBUG from tinygrad.codegen.opt.kernel import Kernel, Opt, OptOps from tinygrad.engine.realize import CompiledRunner, ExecItem, get_program from dataclasses import replace N = 4096 if __name__ == "__main__": if getenv("GEMV"): A, B ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/metal_conv.py
tinygrad_repo/extra/gemm/metal_conv.py
import os #os.environ["METAL"] = "1" import numpy as np BS = 64 CIN = 256 COUT = 256 HW = 32 K = 3 PADDING = 0 # TODO: this is doing some trick, since with CIN=256 COUT=256 it's over 10.4 TFLOPS. # are winograd convs less flops? it appears so if they are batched # https://www.cse.ust.hk/~weiwa/papers/yan-ppopp20.pdf F...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/real_pmatmul.py
tinygrad_repo/extra/gemm/real_pmatmul.py
import time from tinygrad import Tensor, Device, TinyJit from tinygrad.helpers import getenv if __name__ == "__main__": DEVS = [f"NV:{i}" for i in range(getenv("GPUS", 2))] N = getenv("N", 8192) A = Tensor.rand(N, N).shard(DEVS, 0).realize() B = Tensor.rand(N, N).shard(DEVS, 1).realize() print("***** MUL ***...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/torch_gemm.py
tinygrad_repo/extra/gemm/torch_gemm.py
import os os.environ["NVIDIA_TF32_OVERRIDE"] = "0" os.environ["MKL_NUM_THREADS"] = "1" os.environ["NUMEXPR_NUM_THREADS"] = "1" os.environ["OMP_NUM_THREADS"] = "1" import time import torch torch.set_num_threads(1) from tinygrad.helpers import getenv CUDA = getenv("CUDA", 1) for dtype in [torch.float32, torch.float16]: ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/mlx_matmul.py
tinygrad_repo/extra/gemm/mlx_matmul.py
import mlx.core as mx from tinygrad.helpers import Timing N = 4096 x = mx.random.normal((N,N)) w = mx.random.normal((N,N)) FLOPS = N*N*N*2 for i in range(10): with Timing("", lambda x: f" {FLOPS/x:.2f} GFLOPS"): mx.eval(x@w)
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/max_matmul.py
tinygrad_repo/extra/gemm/max_matmul.py
import numpy as np, os from tinygrad.helpers import getenv, flat_mv from tinygrad import dtypes from typing import Optional, List, Tuple, cast, Dict, Final, DefaultDict, Self from tinygrad.engine.realize import get_program # for copied uops from tinygrad.codegen.opt.kernel import Kernel, KernelOptError from tinygrad.u...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/metal_matvec.py
tinygrad_repo/extra/gemm/metal_matvec.py
import numpy as np import time, torch, torch.mps from tinygrad import Tensor, TinyJit, Device from tinygrad.helpers import flat_mv from tinygrad.runtime.ops_metal import MetalAllocator, MetalDevice, MetalProgram, MetalCompiler N = 16384 M = 4096 FLOPS = N*M*2 nb = np.random.default_rng().standard_normal(size=(N), dt...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/tf_gemm.py
tinygrad_repo/extra/gemm/tf_gemm.py
import time import tensorflow as tf gpus = tf.config.list_physical_devices('GPU') if gpus: try: # Currently, memory growth needs to be the same across GPUs for gpu in gpus: tf.config.experimental.set_memory_growth(gpu, True) logical_gpus = tf.config.list_logical_devices('GPU') print(len(gpus), ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/cuda_matmul.py
tinygrad_repo/extra/gemm/cuda_matmul.py
import os import numpy as np os.environ["CUDA"] = "1" from tinygrad.runtime.ops_cuda import CUDAAllocator, CUDADevice, CUDAProgram, CUDACompiler from tinygrad.helpers import flat_mv FLOAT16 = True ACC_FLOAT16 = False N = 4096 na = np.random.default_rng().standard_normal(size=(N,N), dtype=np.float32) nb = np.random.de...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/triton_nv_matmul.py
tinygrad_repo/extra/gemm/triton_nv_matmul.py
import time import triton import triton.language as tl from triton.compiler import AttrsDescriptor, ASTSource, compile as triton_compile import numpy as np from tinygrad import Tensor, dtypes, Device from tinygrad.engine.realize import CompiledRunner, ExecItem, ProgramSpec from tinygrad.helpers import getenv np.set_pri...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/amx.py
tinygrad_repo/extra/gemm/amx.py
#!/usr/bin/env python3 import numpy as np import time import sys np.set_printoptions(linewidth=160) np.set_printoptions(linewidth=1000, threshold=10000000000, suppress=False) from tinygrad.runtime.ops_llvm import LLVMDevice, LLVMProgram, LLVMCompiler from llvmlite import ir # type: ignore from tinygrad.helpers import ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/hip_matmul.py
tinygrad_repo/extra/gemm/hip_matmul.py
import time import numpy as np from tinygrad.helpers import getenv, prod, flat_mv from tinygrad.runtime.ops_amd import AMDAllocator, AMDDevice, AMDProgram # AMD_LOG_LEVEL=3 ./MIOpenDriver gemm --iter 1000 --time 1 --a_w 2048 --a_h 2048 --b_w 2048 # 5.5: Cijk_Ailk_Bljk_HHS_BH_MT128x128x16_MI16x16x16x1_SN_1LDSB0_APM1_AB...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/simple_matmul.py
tinygrad_repo/extra/gemm/simple_matmul.py
import numpy as np from tinygrad import dtypes, Tensor from tinygrad.helpers import getenv, get_single_element from tinygrad.dtype import _to_np_dtype from tinygrad.codegen.opt import OptOps from tinygrad.engine.realize import lower_schedule dtype_in = dtypes.half if getenv("HALF") else dtypes.bfloat16 if getenv("BFLO...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/amd_matmul.py
tinygrad_repo/extra/gemm/amd_matmul.py
# kernel8_batched_gmem.s from https://seb-v.github.io/optimization/update/2025/01/20/Fast-GPU-Matrix-multiplication.html # sudo PATH=/opt/homebrew/Cellar/llvm/20.1.6/bin:$PATH AMD_LLVM=0 AMD=1 DEBUG=2 python3 extra/gemm/amd_matmul.py import pathlib from dataclasses import replace from tinygrad import Tensor, Device, Co...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/simple_conv.py
tinygrad_repo/extra/gemm/simple_conv.py
from tinygrad.helpers import getenv from tinygrad import dtypes, Tensor dtype_in = dtypes.half if getenv("HALF") else dtypes.bfloat16 if getenv("BFLOAT16") else dtypes.float acc_dtype = dtypes.half if getenv("ACC_HALF") else dtypes.bfloat16 if getenv("ACC_BFLOAT16") else None CNT = getenv("CNT", 8) BS = getenv("BS", ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/gemm.py
tinygrad_repo/extra/gemm/gemm.py
#!/usr/bin/env python3 import os #os.environ['OMP_NUM_THREADS'] = '1' import time import numpy as np N = 512 if __name__ == "__main__": # N^2 A = np.random.randn(N, N).astype(np.float32) # N^2 B = np.random.randn(N, N).astype(np.float32) # 2N compute in N^2 output cells flop = 2*N*N*N #print(f"{flop / 1...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/fuzz_matmul.py
tinygrad_repo/extra/gemm/fuzz_matmul.py
import numpy as np from tinygrad.helpers import getenv from tinygrad import dtypes, Tensor dtype_in = dtypes.half if getenv("HALF") else dtypes.bfloat16 if getenv("BFLOAT16") else dtypes.float acc_dtype = dtypes.half if getenv("ACC_HALF") else dtypes.bfloat16 if getenv("ACC_BFLOAT16") else None N_START = getenv("N_STAR...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/tvm_gemm.py
tinygrad_repo/extra/gemm/tvm_gemm.py
# https://tvm.apache.org/docs/tutorial/tensor_expr_get_started.html#example-2-manually-optimizing-matrix-multiplication-with-te M, N, K = 1024, 1024, 1024 try: import tvm from tvm import te #print(tvm.target.Target.list_kinds()) # c, opencl target = tvm.target.Target(target="c") # TVM Matrix Multiplicat...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/halide_gemm.py
tinygrad_repo/extra/gemm/halide_gemm.py
import numpy as np import halide as hl from tinygrad.helpers import Timing, getenv # HL_DEBUG_CODEGEN=1 N = getenv("N", 1024) def gemm_pipeline(gpu=False): # ---------------- Vars & Parameters ---------------- i, j = hl.Var("i"), hl.Var("j") # output tile coordinates A = hl.InputBuffer(hl.Float(32), 2) # [M,...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/metal_matmul.py
tinygrad_repo/extra/gemm/metal_matmul.py
import os os.environ["METAL"] = "1" import time import numpy as np from tinygrad import Device, dtypes from tinygrad.helpers import getenv, flat_mv from tinygrad.runtime.ops_metal import MetalAllocator, MetalDevice, MetalProgram, MetalCompiler N = getenv("N", 2048) LID = 2 device = MetalDevice("METAL") metalalloc = M...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/amd_uop_matmul.py
tinygrad_repo/extra/gemm/amd_uop_matmul.py
from tinygrad import Tensor, Device, Context, GlobalCounters, dtypes from tinygrad.uop.ops import UOp, Ops, KernelInfo, graph_rewrite, AxisType, PatternMatcher, UPat from tinygrad.engine.realize import CompiledRunner, ExecItem, get_program from tinygrad.dtype import AddrSpace from tinygrad.helpers import getenv, colore...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/simple_matvec.py
tinygrad_repo/extra/gemm/simple_matvec.py
import numpy as np from tinygrad.helpers import getenv from tinygrad import dtypes, Tensor, Device dtype_in = dtypes.half if getenv("HALF") else dtypes.bfloat16 if getenv("BFLOAT16") else dtypes.float acc_dtype = dtypes.half if getenv("ACC_HALF") else dtypes.bfloat16 if getenv("ACC_BFLOAT16") else None GPUS = getenv("...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/intel_xmx.py
tinygrad_repo/extra/gemm/intel_xmx.py
#!/usr/bin/env python3 import numpy as np from tinygrad.runtime.ops_cl import CLProgram, CLCompiler from tinygrad import Device, dtypes from tinygrad.device import Buffer from hexdump import hexdump # https://github.com/intel/intel-graphics-compiler/blob/master/documentation/visa/instructions/DPAS.md # https://registr...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/gemm/jax_pmatmul.py
tinygrad_repo/extra/gemm/jax_pmatmul.py
#!/usr/bin/env python3 import time import jax import jax.numpy as jnp print(jax.devices()) DEVICES = len(jax.devices()) BS = 32 N = 4096 dtype = jnp.float16 A = jnp.zeros((DEVICES, BS, N, N), dtype) B = jnp.zeros((1, 1, N, N), dtype) A = jax.device_put_sharded([A[i] for i in range(DEVICES)], jax.devices()) B = jax.dev...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/junk/sentencepiece_model_pb2.py
tinygrad_repo/extra/junk/sentencepiece_model_pb2.py
# -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: sentencepiece_model.proto # Protobuf Python Version: 4.25.1 """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/torch_backend/test_multigpu.py
tinygrad_repo/extra/torch_backend/test_multigpu.py
import unittest from tinygrad.helpers import getenv import torch import tinygrad.frontend.torch torch.set_default_device("tiny") import numpy as np @unittest.skipIf(getenv("GPUS",1)<=1, "only single GPU") class TestTorchBackendMultiGPU(unittest.TestCase): def test_transfer(self): a = torch.Tensor([[1,2],[3,4]])....
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/torch_backend/backend2.py
tinygrad_repo/extra/torch_backend/backend2.py
# NOTE: this is probably the wrong backend to work on, you want backend.py # discussion about this in #pytorch-backend on our Discord # this is using high level debug features from torch and we should integrate deeper from tinygrad import Tensor import torch, contextlib from torch.utils._python_dispatch import TorchDi...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/torch_backend/torch_tests.py
tinygrad_repo/extra/torch_backend/torch_tests.py
import sys import unittest import torch import extra.torch_backend.backend from torch.testing._internal.common_utils import TestCase, is_privateuse1_backend_available assert is_privateuse1_backend_available() and torch._C._get_privateuse1_backend_name() == "tiny" from torch.testing._internal.common_device_type import ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/torch_backend/example.py
tinygrad_repo/extra/torch_backend/example.py
from PIL import Image from tinygrad.helpers import getenv import torch, torchvision, pathlib import torchvision.transforms as transforms import extra.torch_backend.backend device = "tiny" torch.set_default_device(device) if __name__ == "__main__": img = Image.open(pathlib.Path(__file__).parent.parent.parent / "test/...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/torch_backend/test_compile.py
tinygrad_repo/extra/torch_backend/test_compile.py
# https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html import torch import torch._dynamo from extra.torch_backend.backend import unwrap, wrap from torch._dynamo.backends.registry import register_backend from torch._functorch.aot_autograd import aot_module_simplified from tinygrad import Tensor, Tiny...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/torch_backend/test.py
tinygrad_repo/extra/torch_backend/test.py
# simple tests import unittest import torch import numpy as np from tinygrad.helpers import getenv, Context, GlobalCounters if getenv("TINY_BACKEND2"): import extra.torch_backend.backend2 device = "cpu" else: import extra.torch_backend.backend device = "tiny" class TestTorchBackend(unittest.TestCase): def te...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/torch_backend/backend.py
tinygrad_repo/extra/torch_backend/backend.py
# ruff: noqa: E501, A001, A002, A006 # A001 Variable `input` is shadowing a Python builtin # A002 Function argument `input` is shadowing a Python builtin # A006 Lambda argument `input` is shadowing a Python builtin from tinygrad import Tensor, dtypes, Device from tinygrad.uop.ops import Ops from tinygrad.helpers import...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
true
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/torch_backend/test_inplace.py
tinygrad_repo/extra/torch_backend/test_inplace.py
import unittest import torch import tinygrad.frontend.torch torch.set_default_device("tiny") import numpy as np class TestTorchBackendInplace(unittest.TestCase): def test_zero(self): a = torch.ones(4) a.zero_() np.testing.assert_equal(a.cpu().numpy(), [0,0,0,0]) def test_view_zero(self): a = torch...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/backends/clang_graph.py
tinygrad_repo/extra/backends/clang_graph.py
from typing import List, Dict, cast import ctypes from tinygrad.helpers import dedup, cpu_time_execution, DEBUG from tinygrad.engine.jit import GraphRunner, GraphException from tinygrad.device import Buffer, Device from tinygrad.engine.realize import ExecItem, CompiledRunner from tinygrad.uop.ops import Variable from t...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/backends/hsa_driver.py
tinygrad_repo/extra/backends/hsa_driver.py
import ctypes, collections import tinygrad.runtime.autogen.hsa as hsa from tinygrad.helpers import init_c_var def check(status): if status != 0: hsa.hsa_status_string(status, ctypes.byref(status_str := ctypes.POINTER(ctypes.c_char)())) raise RuntimeError(f"HSA Error {status}: {ctypes.string_at(status_str).de...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/backends/ops_hsa.py
tinygrad_repo/extra/backends/ops_hsa.py
from __future__ import annotations import ctypes, functools, subprocess, io, atexit, collections, json from typing import Tuple, TypeVar, List, Dict, Any import tinygrad.runtime.autogen.hsa as hsa from tinygrad.helpers import DEBUG, init_c_var, from_mv, round_up, to_mv, init_c_struct_t, getenv, PROFILE from tinygrad.de...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/backends/hsa_graph.py
tinygrad_repo/extra/backends/hsa_graph.py
import ctypes, collections, time, itertools from typing import List, Any, Dict, cast, Optional, Tuple from tinygrad.helpers import init_c_var, round_up from tinygrad.device import Buffer, BufferSpec from tinygrad.device import Compiled, Device from tinygrad.uop.ops import Variable from tinygrad.runtime.ops_hsa import H...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/backends/triton.py
tinygrad_repo/extra/backends/triton.py
from typing import Dict, List, Final, Callable, DefaultDict from collections import defaultdict from tinygrad.uop.ops import UnaryOps, BinaryOps, TernaryOps, Op from tinygrad.helpers import DType, PtrDType, dtypes, ImageDType, DEBUG, getenv from tinygrad.codegen.opt.kernel import UOp, Ops from triton.compiler import c...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/backends/graph_hip.py
tinygrad_repo/extra/backends/graph_hip.py
import ctypes from typing import Tuple import tinygrad.runtime.autogen.hip as hip from tinygrad.helpers import init_c_var, time_execution_cuda_style from tinygrad.runtime.ops_hip import check, hip_set_device from tinygrad.runtime.graph.cuda import CUDAGraph # TODO: this is only used in graph def hip_time_execution(cb,...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/backends/rdna.py
tinygrad_repo/extra/backends/rdna.py
from typing import Dict, Set import yaml from tinygrad.codegen.uops import UOpGraph, UOps, UOp from tinygrad.uop.ops import BinaryOps from tinygrad.dtype import dtypes def uops_to_rdna(function_name:str, uops:UOpGraph) -> str: replace: Dict[UOp, UOp] = {} seen: Set[UOp] = set() for u in uops: if u in seen: c...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/resnet18/resnet_mlx.py
tinygrad_repo/extra/resnet18/resnet_mlx.py
# code from https://x.com/awnihannun/status/1832511021602500796 from huggingface_hub import snapshot_download import mlx.core as mx import mlx.nn as nn import time class Block(nn.Module): def __init__(self, in_dims, dims, stride=1): super().__init__() self.conv1 = nn.Conv2d( in_dims, dims, kernel_siz...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/resnet18/resnet_tinygrad.py
tinygrad_repo/extra/resnet18/resnet_tinygrad.py
from huggingface_hub import snapshot_download from tinygrad import nn, Tensor, TinyJit, Device, GlobalCounters, Context import time class Block: def __init__(self, in_dims, dims, stride=1): super().__init__() self.conv1 = nn.Conv2d( in_dims, dims, kernel_size=3, stride=stride, padding=1, bias=False ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/qcom_gpu_driver/msm_kgsl.py
tinygrad_repo/extra/qcom_gpu_driver/msm_kgsl.py
# type: ignore # -*- coding: utf-8 -*- # # TARGET arch is: [] # WORD_SIZE is: 8 # POINTER_SIZE is: 8 # LONGDOUBLE_SIZE is: 16 # import ctypes class AsDictMixin: @classmethod def as_dict(cls, self): result = {} if not isinstance(self, AsDictMixin): # not a structure, assume it's alr...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/qcom_gpu_driver/qcom_opencl_interop.py
tinygrad_repo/extra/qcom_gpu_driver/qcom_opencl_interop.py
import ctypes, array from hexdump import hexdump from tinygrad.runtime.ops_cl import CLDevice from tinygrad.helpers import getenv, to_mv, mv_address from tinygrad.dtype import dtypes from tinygrad import Tensor, TinyJit from tinygrad.runtime.autogen import opencl as cl if getenv("IOCTL"): import extra.qcom_gpu_driver.o...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/qcom_gpu_driver/opencl_ioctl.py
tinygrad_repo/extra/qcom_gpu_driver/opencl_ioctl.py
# type: ignore import ctypes, ctypes.util, struct, fcntl, re from hexdump import hexdump from copy import deepcopy import pathlib, sys from tinygrad.helpers import to_mv, getenv from tinygrad.runtime.autogen import adreno sys.path.append(pathlib.Path(__file__).parent.parent.parent.as_posix()) IOCTL = getenv("IOCTL", 0...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/amdpci/proclogs.py
tinygrad_repo/extra/amdpci/proclogs.py
import re, ctypes, sys, importlib from tinygrad.runtime.support.am.amdev import AMDev, AMRegister class AMDFake(AMDev): def __init__(self, devfmt, vram, doorbell, mmio, dma_regions=None): self.devfmt, self.vram, self.doorbell64, self.mmio, self.dma_regions = devfmt, vram, doorbell, mmio, dma_regions self._ru...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/amdpci/am_smi.py
tinygrad_repo/extra/amdpci/am_smi.py
#!/usr/bin/env python3 import time, mmap, sys, shutil, os, glob, subprocess, argparse, collections from tinygrad.helpers import DEBUG, colored, ansilen from tinygrad.runtime.autogen import libc from tinygrad.runtime.autogen.am import am from tinygrad.runtime.support.hcq import MMIOInterface from tinygrad.runtime.suppo...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/nv_gpu_driver/nv_ioctl.py
tinygrad_repo/extra/nv_gpu_driver/nv_ioctl.py
# type: ignore import ctypes, ctypes.util, struct, platform, pathlib, re, time, os, signal from tinygrad.helpers import from_mv, to_mv, getenv, init_c_struct_t from hexdump import hexdump start = time.perf_counter() # *** ioctl lib *** libc = ctypes.CDLL(ctypes.util.find_library("c")) processor = platform.processor() ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/hcqfuzz/spec.py
tinygrad_repo/extra/hcqfuzz/spec.py
import os, random class TestSpec: def prepare(self, device, seed): raise NotImplementedError("prepare must be implemented in the derived class") def get_exec_state(self): raise NotImplementedError("get_exec_state must be implemented in the derived class") def name(self): return self.__class__.__name__ c...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/hcqfuzz/tools.py
tinygrad_repo/extra/hcqfuzz/tools.py
import pickle, datetime, os, tempfile, subprocess, zipfile, importlib.util from extra.hcqfuzz.spec import TestSpec from tinygrad.helpers import getenv BASE_DIR = os.path.dirname(os.path.abspath(__file__)) TEST_DIR = os.path.join(BASE_DIR, "tests") REPORTS_DIR = os.path.join(BASE_DIR, "reports") def collect_tests(): ...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/hcqfuzz/fuzzer.py
tinygrad_repo/extra/hcqfuzz/fuzzer.py
import os, random, subprocess, shlex, datetime, time, signal from extra.hcqfuzz.tools import create_report, on_start_run, collect_tests, init_log, log from extra.hcqfuzz.spec import AMSpec def run_test(dev, test): on_start_run(dev, test) dev_env = dev.get_exec_state() test_env, cmd, timeout = test.get_exec_stat...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/hcqfuzz/tests/bert.py
tinygrad_repo/extra/hcqfuzz/tests/bert.py
from extra.hcqfuzz.spec import TestSpec import random bert_train_params = { "DEFAULT_FLOAT": "HALF", "SUM_DTYPE": "HALF", "GPUS": 6, "BS": 96, "EVAL_BS": 96, "FUSE_ARANGE": 1, "BASEDIR": "/raid/datasets/wiki", } class TrainBert(TestSpec): def prepare(self, dev, seed): random.seed(seed) self.e...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/hcqfuzz/tests/resnet.py
tinygrad_repo/extra/hcqfuzz/tests/resnet.py
from extra.hcqfuzz.spec import TestSpec import random resnet_train_params = { "DEFAULT_FLOAT": "HALF", "SUM_DTYPE": "HALF", "GPUS": 6, "BS": 1536, "EVAL_BS": 192, "TRAIN_BEAM": 4, "IGNORE_JIT_FIRST_BEAM": 1, "BEAM_UOPS_MAX": 2000, "BEAM_UPCAST_MAX": 96, "BEAM_LOCAL_MAX": 1024, "BEAM_MIN_PROGRESS"...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false
ajouatom/openpilot
https://github.com/ajouatom/openpilot/blob/b0eab6e8de2d57522b657426fbb794f2d736c75c/tinygrad_repo/extra/hcqfuzz/tests/hcq.py
tinygrad_repo/extra/hcqfuzz/tests/hcq.py
from extra.hcqfuzz.spec import TestSpec import random class HCQSignalFuzzer(TestSpec): def prepare(self, dev, seed): random.seed(seed) self.env = { "GPUS": random.choice([2, 3, 4, 5, 6]), "ITERS": random.randint(1000000, 10000000), "SEED": seed, } self.cmd = "python3 test/external...
python
MIT
b0eab6e8de2d57522b657426fbb794f2d736c75c
2026-01-05T07:04:53.428285Z
false