Skip to content

Commit 296e37e

Browse files
authored
cherry-picked improvements + fixes from jr/mnist (including compat fixes for v0.6) (#47)
* minor broadcast improvements * refactor code for cleanliness + add some reduction methods * v0.6 broadcast dispatch compat fix * circumvent world-age problems in v0.6 tests * fix accidental method overwrites and NTuple usage in v0.6 * bump dependency versions to include v0.6 fixes * add docs note mentioning world-age restriction for compiled tapes * fix v0.6 method ambiguities * use isapprox instead test_approx_eq_eps * fix typo * remove unused type parameter * test only against tagged versions of DiffBase (ref JuliaDiff/ForwardDiff.jl#185) * get tests passing on v0.5 again * add PkgEval badges to README
1 parent 69dd923 commit 296e37e

25 files changed

+1060
-925
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ notifications:
99
email: false
1010
script:
1111
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
12-
- julia -e 'Pkg.clone(pwd()); Pkg.build("ReverseDiff"); Pkg.checkout("DiffBase"); Pkg.test("ReverseDiff"; coverage=true)'
12+
- julia -e 'Pkg.clone(pwd()); Pkg.build("ReverseDiff"); Pkg.test("ReverseDiff"; coverage=true)'
1313
after_success:
1414
# push coverage results to Coveralls
1515
- julia -e 'cd(Pkg.dir("ReverseDiff")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# ReverseDiff
22

33
[![Build Status](https://travis-ci.org/JuliaDiff/ReverseDiff.jl.svg?branch=master)](https://travis-ci.org/JuliaDiff/ReverseDiff.jl)
4+
[![ReverseDiff](http://pkg.julialang.org/badges/ReverseDiff_0.5.svg)](http://pkg.julialang.org/?pkg=ReverseDiff)
5+
[![ReverseDiff](http://pkg.julialang.org/badges/ReverseDiff_0.6.svg)](http://pkg.julialang.org/?pkg=ReverseDiff)
46
[![Coverage Status](https://coveralls.io/repos/github/JuliaDiff/ReverseDiff.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaDiff/ReverseDiff.jl?branch=master)
57

68
[**Go To ReverseDiff's Documentation**](http://www.juliadiff.org/ReverseDiff.jl/)

REQUIRE

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
julia 0.5
2-
DiffBase 0.0.2
3-
ForwardDiff 0.3.2
4-
Calculus 0.1.15
2+
DiffBase 0.0.3
3+
ForwardDiff 0.3.4
4+
Calculus 0.2.0

src/ReverseDiff.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ const SKIPPED_BINARY_SCALAR_FUNCS = (:isequal, :isless, :<, :>, :(==), :(!=), :(
3030
include("tape.jl")
3131
include("tracked.jl")
3232
include("macros.jl")
33+
include("derivatives/propagation.jl")
3334
include("derivatives/scalars.jl")
34-
include("derivatives/linalg.jl")
3535
include("derivatives/elementwise.jl")
36+
include("derivatives/linalg/arithmetic.jl")
37+
include("derivatives/linalg/reductions.jl")
38+
include("derivatives/linalg/special.jl")
3639
include("api/utils.jl")
3740
include("api/Config.jl")
3841
include("api/tape.jl")

src/api/Config.jl

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ function JacobianConfig{D}(output::AbstractArray{D}, input::Tuple, tp::RawTape =
105105
return _JacobianConfig(cfg_input, cfg_output, tp)
106106
end
107107

108+
# we dispatch on V<:Real here because RawTape is actually also an AbstractArray
108109
function JacobianConfig{D,V<:Real}(output::AbstractArray{D}, input::AbstractArray{V}, tp::RawTape = RawTape())
109110
cfg_input = track(similar(input), D, tp)
110111
cfg_output = track!(similar(output, TrackedReal{D,D,Void}), output, tp)

src/api/gradients.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ function gradient!(result, f, input, cfg::GradientConfig = GradientConfig(input)
4444
return result
4545
end
4646

47-
#############################
47+
###########################
4848
# Executing GradientTapes #
49-
#############################
49+
###########################
5050

5151
"""
5252
ReverseDiff.gradient!(tape::Union{GradientTape,CompiledGradient}, input)

src/api/hessians.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ function hessian!(result::DiffResult, f, input::AbstractArray,
5656
return result
5757
end
5858

59-
############################
59+
##########################
6060
# Executing HessianTapes #
61-
############################
61+
##########################
6262

6363
"""
6464
ReverseDiff.hessian!(tape::Union{HessianTape,CompiledHessian}, input)

src/api/jacobians.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ function jacobian!(result, f!, output, input, cfg::JacobianConfig = JacobianConf
8080
return result
8181
end
8282

83-
#############################
83+
###########################
8484
# Executing JacobianTapes #
85-
#############################
85+
###########################
8686

8787
"""
8888
ReverseDiff.jacobian!(tape::Union{JacobianTape,CompiledJacobian}, input)

src/api/tape.jl

+8-3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ object can be passed to any API methods that accept `t`.
7373
In many cases, compiling `t` can significantly speed up execution time. Note that the longer
7474
the tape, the more time compilation may take. Very long tapes (i.e. when `length(t)` is on
7575
the order of 10000 elements) can take a very long time to compile.
76+
77+
Note that this function calls `eval` in the `current_module()` to generate functions
78+
from `t`. Thus, the returned `Compiled*` type will only be useable once the world-age
79+
counter has caught up with the world-age of the `eval`'d functions (i.e. once the call
80+
stack has bubbled up to top level).
7681
"""
7782
function compile(t::AbstractTape)
7883
return Compiled(typeof(t), t.func, t.input, t.output,
@@ -93,7 +98,7 @@ The arguments to `ReverseDiff.compile_gradient` are the same as the arguments to
9398
9499
The usage restrictions on the returned function are the same as the usage restrictions
95100
for calling `gradient!(result, tape, input)` where `tape` is a compiled `GradientTape`;
96-
see `ReverseDiff.compile` for details.
101+
see `ReverseDiff.compile` for details (including an important note on world-age).
97102
"""
98103
function compile_gradient(f, args...)
99104
tape = compile(GradientTape(f, args...))
@@ -115,7 +120,7 @@ this means `ReverseDiff.compile_jacobian` also supports target functions of the
115120
116121
The usage restrictions on the returned function are the same as the usage restrictions
117122
for calling `jacobian!(result, tape, input)` where `tape` is a compiled `JacobianTape`;
118-
see `ReverseDiff.compile` for details.
123+
see `ReverseDiff.compile` for details (including an important note on world-age).
119124
"""
120125
function compile_jacobian(f, args...)
121126
tape = compile(JacobianTape(f, args...))
@@ -135,7 +140,7 @@ The arguments to `ReverseDiff.compile_hessian` are the same as the arguments to
135140
136141
The usage restrictions on the returned function are the same as the usage restrictions
137142
for calling `hessian!(result, tape, input)` where `tape` is a compiled `HessianTape`;
138-
see `ReverseDiff.compile` for details.
143+
see `ReverseDiff.compile` for details (including an important note on world-age).
139144
"""
140145
function compile_hessian(f, args...)
141146
tape = compile(HessianTape(f, args...))

0 commit comments

Comments
 (0)