Skip to content

Instantly share code, notes, and snippets.

View svaniksharma's full-sized avatar

Svanik Sharma svaniksharma

View GitHub Profile
@svaniksharma
svaniksharma / ggml_cont_permute.cpp
Created May 31, 2025 03:17
Using `ggml_cont`
#include "ggml-cpu.h"
#include "ggml.h"
#include <iostream>
void print_tensor(struct ggml_tensor *tensor) {
for (size_t i = 0; i < tensor->ne[3]; i++) {
for (size_t k = 0; k < tensor->ne[2]; k++) {
for (size_t j = 0; j < tensor->ne[1]; j++) {
for (size_t l = 0; l < tensor->ne[0]; l++) {
std::cout << ggml_get_i32_nd(tensor, l, j, k, i) << " ";
@svaniksharma
svaniksharma / matrix.zig
Created May 7, 2023 05:42
Optimizing Matrix Multiplication in Zig
const std = @import("std");
const mem = std.mem;
const meta = std.meta;
const math = std.math;
const Vector = meta.Vector;
const expect = std.testing.expect;
fn generateSquareMatrix(N: usize, allocator: mem.Allocator, gen_rand: bool) ![][]f64 {
var matrix: [][]f64 = undefined;
matrix = try allocator.alloc([]f64, N);
@kconner
kconner / macOS Internals.md
Last active June 7, 2025 16:40
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@moyix
moyix / check_for_ffast_math.py
Last active October 29, 2022 11:42
Hacky script to check for the set_fast_math constructor in an executable/shared library using objdump
#!/usr/bin/env python
import subprocess
import re
import sys
def get_init_array(filename):
# Call objdump -s -j .init_array <filename> to get the contents of the .init_array section
try:
objdump_output = subprocess.check_output(['objdump', '-s', '-j', '.init_array', filename], stderr=subprocess.STDOUT)
@karpathy
karpathy / stablediffusionwalk.py
Last active May 27, 2025 23:31
hacky stablediffusion code for generating videos
"""
stable diffusion dreaming
creates hypnotic moving videos by smoothly walking randomly through the sample space
example way to run this script:
$ python stablediffusionwalk.py --prompt "blueberry spaghetti" --name blueberry
to stitch together the images, e.g.:
$ ffmpeg -r 10 -f image2 -s 512x512 -i blueberry/frame%06d.jpg -vcodec libx264 -crf 10 -pix_fmt yuv420p blueberry.mp4
@ianmackinnon
ianmackinnon / match.c
Created August 8, 2012 12:01
C Regex multiple matches and groups example
# gcc -Wall -o match match.c && ./match
#
#include <stdio.h>
#include <string.h>
#include <regex.h>