This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto a = op::uniform(-20.0, 20.0, {2, 5}).astype(dtype); | |
a.eval(); | |
auto exped = op::exp(a - op::max(a, {-1}, true)); | |
auto fused_softmax = exped / op::sum(exped, {-1}, true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using LatexPrint | |
function fulltabular(A::AbstractArray{T,2}; placement::String="htb",rounding::Int=0, colnames::Vector{String}=Vector{String}(), frontmatter::String="" , caption::String="", title::String="", label::String="", strfirstcol::Bool=false,arraystretch=1) where {T<:Any} | |
(r,c) = size(A) | |
println("\\begin{table}[", placement, "] \\centering") | |
println("\\renewcommand{\\arraystretch}{",arraystretch ,"}") | |
println(frontmatter) | |
if !isempty(title) | |
println("\\caption{", title, "}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Cassette | |
using Logging | |
# wrapper for overdubbing functions | |
struct Overdub{F,C} | |
func::F | |
context::C | |
Overdub(f::F, c::C=nothing) where {F,C} = new{F,C}(f,c) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using InteractiveUtils | |
const Compiler = Core.Compiler | |
function method_match_to_ir(methds, types) | |
if length(methds) != 1 | |
@show methds | |
@assert false | |
end | |
x = methds[1] | |
meth = Core.Main.Base.func_for_method_checked(x[3], types) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TraceCalls | |
using Cassette | |
mutable struct Trace | |
level::Int | |
cutoff::Int | |
end | |
Cassette.@context TraceCtx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const BRAILLE = split("⠀⠁⠂⠄⡀⠈⠐⠠⢀", "") .|> s -> Int(s[1]) | |
function show_any_nonzero(S::SparseMatrixCSC; maxw = displaysize(stdout)[2], maxh = displaysize(stdout)[1]-3) | |
h,w = size(S) | |
h > 4maxh && (w = max(1, (w*4maxh+h÷2)÷h); h = 4maxh) | |
w > 2maxw && (h = max(1, (h*2maxw+w÷2)÷w); w = 2maxw) | |
P = fill(BRAILLE[1], (w+3)÷2, (h+3)÷4) | |
P[end, :].=10 | |
@inbounds for c = 0:w-1, r = 0:h-1 | |
_anynz(S, r*S.m÷h+1, c*S.n÷w+1, (r+1)*S.m÷h, (c+1)*S.n÷w) && |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
import numpy.random as npr | |
import jax.numpy as np | |
from jax import lax | |
from jax import grad, pjit, papply | |
### set up some synthetic data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- The Datafun runtime. | |
module Runtime where | |
import qualified Data.Set as Set | |
import Data.Set (Set) | |
class Eq a => Preord a where | |
(<:) :: a -> a -> Bool | |
class Preord a => Semilat a where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function red_echo() | |
{ | |
tput setaf 1 | |
echo "$*" | |
tput sgr0 | |
} | |
if [[ "$*" == *--help* ]]; then |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.