Skip to content

Commit 71dbbb6

Browse files
committed
make observables forward diffable
1 parent 81f1f55 commit 71dbbb6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/symbolicindexing.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,11 @@ function _get_observed_f(im::IndexManager, cf::VertexModel, vidx, _obsf::O) wher
555555
aggr = im.v_aggr[vidx]
556556
extr = im.v_out[vidx]
557557
pr = im.v_para[vidx]
558-
ret = Vector{Float64}(undef, N)
558+
retcache = DiffCache(Vector{Float64}(undef, N))
559559
_hasext = has_external_input(cf)
560560

561561
(u, outbuf, aggbuf, extbuf, p, t) -> begin
562+
ret = PreallocationTools.get_tmp(retcache, first(u)*first(p)*first(t))
562563
ins = if _hasext
563564
(view(aggbuf, aggr), view(extbuf, extr))
564565
else

test/symbolicindexing_test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,9 @@ end
534534
# @b SII.observed($nw, $(VIndex(2,:Pdamping))) # 15
535535
# @b SII.observed($nw, $(VIndex(2,:θ))) # 7 5
536536

537-
b = @b SII.observed($nw, $idxs1) # 69 36 42 30 37
537+
b = @b SII.observed($nw, $idxs1) # 69 36 42 30 37 47
538538
if VERSION v"1.11"
539-
@test b.allocs <= 37
539+
@test b.allocs <= 47
540540
end
541541
b = @b SII.observed($nw, $idxs2) # 12 7 10 5
542542
if VERSION v"1.11"

0 commit comments

Comments
 (0)