This file contains 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
[[package]] | |
name = "absl-py" | |
version = "1.2.0" | |
description = "Abseil Python Common Libraries, see https://github.com/abseil/abseil-py." | |
category = "main" | |
optional = false | |
python-versions = ">=3.6" | |
[[package]] | |
name = "alabaster" |
This file contains 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
/* collapsing multiple levels of interpreters */ | |
object TestMeta3 { | |
abstract class Exp | |
case class Lit(n:Int) extends Exp | |
case class Sym(s:String) extends Exp | |
case class Var(n:Int) extends Exp | |
case class App(e1:Exp, e2:Exp) extends Exp | |
case class Lam(e:Exp) extends Exp |
This file contains 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
# Recursively wraps function calls with the below generated function call and inserts the context argument. | |
function remix!(ir, hooks = false) | |
pr = IRTools.Pipe(ir) | |
new = argument!(pr) | |
for (v, st) in pr | |
ex = st.expr | |
ex isa Expr && ex.head == :call && begin | |
if !(ex.args[1] isa GlobalRef && (ex.args[1].mod == Base || ex.args[1].mod == Core)) | |
args = copy(ex.args) | |
ex = Expr(:call, :remix!, new, ex.args...) |
This file contains 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 julia | |
# Check if Revise is installed. | |
using Pkg | |
try | |
Pkg.status("Revise") | |
catch e | |
error("\n\033[0;31mRevise not installed to your global environment. Please install Revise.\033[0m\n\033[0;32mUse 'using Pkg; Pkg.add(\"Revise\")' at REPL.\033[0m\n") | |
end | |
using Revise |
This file contains 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 ReverseModeADwithContexts | |
using Cassette | |
Cassette.@context J; # J is the notation for the function which generates pullbacks (the lambda terms you see below) | |
# Equivalent to gradient tape. | |
mutable struct ReverseTrace | |
gradient_tape::Array{Function, 1} | |
ReverseTrace() = new([]) |
This file contains 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
-- Autodiff using algebraic effects | |
-- Simple reverse mode with a gradient tape | |
use .base | |
ability Differentiable where | |
cos : Float -> Float | |
sin : Float -> Float | |
exp : Float -> Float |