Skip to content

Commit 80de568

Browse files
authored
Merge pull request #94 from JuliaDiff/npr/rename-dne-doesnotexit
Rename `DNE` -> `DoesNotExist`
2 parents f17dcdc + 3097e66 commit 80de568

File tree

13 files changed

+34
-34
lines changed

13 files changed

+34
-34
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1010
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1111

1212
[compat]
13-
ChainRulesCore = "0.3, 0.4"
13+
ChainRulesCore = "0.4"
1414
FiniteDifferences = "^0.7"
1515
julia = "^1.0"
1616

src/rulesets/Base/array.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
function rrule(::typeof(reshape), A::AbstractArray, dims::Tuple{Vararg{Int}})
66
function reshape_pullback(Ȳ)
7-
return (NO_FIELDS, @thunk(reshape(Ȳ, dims)), DNE())
7+
return (NO_FIELDS, @thunk(reshape(Ȳ, dims)), DoesNotExist())
88
end
99
return reshape(A, dims), reshape_pullback
1010
end
1111

1212
function rrule(::typeof(reshape), A::AbstractArray, dims::Int...)
1313
function reshape_pullback(Ȳ)
1414
∂A = @thunk(reshape(Ȳ, dims))
15-
return (NO_FIELDS, ∂A, fill(DNE(), length(dims))...)
15+
return (NO_FIELDS, ∂A, fill(DoesNotExist(), length(dims))...)
1616
end
1717
return reshape(A, dims...), reshape_pullback
1818
end
@@ -63,14 +63,14 @@ end
6363

6464
function rrule(::typeof(fill), value::Any, dims::Tuple{Vararg{Int}})
6565
function fill_pullback(Ȳ)
66-
return (NO_FIELDS, @thunk(sum(Ȳ)), DNE())
66+
return (NO_FIELDS, @thunk(sum(Ȳ)), DoesNotExist())
6767
end
6868
return fill(value, dims), fill_pullback
6969
end
7070

7171
function rrule(::typeof(fill), value::Any, dims::Int...)
7272
function fill_pullback(Ȳ)
73-
return (NO_FIELDS, @thunk(sum(Ȳ)), ntuple(_->DNE(), length(dims))...)
73+
return (NO_FIELDS, @thunk(sum(Ȳ)), ntuple(_->DoesNotExist(), length(dims))...)
7474
end
7575
return fill(value, dims), fill_pullback
7676
end

src/rulesets/Base/base.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
@scalar_rule(abs(x::Complex), Wirtinger(x' / 2Ω, x / 2Ω))
5959
@scalar_rule(hypot(x::Real), sign(x))
6060
@scalar_rule(hypot(x::Complex), Wirtinger(x' / 2Ω, x / 2Ω))
61-
@scalar_rule(rem2pi(x, r::RoundingMode), (One(), DNE()))
61+
@scalar_rule(rem2pi(x, r::RoundingMode), (One(), DoesNotExist()))
6262

6363
@scalar_rule(+(x), One())
6464
@scalar_rule(-(x), -1)

src/rulesets/Base/broadcast.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ end
2424
function rrule(::typeof(broadcast), f, x)
2525
values, derivs = _cast_diff(f, x)
2626
function broadcast_pullback(ΔΩ)
27-
return (NO_FIELDS, DNE(), @thunk(ΔΩ .* derivs))
27+
return (NO_FIELDS, DoesNotExist(), @thunk(ΔΩ .* derivs))
2828
end
2929
return values, broadcast_pullback
3030
end

src/rulesets/Base/mapreduce.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function rrule(::typeof(map), f, xs...)
77
function map_pullback(ȳ)
88
ntuple(length(xs)+2) do full_i
99
full_i == 1 && return NO_FIELDS
10-
full_i == 2 && return DNE()
10+
full_i == 2 && return DoesNotExist()
1111
i = full_i-2
1212
@thunk map(ȳ, xs...) do ȳi, xis...
1313
_, pullback = _checked_rrule(f, xis...)
@@ -39,7 +39,7 @@ for mf in (:mapreduce, :mapfoldl, :mapfoldr)
3939
_, ∂xi = pullback_f(ȳi)
4040
extern(∂xi)
4141
end
42-
(NO_FIELDS, DNE(), DNE(), ∂x)
42+
(NO_FIELDS, DoesNotExist(), DoesNotExist(), ∂x)
4343
end
4444
return y, $pullback_name
4545
end
@@ -67,7 +67,7 @@ end
6767
function rrule(::typeof(sum), f, x::AbstractArray{<:Real}; dims=:)
6868
y, mr_pullback = rrule(mapreduce, f, Base.add_sum, x; dims=dims)
6969
function sum_pullback(ȳ)
70-
return NO_FIELDS, DNE(), last(mr_pullback(ȳ))
70+
return NO_FIELDS, DoesNotExist(), last(mr_pullback(ȳ))
7171
end
7272
return y, sum_pullback
7373
end
@@ -83,7 +83,7 @@ end
8383
function rrule(::typeof(sum), ::typeof(abs2), x::AbstractArray{<:Real}; dims=:)
8484
y = sum(abs2, x; dims=dims)
8585
function sum_abs2_pullback(ȳ)
86-
return (NO_FIELDS, DNE(), @thunk(2.* x))
86+
return (NO_FIELDS, DoesNotExist(), @thunk(2.* x))
8787
end
8888
return y, sum_abs2_pullback
8989
end

src/rulesets/LinearAlgebra/blas.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function rrule(::typeof(BLAS.dot), n, X, incx, Y, incy)
2626
∂X = @thunk scal!(n, ΔΩ, blascopy!(n, Y, incy, _zeros(X), incx), incx)
2727
∂Y = @thunk scal!(n, ΔΩ, blascopy!(n, X, incx, _zeros(Y), incy), incy)
2828
end
29-
return (NO_FIELDS, DNE(), ∂X, DNE(), ∂Y, DNE())
29+
return (NO_FIELDS, DoesNotExist(), ∂X, DoesNotExist(), ∂Y, DoesNotExist())
3030
end
3131
return Ω, blas_dot_pullback
3232
end
@@ -60,7 +60,7 @@ function rrule(::typeof(BLAS.nrm2), n, X, incx)
6060
ΔΩ = extern(ΔΩ)
6161
∂X = scal!(n, ΔΩ / Ω, blascopy!(n, X, incx, _zeros(X), incx), incx)
6262
end
63-
return (NO_FIELDS, DNE(), ∂X, DNE())
63+
return (NO_FIELDS, DoesNotExist(), ∂X, DoesNotExist())
6464
end
6565

6666
return Ω, nrm2_pullback
@@ -92,13 +92,13 @@ function rrule(::typeof(BLAS.asum), n, X, incx)
9292
else
9393
ΔΩ = extern(ΔΩ)
9494
∂X = @thunk scal!(
95-
n,
95+
n,
9696
ΔΩ,
9797
blascopy!(n, sign.(X), incx, _zeros(X), incx),
9898
incx
9999
)
100100
end
101-
return (NO_FIELDS, DNE(), ∂X, DNE())
101+
return (NO_FIELDS, DoesNotExist(), ∂X, DoesNotExist())
102102
end
103103
return Ω, asum_pullback
104104
end
@@ -130,7 +130,7 @@ function rrule(::typeof(gemv), tA::Char, α::T, A::AbstractMatrix{T},
130130
-> gemv!('N', α, A, ȳ, one(T), x̄)
131131
)
132132
end
133-
return (NO_FIELDS, DNE(), @thunk(dot(ȳ, y) / α), ∂A, ∂x)
133+
return (NO_FIELDS, DoesNotExist(), @thunk(dot(ȳ, y) / α), ∂A, ∂x)
134134
end
135135
return y, gemv_pullback
136136
end
@@ -195,7 +195,7 @@ function rrule(::typeof(gemm), tA::Char, tB::Char, α::T,
195195
)
196196
end
197197
end
198-
return (NO_FIELDS, DNE(), DNE(), @thunk(dot(C̄, C) / α), ∂A, ∂B)
198+
return (NO_FIELDS, DoesNotExist(), DoesNotExist(), @thunk(dot(C̄, C) / α), ∂A, ∂B)
199199
end
200200
return C, gemv_pullback
201201
end

src/rulesets/LinearAlgebra/factorization.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function rrule(::typeof(getproperty), F::SVD, x::Symbol)
2929

3030
update = (X̄::NamedTuple{(:U,:S,:V)}) -> _update!(X̄, ∂, x)
3131
∂F = InplaceableThunk(∂, update)
32-
return NO_FIELDS, ∂F, DNE()
32+
return NO_FIELDS, ∂F, DoesNotExist()
3333
end
3434
return getproperty(F, x), getproperty_svd_pullback
3535
end
@@ -93,7 +93,7 @@ function rrule(::typeof(getproperty), F::Cholesky, x::Symbol)
9393
∂F = @thunk UpperTriangular(Ȳ')
9494
end
9595
end
96-
return NO_FIELDS, ∂F, DNE()
96+
return NO_FIELDS, ∂F, DoesNotExist()
9797
end
9898
return getproperty(F, x), getproperty_cholesky_pullback
9999
end

src/rulesets/Statistics/statistics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function rrule(::typeof(mean), f, x::AbstractArray{<:Real})
2929
_, _, ∂sum_x = sum_pullback(ȳ)
3030
extern(∂sum_x) / n
3131
end
32-
return (NO_FIELDS, DNE(), ∂x)
32+
return (NO_FIELDS, DoesNotExist(), ∂x)
3333
end
3434
return y_sum / n, mean_pullback
3535
end

test/rulesets/Base/array.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
(s̄, Ā, d̄) = pullback(Ȳ)
99
@test== NO_FIELDS
10-
@testisa DNE
10+
@testisa DoesNotExist
1111
@test extern(Ā) == reshape(Ȳ, (5, 4))
1212

1313
B, pullback = rrule(reshape, A, 5, 4)
@@ -16,8 +16,8 @@
1616
= randn(rng, 4, 5)
1717
(s̄, Ā, d̄1, d̄2) = pullback(Ȳ)
1818
@test== NO_FIELDS
19-
@test d̄1 isa DNE
20-
@test d̄2 isa DNE
19+
@test d̄1 isa DoesNotExist
20+
@test d̄2 isa DoesNotExist
2121
@test extern(Ā) == reshape(Ȳ, 5, 4)
2222
end
2323

@@ -56,13 +56,13 @@ end
5656
@test y == [44, 44, 44, 44]
5757
(ds, dv, dd) = pullback(ones(4))
5858
@test ds === NO_FIELDS
59-
@test dd isa DNE
59+
@test dd isa DoesNotExist
6060
@test extern(dv) == 4
6161

6262
y, pullback = rrule(fill, 2.0, (3, 3, 3))
6363
@test y == fill(2.0, (3, 3, 3))
6464
(ds, dv, dd) = pullback(ones(3, 3, 3))
6565
@test ds === NO_FIELDS
66-
@test dd isa DNE
66+
@test dd isa DoesNotExist
6767
@test dv 27.0
6868
end

test/rulesets/Base/broadcast.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@test y == sin.(x)
77
(dself, dsin, dx) = pullback(One())
88
@test dself == NO_FIELDS
9-
@test dsin == DNE()
9+
@test dsin == DoesNotExist()
1010
@test extern(dx) == cos.(x)
1111

1212
x̄, ȳ = rand(), rand()

0 commit comments

Comments
 (0)