Skip to content

Instantly share code, notes, and snippets.

View j2kun's full-sized avatar
💭
Math math math math math math math

Jeremy Kun j2kun

💭
Math math math math math math math
View GitHub Profile
@j2kun
j2kun / utils.py
Created October 30, 2024 06:00
Utils for social media syndication
from collections import deque, defaultdict
from itertools import zip_longest
import datetime
import os
import pathlib
import re
import subprocess
import marko
import os
import pathlib
import pprint
import re
import subprocess
import fire
import marko
from mastodon import Mastodon
@j2kun
j2kun / out.mlir
Created March 3, 2024 04:52
out.mlir after --straight-line-vectorize
module {
func.func @box_blur(%arg0: !secret.secret<tensor<4096xi16>>) -> !secret.secret<tensor<4096xi16>> {
%cst = arith.constant dense<4096> : tensor<64xindex>
%cst_0 = arith.constant dense<[49, 16, 62, 7, 45, 4, 25, 11, 37, 58, 29, 21, 50, 41, 33, 54, 46, 48, -1, 61, 17, 3, 10, 26, 6, 34, 57, 38, 22, 53, 30, 42, 31, 60, 47, 2, 18, 14, 5, 39, 13, 9, 23, 52, 27, 56, 35, 43, 19, 15, 8, 44, 40, 12, 1, 24, 20, 51, 28, 59, 36, 32, 55]> : tensor<63xindex>
%cst_1 = arith.constant dense<4096> : tensor<128xindex>
%cst_2 = arith.constant dense<"0x1D0000000000000004000000000000001000000000000000040000000000000010000000000000003A000000000000003A000000000000003E000000000000003E0000000000000036000000000000000B0000000000000019000000000000002D0000000000000007000000000000000B0000000000000036000000000000002D000000000000002100000000000000070000000000000021000000000000003200000000000000290000000000000011000000000000001500000000000000250000000000000029000000000000001500000000000000250000000000000032000000000000
// bazel run //tools:heir-opt -- --secretize=entry-function=box_blur --wrap-generic --canonicalize --cse --affine-loop-unroll=unroll-factor=2 --affine-loop-unroll=unroll-factor=2 --canonicalize --cse --affine-loop-unroll=unroll-factor=64 --canonicalize --cse $PWD/tests/simd/box_blur.mlir > out.mlir
module {
func.func @box_blur(%arg0: !secret.secret<tensor<4096xi16>>) -> !secret.secret<tensor<4096xi16>> {
%c63 = arith.constant 63 : index
%c62 = arith.constant 62 : index
%c61 = arith.constant 61 : index
%c60 = arith.constant 60 : index
%c59 = arith.constant 59 : index
%c58 = arith.constant 58 : index
@j2kun
j2kun / search.py
Created February 17, 2024 17:59
search GitHub code filtering on star count of repository
import argparse
from github import Github, Auth
parser = argparse.ArgumentParser(description="Search for code on GitHub")
parser.add_argument('query')
parser.add_argument('-o', '--output_file')
parser.add_argument('-m', '--max_iters')
args = parser.parse_args()
@j2kun
j2kun / gist:46ee5fdd21ee6d660df1f4ab83dcdfa7
Created November 18, 2023 05:49
bazel run //tools:heir-opt -- --pass-pipeline='builtin.module(func.func(secret.generic(yosys-optimizer)), secret-distribute-generic)' $PWD/tests/yosys_optimizer/add_one_generic.mlir
module {
func.func @add_one(%arg0: !secret.secret<i8>) -> !secret.secret<i8> {
%c1_i8 = arith.constant 1 : i8
%false = arith.constant false
%0 = secret.generic ins(%arg0 : !secret.secret<i8>) {
^bb0(%arg1: i8):
%32 = comb.extract %arg1 from 0 : (i8) -> i1
secret.yield %32 : i1
} -> !secret.secret<i1>
%1 = comb.extract %c1_i8 from 0 : (i8) -> i1
@j2kun
j2kun / gist:146b190ba53ed6bf5aa2afa63f39c6c8
Created November 18, 2023 05:48
bazel run //tools:heir-opt -- --pass-pipeline='builtin.module(func.func(secret.generic(yosys-optimizer)))' $PWD/tests/yosys_optimizer/add_one_generic.mlir
module {
func.func @add_one(%arg0: !secret.secret<i8>) -> !secret.secret<i8> {
%c1_i8 = arith.constant 1 : i8
%0 = secret.generic ins(%arg0, %c1_i8 : !secret.secret<i8>, i8) {
^bb0(%arg1: i8, %arg2: i8):
%1 = comb.extract %arg1 from 0 : (i8) -> i1
%2 = comb.extract %arg2 from 0 : (i8) -> i1
%false = arith.constant false
%3 = comb.truth_table %1, %2, %false -> 8 : ui8
%4 = comb.extract %arg1 from 1 : (i8) -> i1
@j2kun
j2kun / otuput.ll
Created October 30, 2023 21:41
bazel run //tools:tutorial-opt -- --poly-to-llvm $PWD/tests/poly_to_llvm.mlir | ./bazel-bin/external/llvm-project/mlir/mlir-translate --mlir-to-llvmir
; ModuleID = 'LLVMDialectModule'
source_filename = "LLVMDialectModule"
@__constant_3xi32 = private constant [3 x i32] [i32 2, i32 3, i32 4], align 64
@__constant_10xi32 = private constant [10 x i32] zeroinitializer, align 64
declare ptr @malloc(i64)
declare void @free(ptr)
@j2kun
j2kun / PolyCanonicalize.cpp.inc
Created September 19, 2023 21:59
Generated rewrite pattern for lifting complex conjugate through polynomial evaluation
/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|* *|
|* Rewriters *|
|* *|
|* Automatically generated file, do not edit! *|
|* *|
\*===----------------------------------------------------------------------===*/
/* Generated from:
lib/Dialect/Poly/PolyPatterns.td:8
@j2kun
j2kun / PolyOps.cpp.inc
Created August 18, 2023 23:59
Poly ops generated code
/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|* *|
|* Op Definitions *|
|* *|
|* Automatically generated file, do not edit! *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifdef GET_OP_LIST
#undef GET_OP_LIST