Skip to content

Instantly share code, notes, and snippets.

View jrevels's full-sized avatar

Jarrett Revels jrevels

View GitHub Profile
using Test
using Cassette: @overdub, @context, @pass
f27078(T::Type{S}) where {S} = isa(T, UnionAll) ? f27078(T.body) : T
T27078 = Vector{Vector{T}} where T
@test f27078(T27078) === T27078.body
@context Ctx
@overdub(Ctx(), convert(Tuple{Vararg{Float64}}, (1,2)))
bar(T) = isa(T, UnionAll) ? bar(T.body) : T
#!/bin/bash -eo pipefail
cd .. &&
mv project julia-src &&
/tmp/julia/bin/julia -e 'Base.require(Main, :InteractiveUtils).versioninfo()' &&
/tmp/julia/bin/julia --sysimage-native-code=no -e 'true' &&
/tmp/julia/bin/julia-debug --sysimage-native-code=no -e 'true' &&
pushd /tmp/julia/share/julia/test &&
/tmp/julia/bin/julia --check-bounds=yes runtests.jl all --skip Sockets | bar -i 30 &&
/tmp/julia/bin/julia --check-bounds=yes runtests.jl LibGit2/online OldPkg/pkg Pkg/pkg download &&
popd &&
./.freebsdci.sh runtests
in dir /usr/home/julia/julia-fbsd-buildbot/worker/11rel-amd64/build (timeout 1200 secs)
watching logfiles {}
argv: ['./.freebsdci.sh', 'runtests']
environment:
BLOCKSIZE=K
COLORFGBG=default;default
COLORTERM=rxvt-xpm
DESKTOP_STARTUP_ID=awesome/urxvt/1040-0-abeing_TIME707846
EDITOR=vi
using Test, SparseArrays, LinearAlgebra, Random
N, M, p = 10, 12, 0.3;
Q, X, Y, Z = sprand(N, M, p), sprand(Float32, N, M, p), sprand(N, M, p), sprand(N, M, p);
f(x, y, z) = x + y + z + 1;
broadcast!(+, Q, X, Y, Z); # warmup for @allocated
broadcast!(*, Q, X, Y, Z); # warmup for @allocated
broadcast!(f, Q, X, Y, Z); # warmup for @allocated
This file has been truncated, but you can view the full file.
Some tests did not pass: 117 passed, 1 failed, 0 errored, 4 broken.spawn: Test Failed at /data/jrevels/juliadev/test/spawn.jl:479
Expression: sort(readlines(#= /data/jrevels/juliadev/test/spawn.jl:479 =# @cmd("\$lscmd -A"))) == sort(readdir())
Evaluated: [".gitignore", "Makefile", "TestHelpers.jl", "abstractarray.jl", "ambiguous.jl", "arrayops.jl", "asyncmap.jl", "backtrace.jl", "bigfloat.jl", "bigint.jl" … "testdefs.jl", "testenv.jl", "threads.jl", "triplequote.jl", "tuple.jl", "unicode", "util", "vecelement.jl", "version.jl", "worlds.jl"] == [".gitignore", ".sha", "Makefile", "TestHelpers.jl", "abstractarray.jl", "ambiguous.jl", "arrayops.jl", "asyncmap.jl", "backtrace.jl", "bigfloat.jl" … "testdefs.jl", "testenv.jl", "threads.jl", "triplequote.jl", "tuple.jl", "unicode", "util", "vecelement.jl", "version.jl", "worlds.jl"]
Stacktrace:
[1] record(::Test.DefaultTestSet, ::Test.Fail) at /data/jrevels/juliadev/usr/share/julia/stdlib/v0.7/Test/src/Test.jl:741
[2] (::getfield(Main, Symbol("##44#50")))(
@jrevels
jrevels / recursive_ad.jl
Last active February 23, 2018 16:57
recursive_ad.jl
# This script requires an up-to-date ForwardDiff, ReverseDiff, and Julia v0.6 installation.
using ForwardDiff, ReverseDiff
D_f(f) = x::Number -> ForwardDiff.derivative(f, x)
# ReverseDiff's API only supports array inputs, so we just wrap our scalar input in a
# 1-element array and extract our scalar derivative from the returned gradient array
D_r(f) = x::Number -> ReverseDiff.gradient(y -> f(y[1]), [x])[1]
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
using BenchmarkTools
using ReverseDiff: @forward, GradientTape, gradient!, compile
# Similar to XDiff's @diff_rule, except it gets the derivative automatically via forward mode.
# In future versions, `@forward` will no longer be necessary.
@forward logistic(x::Real) = 1 / (1 + exp(-x))
# This is how I would write this for ReverseDiff usage if parser fusion didn't mess things up.
# In the future, this form will be performant (all the pieces already exist, they just have
# to be hooked up).
using ForwardDiff
using BenchmarkTools
function gen_beta_kl_obj(alpha2, beta2)
lgamma_alpha2 = lgamma(alpha2)
lgamma_beta2 = lgamma(beta2)
return x -> begin
alpha1, beta1 = x
alpha_diff = alpha1 - alpha2
beta_diff = beta1 - beta2
function tupexpr(f, N)
ex = Expr(:tuple, [f(i) for i=1:N]...)
return quote
@inbounds return $(ex)
end
end
@inline iszero_tuple(::Tuple{}) = true
@inline zero_tuple(::Type{Tuple{}}) = tuple()
@inline one_tuple(::Type{Tuple{}}) = tuple()