Skip to content

Commit c0b58ed

Browse files
committed
Rename ReverseAD -> ArrayAD
1 parent d1119ca commit c0b58ed

File tree

4 files changed

+37
-34
lines changed

4 files changed

+37
-34
lines changed

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ name = "ArrayAD"
22
uuid = "c45fa1ca-6901-44ac-ae5b-5513a4852d50"
33
authors = ["Benoît Legat <benoit.legat@gmail.com>"]
44
version = "0.1.0"
5+
6+
[deps]
7+
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"

src/ReverseAD.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Use of this source code is governed by an MIT-style license that can be found
55
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
66

7-
module ReverseAD
7+
module ArrayAD
88

99
import ForwardDiff
1010
import MathOptInterface as MOI

src/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ julia> x = [(1, 2, 3), (4, 5, 6), (7, 8, 9)]
188188
(4, 5, 6)
189189
(7, 8, 9)
190190
191-
julia> MOI.Nonlinear.ReverseAD._reinterpret_unsafe(NTuple{2,Int}, x)
192-
4-element MathOptInterface.Nonlinear.ReverseAD._UnsafeVectorView{Tuple{Int64, Int64}}:
191+
julia> MOI.Nonlinear.ArrayAD._reinterpret_unsafe(NTuple{2,Int}, x)
192+
4-element MathOptInterface.Nonlinear.ArrayAD._UnsafeVectorView{Tuple{Int64, Int64}}:
193193
(1, 2)
194194
(3, 4)
195195
(5, 6)

test/ReverseAD.jl

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
# Use of this source code is governed by an MIT-style license that can be found
55
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
66

7-
module TestReverseAD
7+
module TestArrayAD
88

99
using Test
1010
import LinearAlgebra
1111
import MathOptInterface as MOI
1212
import SparseArrays
1313

1414
const Nonlinear = MOI.Nonlinear
15-
const ReverseAD = Nonlinear.ReverseAD
16-
const Coloring = ReverseAD.Coloring
15+
const ArrayAD = Nonlinear.ArrayAD
16+
const Coloring = ArrayAD.Coloring
1717

1818
function runtests()
1919
for name in names(@__MODULE__; all = true)
@@ -553,85 +553,85 @@ function test_linearity()
553553
ex = Nonlinear.add_expression(model, input)
554554
expr = model[ex]
555555
adj = Nonlinear.adjacency_matrix(expr.nodes)
556-
nodes = ReverseAD._replace_moi_variables(expr.nodes, variables)
557-
ret = ReverseAD._classify_linearity(nodes, adj, ReverseAD.Linearity[])
556+
nodes = ArrayAD._replace_moi_variables(expr.nodes, variables)
557+
ret = ArrayAD._classify_linearity(nodes, adj, ArrayAD.Linearity[])
558558
@test ret[1] == test_value
559559
indexed_set = Coloring.IndexedSet(100)
560-
edge_list = ReverseAD._compute_hessian_sparsity(
560+
edge_list = ArrayAD._compute_hessian_sparsity(
561561
nodes,
562562
adj,
563563
ret,
564564
indexed_set,
565565
Set{Tuple{Int,Int}}[],
566566
Vector{Int}[],
567567
)
568-
if ret[1] != ReverseAD.NONLINEAR
568+
if ret[1] != ArrayAD.NONLINEAR
569569
@test length(edge_list) == 0
570570
elseif length(IJ) > 0
571571
@test IJ == edge_list
572572
end
573573
if length(indices) > 0
574574
empty!(indexed_set)
575-
ReverseAD._compute_gradient_sparsity!(indexed_set, nodes)
575+
ArrayAD._compute_gradient_sparsity!(indexed_set, nodes)
576576
ix = sort(collect(indexed_set))
577577
@test indices == ix
578578
end
579579
return
580580
end
581581
_test_linearity(
582582
:(sin($x^2) + cos($y * 4) - 2.0),
583-
ReverseAD.NONLINEAR,
583+
ArrayAD.NONLINEAR,
584584
Set([(2, 2), (1, 1)]),
585585
[1, 2],
586586
)
587-
_test_linearity(:(3 * 4 * ($x + $y)), ReverseAD.LINEAR)
587+
_test_linearity(:(3 * 4 * ($x + $y)), ArrayAD.LINEAR)
588588
_test_linearity(
589589
:($z * $y),
590-
ReverseAD.NONLINEAR,
590+
ArrayAD.NONLINEAR,
591591
Set([(3, 2), (3, 3), (2, 2)]),
592592
[2, 3],
593593
)
594-
_test_linearity(:(3 + 4), ReverseAD.CONSTANT)
595-
_test_linearity(:(sin(3) + $x), ReverseAD.LINEAR)
594+
_test_linearity(:(3 + 4), ArrayAD.CONSTANT)
595+
_test_linearity(:(sin(3) + $x), ArrayAD.LINEAR)
596596
_test_linearity(
597597
:(cos($z) * sin(3) + $x),
598-
ReverseAD.NONLINEAR,
598+
ArrayAD.NONLINEAR,
599599
Set([(3, 3)]),
600600
[1, 3],
601601
)
602-
_test_linearity(:($x - 3 * $y), ReverseAD.LINEAR)
603-
_test_linearity(:(-$x), ReverseAD.LINEAR)
604-
_test_linearity(:(+$x), ReverseAD.LINEAR)
602+
_test_linearity(:($x - 3 * $y), ArrayAD.LINEAR)
603+
_test_linearity(:(-$x), ArrayAD.LINEAR)
604+
_test_linearity(:(+$x), ArrayAD.LINEAR)
605605
_test_linearity(
606606
:($x^$y),
607-
ReverseAD.NONLINEAR,
607+
ArrayAD.NONLINEAR,
608608
Set([(2, 2), (1, 1), (2, 1)]),
609609
[1, 2],
610610
)
611-
_test_linearity(:($x / 3 + $y), ReverseAD.LINEAR)
611+
_test_linearity(:($x / 3 + $y), ArrayAD.LINEAR)
612612
_test_linearity(
613613
:(3 / ($x * $y)),
614-
ReverseAD.NONLINEAR,
614+
ArrayAD.NONLINEAR,
615615
Set([(2, 2), (1, 1), (2, 1)]),
616616
[1, 2],
617617
)
618-
_test_linearity(:(1 / ($x + 3)), ReverseAD.NONLINEAR, Set([(1, 1)]), [1])
618+
_test_linearity(:(1 / ($x + 3)), ArrayAD.NONLINEAR, Set([(1, 1)]), [1])
619619
_test_linearity(
620620
:(ifelse($x <= 1, $x, $y)),
621-
ReverseAD.PIECEWISE_LINEAR,
621+
ArrayAD.PIECEWISE_LINEAR,
622622
Set([]),
623623
[],
624624
)
625625
_test_linearity(
626626
:(ifelse($x <= 1, $x^2, $y)),
627-
ReverseAD.NONLINEAR,
627+
ArrayAD.NONLINEAR,
628628
Set([(1, 1)]),
629629
[1, 2],
630630
)
631-
_test_linearity(:(ifelse(1 <= 1, 2, 3)), ReverseAD.CONSTANT)
631+
_test_linearity(:(ifelse(1 <= 1, 2, 3)), ArrayAD.CONSTANT)
632632
_test_linearity(
633633
:(1 / ifelse($x < 1, $x, 0)),
634-
ReverseAD.NONLINEAR,
634+
ArrayAD.NONLINEAR,
635635
Set([(1, 1)]),
636636
[1],
637637
)
@@ -648,7 +648,7 @@ function test_linearity_no_hess()
648648
# We initialized without the need for the hessian so
649649
# the linearity shouldn't be computed.
650650
@test only(evaluator.backend.subexpressions).linearity ==
651-
ReverseAD.NONLINEAR
651+
ArrayAD.NONLINEAR
652652
return
653653
end
654654

@@ -1247,7 +1247,7 @@ end
12471247
function test_unsafe_vector_view()
12481248
x = Float64[]
12491249
GC.@preserve x begin
1250-
view = MOI.Nonlinear.ReverseAD._UnsafeVectorView(x, 3)
1250+
view = MOI.Nonlinear.ArrayAD._UnsafeVectorView(x, 3)
12511251
@test length(x) == 3
12521252
view[2] = 1.0
12531253
@test x[2] == 1.0
@@ -1388,12 +1388,12 @@ end
13881388
function test_generate_hessian_slice_inner()
13891389
# Test that it evaluates without error. The code contents are tested
13901390
# elsewhere.
1391-
MOI.Nonlinear.ReverseAD._generate_hessian_slice_inner()
1391+
MOI.Nonlinear.ArrayAD._generate_hessian_slice_inner()
13921392
d = ex = nothing # These arguments are untyped and not needed for this test
1393-
for id in [0, MOI.Nonlinear.ReverseAD.MAX_CHUNK + 1]
1393+
for id in [0, MOI.Nonlinear.ArrayAD.MAX_CHUNK + 1]
13941394
@test_throws(
13951395
ErrorException("Invalid chunk size: $id"),
1396-
MOI.Nonlinear.ReverseAD._hessian_slice_inner(d, ex, id),
1396+
MOI.Nonlinear.ArrayAD._hessian_slice_inner(d, ex, id),
13971397
)
13981398
end
13991399
return
@@ -1423,4 +1423,4 @@ end
14231423

14241424
end # module
14251425

1426-
TestReverseAD.runtests()
1426+
TestArrayAD.runtests()

0 commit comments

Comments
 (0)