Want to expose your machine learning model to the network? Use io.serve:
import * as sm from '@shumai/shumai'
import { model } from './model'| import torch | |
| def cudagraph(f): | |
| _graphs = {} | |
| def f_(*args): | |
| key = hash(tuple(tuple(a.shape) for a in args)) | |
| if key in _graphs: | |
| wrapped, *_ = _graphs[key] | |
| return wrapped(*args) | |
| g = torch.cuda.CUDAGraph() |
| console.log("Oh no! bun hit an error\n") | |
| const report = 'bun report blah blah blah' | |
| const url = `https://duckduckgo.com/?q=${report}` | |
| const str = '[click to upload report]' | |
| console.log(`\u001b]8;;${url}\u001b\\${str}\u001b]8;;\u001b\\`) |
| read -p "this script will remove libarrayfire from your system and install all requirements to build from source. continue? [Y/n]" -n 1 -r | |
| echo | |
| if [[ $REPLY =~ ^[Yy]$ ]] | |
| then | |
| sudo apt remove libarrayfire-dev libarrayfire-cpu3 libarrayfire-cpu-dev | |
| sudo apt install -y libblas-dev liblapack-dev liblapacke-dev libfftw3-dev libboost-all-dev cmake make g++ | |
| cd /tmp | |
| rm -rf arrayfire | |
| git clone https://github.com/arrayfire/arrayfire.git | |
| cd arrayfire |
| # conv bwd implemented with fwd functions | |
| import torch | |
| import torch.nn.functional as F | |
| def dconv2d(grad, x, w, stride, padding, groups): | |
| batch = grad.shape[0] | |
| channel_out = grad.shape[1] | |
| channel_in = x.shape[1] |
| # example of backward pass implemented with only forward functions | |
| import torch | |
| import torch.nn.functional as F | |
| def dconv(grad, x, w, stride, padding, groups): | |
| batch = grad.shape[0] | |
| channel_out = grad.shape[1] | |
| channel_in = x.shape[1] |
| # examples of backward passes implemented with fwd functions | |
| import torch | |
| import torch.nn.functional as F | |
| def simple(): | |
| print("simple") | |
| x = torch.randn(1, 1, 4, 4) | |
| x.requires_grad = True |
| import os | |
| for cmd in ["add", "mm"]: | |
| print(cmd) | |
| for n in range(0, 14): | |
| N = 2**n | |
| best_cpu = 0 | |
| best_cuda = 0 | |
| for thread in [1, 2, 4, 8, 16, 32, 64, 80]: | |
| full_cmd = f"OMP_NUM_THREADS={thread} python comp.py {cmd} {N}" |
| import torch | |
| import time | |
| import sys | |
| fn = sys.argv[1] | |
| N = int(sys.argv[2]) | |
| iters = 1000 | |
| mps = torch.device("mps") | |
| a = torch.randn(N, N) |
| #include <cstdint> | |
| extern "C" { | |
| void init() {} | |
| int64_t bytesUsed() { | |
| return 0; | |
| } |