Skip to content

Instantly share code, notes, and snippets.

@nullhook
nullhook / libtpu.so
Last active January 11, 2024 00:43
libtpu.so symbol dump. google's TPU (v4)?
// BuildID[md5/uuid]=89fd1efde83abcbf9fba1226f6918f47
DYNAMIC SYMBOL TABLE:
0000000000000000 w D *UND* 0000000000000000 __gmon_start__
0000000000000000 w DF *UND* 0000000000000000 (GLIBC_2.2.5) __cxa_finalize
0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.2.5) strlen
0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.2.5) abort
0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.3) __tls_get_addr
0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.2.5) memchr
0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.2.5) getenv
0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.2.5) strcasecmp
@nullhook
nullhook / compute.cpp
Last active February 16, 2024 16:43
compute in metal
#include <iostream>
#define NS_PRIVATE_IMPLEMENTATION
#define CA_PRIVATE_IMPLEMENTATION
#define MTL_PRIVATE_IMPLEMENTATION
#include "Metal.hpp"
MTL::Buffer* outputs;
MTL::Buffer* input0;
@nullhook
nullhook / linearized_bufs
Last active December 8, 2023 11:57
tinygrad buffers at each level
[MemBuffer(idx=0, dtype=dtypes.float, st=ShapeTracker(views=(View(shape=(1, 3, 224, 224), strides=(0, 50176, 224, 1), offset=0, mask=None, contiguous=True),))), ConstBuffer(val=1.5707963267948966, dtype=dtypes.float, st=ShapeTracker(views=(View(shape=(1, 3, 224, 224), strides=(0, 0, 0, 0), offset=0, mask=None, contiguous=False),))), MemBuffer(idx=1, dtype=dtypes.float, st=ShapeTracker(views=(View(shape=(1, 3, 224, 224), strides=(0, 50176, 224, 1), offset=0, mask=None, contiguous=True),))), ConstBuffer(val=6.283185307179586, dtype=dtypes.float, st=ShapeTracker(views=(View(shape=(1, 3, 224, 224), strides=(0, 0, 0, 0), offset=0, mask=None, contiguous=False),))), ConstBuffer(val=1.0, dtype=dtypes.float, st=ShapeTracker(views=(View(shape=(1, 3, 224, 224), strides=(0, 0, 0, 0), offset=0, mask=None, contiguous=False),))), MemBuffer(idx=1, dtype=dtypes.float, st=ShapeTracker(views=(View(shape=(1, 3, 224, 224), strides=(0, 50176, 224, 1), offset=150528, mask=None, contiguous=False),))), ConstBuffer(val=0.6931471805599
@nullhook
nullhook / chars.cc
Last active June 9, 2021 03:17
char type conversions in c++
#include <iostream>
#include <locale>
#include <string>
#include <fstream>
#include <codecvt>
// utf8/utf16/utf32 can be directly written to file without conversions
// sizeof(T) gives you bytes of the type
// .size() .length() gives count of chars
// if char16_t is stored the open the file with utf16 encoding