Skip to content

Instantly share code, notes, and snippets.

View jackalcooper's full-sized avatar

Shenghang Tsai jackalcooper

View GitHub Profile
defmodule Beaver.Nx.Defn do
require Beaver
import Beaver, only: [mlir: 1]
require Beaver.MLIR.Dialect.Func
alias Beaver.MLIR
alias Beaver.MLIR.Dialect.{Builtin, Func, TOSA}
import Builtin, only: :macros
import MLIR, only: :macros
import MLIR.Sigils
from jax import random, pmap
import jax.numpy as jnp
from jax import grad, jit, vmap
import os
os.environ["XLA_FLAGS"] = "--xla_force_host_platform_device_count=8"
x = jnp.ones((2, 2))
@pmap
@jackalcooper
jackalcooper / ONEFLOW_CLA
Last active April 29, 2021 09:50 — forked from CLAassistant/SAP_CLA
SAP Individual Contributor License Agreement
### OneFlow Individual Contributor License Agreement
Thank you for your interest in contributing to open source software projects (“Projects”) made available by OneFlow or its affiliates (“OneFlow”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to OneFlow in respect of any of the Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact contact@oneflow.org.
You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions.
**Copyright License.** You hereby grant, and agree to grant, to OneFlow a non-exclusive, perpetual, ir
@jackalcooper
jackalcooper / faye_websocket.ex
Last active November 3, 2021 18:33
Elixir Faye Websocket client example, heartbeat and subscription
defmodule Tuna.Client.FayeWebsocket do
import Tuna.Ewhine
require Logger
import Tuna.Ewhine
use Maxwell.Builder, ~w(get post)a
adapter Maxwell.Adapter.Ibrowse
middleware Maxwell.Middleware.BaseUrl, endpoint
middleware Maxwell.Middleware.Headers, %{
"Content-Type" => "application/json",
# "User-Agent" => "Subway",
@jackalcooper
jackalcooper / latency.markdown
Created October 14, 2016 06:47 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs