This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| import torch.nn as nn | |
| import torch.nn.functional as F | |
| import torch.optim as optim | |
| import numpy as np | |
| import gym | |
| # Hyperparameters | |
| num_inputs = 4 | |
| num_actions = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| × / | |
| ← → ↔ ⇐ ⇒ ⇔ | |
| ⟵ ⟶ ⟷ ⟸ ⟹ ⟺ | |
| ∀ ∃ | |
| ∂ ∫ | |
| ∈ ∊ ∉ | |
| ∏ ∑ | |
| ∙ ⋅ | |
| √ | |
| ∞ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| class ModelArgs: | |
| dim = 288 | |
| n_layers = 6 | |
| n_heads = 6 | |
| norm_eps = 1e-6 | |
| def build_cos_sin_cache(head_dim, seq_len, base=10000): | |
| theta = 1. / (base ** (np.arange(0, head_dim, 2, dtype=np.float32) / head_dim)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| N_inp = 64 | |
| N_out = 64 | |
| d = 128 | |
| Q = np.random.randn(N_out, d) | |
| K = np.random.randn(N_inp, d) | |
| V = np.random.randn(N_inp, d) | |
| O = np.random.randn(N_out, d) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| from threading import Barrier, Thread | |
| from collections import namedtuple | |
| dim3 = namedtuple("dim3", ["x", "y", "z"], defaults=(1, 1)) | |
| TILE = 16 | |
| def cdiv(a, b): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name adventofcode daylight mode | |
| // @namespace Violentmonkey Scripts | |
| // @match https://adventofcode.com/* | |
| // @grant none | |
| // @version 1.0 | |
| // @author scturtle | |
| // @description 2023/11/27 16:52:13 | |
| // ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import re | |
| from pathlib import Path | |
| from typing import List | |
| MARK = "// -----// IR Dump" | |
| PAT = re.compile(r'IR Dump \w+ (?:.*::)?(\w+)') | |
| def main(infile: Path, outdir: Path): | |
| assert infile.exists(), f'{infile} not exists' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import time | |
| import random | |
| import struct | |
| import urllib.request | |
| from pathlib import Path | |
| # https://www.amiiboapi.com/api/amiibo/ | |
| database = json.load(open("amiibos.json")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| from torch import nn | |
| # import torch_mlir | |
| from torch_mlir.passmanager import PassManager | |
| from torch_mlir.dialects.torch.importer.jit_ir import ClassAnnotator, ModuleBuilder | |
| torch.manual_seed(42) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| from torch import nn | |
| import numpy as np | |
| # https://github.com/arasdar/DL/blob/master/uri-dl/uri-dl-hw-2/assignment2/cs231n/layers.py | |
| # https://github.com/brandontrabucco/conv-python/blob/master/main.py | |
| def get_output_shape(x, kernel, stride): | |
| (_, _, ih, iw), (kh, kw) = x.shape, kernel | |
| oh = (ih - kh) // stride + 1 |