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
#map = affine_map<(d0, d1) -> (d0 * 16 + d1)>
#map1 = affine_map<(d0, d1) -> (d1)>
#map2 = affine_map<(d0) -> (d0)>
#map3 = affine_map<(d0, d1, d2) -> (d0, d2)>
#map4 = affine_map<(d0, d1, d2) -> (d2, d1)>
#map5 = affine_map<(d0, d1, d2) -> (d0, d1)>
module {
func.func @matmul(%arg0: !secret.secret<tensor<1x16xf32>> {tensor_ext.layout = #tensor_ext.layout<layout = (d0, d1) -> (d0 * 16 + d1)>}) -> (!secret.secret<tensor<1x16xf32>> {tensor_ext.layout = #tensor_ext.layout<layout = (d0, d1) -> (d1)>}) {
%cst = arith.constant dense<"0x5036CB3DE147C3BEE4A9393E47C021BE40F376BFA1078D3E8D53EB3DD6E0493EEFFC3CBFBEB947BE4597B5BBD185903E9B9C1BBEEB0713BD23B418BF66736C3EED693F3E584F72BF3CB9E83EBD0E8D3E4D87BDBE5A0439BFBE94AABECDCA91BE695FA93E870B93BE576920BF6294083F4C08633DCBACC6BDD8C9243FABF141BE647E8E3F27116D3DBA00FA3DDDD4C93EA96AA03E1FD4A7BE3C3297BD387D02BFA695923E3402CB3E6A4E0F3E8D0700BF195E3E3ECA2E0EBF6CAA17BE63FE853E1C7029BFAA05383F0DBFF0BEBF82CB3F8D9F843D3640A63F75BF7FBEF615053D1937CB3FC68B41BEEC66B9BED998223F90
#map = affine_map<(d0, d1) -> (d0 * 32 + d1)>
#map1 = affine_map<(d0) -> (d0)>
#map2 = affine_map<(d0) -> (d0 * 32)>
module {
func.func @insert_conversion(%arg0: !secret.secret<tensor<32x32xi16>> {tensor_ext.layout = #tensor_ext.layout<layout = (d0, d1) -> (d0 * 32 + d1)>}, %arg1: !secret.secret<tensor<32x32xi16>> {tensor_ext.layout = #tensor_ext.layout<layout = (d0, d1) -> (d0 * 32 + d1)>}) -> (!secret.secret<tensor<32xi16>> {tensor_ext.layout = #tensor_ext.layout<layout = (d0) -> (d0)>}) {
%0 = secret.generic ins(%arg0, %arg1 : !secret.secret<tensor<32x32xi16>>, !secret.secret<tensor<32x32xi16>>) attrs = {arg0 = {layout = #map}, arg1 = {layout = #map}, layout = [#map1]} {
^body(%input0: tensor<32x32xi16>, %input1: tensor<32x32xi16>):
%1 = tensor_ext.sum %input0, 0 {layout = [#map1]} : tensor<32x32xi16> -> tensor<32xi16>
%2 = tensor_ext.sum %input1, 1 {layout = [#map2]} : tensor<32x32xi16> -> tensor<32xi16>
%3 = tensor_ext.convert_layout %2 {from_layout = #map2, layout = [#map1],
import argparse
import datetime
import requests
import sys
from scripts import utils as utils
def get_dois_from_page(page, since_days):
posts = page["hits"]
dois = dict()
@j2kun
j2kun / util.py
Created October 30, 2024 22:10
webmention utils
import indieweb_utils
def send_webmention(source_url, target_url, dry_run=False):
print(f"Found a webmention: {source_url} -> {target_url}")
try:
indieweb_utils.discover_webmention_endpoint(source_url)
except Exception as e:
print(f"Error discovering webmention endpoint: {e}")
import datetime
import fire
import marko
from scripts.webmention.utils import send_webmention
from scripts import utils as utils
DATABASE_PATH = "scripts/webmention/outgoing_processed.txt"
@j2kun
j2kun / hn.py
Created October 30, 2024 22:06
from bs4 import BeautifulSoup
from urllib.parse import urlparse
import argparse
import datetime
import pprint
import requests
import sys
from scripts.webmention.utils import send_webmention
"""Add URLs to blogroll database.
scripts/blogroll.txt is a flat file containing URLs and titles of blog posts
I submitted via https://github.com/j2kun/extension-trigger-gh-workflow
Each entry contains two lines: the first line is a URL and the second is a
title extracted from the URL. Entries are separated by a blank line.
Example:
import os
import fire
from atproto import Client, models
from scripts import utils as utils
from scripts import syndication as syndication
# A simple text file with two urls per line
DATABASE_FILE = "scripts/published_bluesky.txt"
BLUESKY_HANDLE = "jeremykun.com"
import os
import time
from scripts import utils as utils
from scripts import syndication as syndication
import fire
import tweepy
# A simple text file with two urls per line
@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