Skip to content

Instantly share code, notes, and snippets.

@jrevels
Created November 7, 2017 18:33
Show Gist options
  • Save jrevels/fff056ea318923e0cf96bbb91e1a5e7f to your computer and use it in GitHub Desktop.
Save jrevels/fff056ea318923e0cf96bbb91e1a5e7f to your computer and use it in GitHub Desktop.
using Cassette
function rosenbrock(x)
a = one(eltype(x))
b = 100.0
result = zero(a)
for i in 1:length(x)-1
result += (a - x[i])^2 + b*(x[i+1] - x[i]^2)^2
end
return result
end
Cassette.@context Ctx
f(x) = Cassette.@execute Ctx rosenbrock(x)
x = rand(1000)
# ideally, f(x) should have nearly the same performance as rosenbrock(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment