Skip to content

Commit af9c36e

Browse files
committed
wip
1 parent 36f7bfe commit af9c36e

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

src/Nonlinear/ReverseAD/types.jl

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,18 @@ struct _SubexpressionStorage
4343
end
4444

4545
struct _FunctionStorage
46-
nodes::Vector{Nonlinear.Node}
47-
adj::SparseArrays.SparseMatrixCSC{Bool,Int}
48-
const_values::Vector{Float64}
49-
forward_storage::Vector{Float64}
50-
partials_storage::Vector{Float64}
51-
reverse_storage::Vector{Float64}
46+
expr::_SubexpressionStorage
5247
grad_sparsity::Vector{Int}
5348
# Nonzero pattern of Hessian matrix
5449
hess_I::Vector{Int}
5550
hess_J::Vector{Int}
5651
rinfo::Coloring.RecoveryInfo # coloring info for hessians
5752
seed_matrix::Matrix{Float64}
58-
linearity::Linearity
5953
# subexpressions which this function depends on, ordered for forward pass.
6054
dependent_subexpressions::Vector{Int}
6155

6256
function _FunctionStorage(
63-
nodes::Vector{Nonlinear.Node},
64-
const_values,
57+
expr::_SubexpressionStorage,
6558
num_variables,
6659
coloring_storage::Coloring.IndexedSet,
6760
want_hess::Bool,
@@ -70,10 +63,7 @@ struct _FunctionStorage
7063
subexpression_linearity,
7164
subexpression_edgelist,
7265
subexpression_variables,
73-
moi_index_to_consecutive_index,
7466
)
75-
nodes = _replace_moi_variables(nodes, moi_index_to_consecutive_index)
76-
adj = Nonlinear.adjacency_matrix(nodes)
7767
N = length(nodes)
7868
empty!(coloring_storage)
7969
_compute_gradient_sparsity!(coloring_storage, nodes)
@@ -102,34 +92,21 @@ struct _FunctionStorage
10292
)
10393
seed_matrix = Coloring.seed_matrix(rinfo)
10494
return new(
105-
nodes,
106-
adj,
107-
const_values,
108-
zeros(N), # forward_storage,
109-
zeros(N), # partials_storage,
110-
zeros(N), # reverse_storage,
95+
expr,
11196
grad_sparsity,
11297
hess_I,
11398
hess_J,
11499
rinfo,
115100
seed_matrix,
116-
linearity[1],
117101
dependent_subexpressions,
118102
)
119103
else
120104
return new(
121-
nodes,
122-
adj,
123-
const_values,
124-
zeros(N), # forward_storage,
125-
zeros(N), # partials_storage,
126-
zeros(N), # reverse_storage,
127105
grad_sparsity,
128106
Int[],
129107
Int[],
130108
Coloring.RecoveryInfo(),
131109
Array{Float64}(undef, 0, 0),
132-
NONLINEAR,
133110
dependent_subexpressions,
134111
)
135112
end

0 commit comments

Comments
 (0)