Skip to content

Commit 0b2e62e

Browse files
committed
Fix
1 parent df4a0d2 commit 0b2e62e

1 file changed

Lines changed: 39 additions & 16 deletions

File tree

DifferentiationInterfaceTest/src/tests/correctness_eval.jl

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ for op in ALL_OPS
5454
xrand = myrandom(x)
5555
rewrap = Rewrap(contexts...)
5656
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
57+
local prepstrict
5758
preptup_cands_val, preptup_cands_noval = map(1:2) do _
5859
new_smaller =
5960
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
@@ -121,6 +122,7 @@ for op in ALL_OPS
121122
xrand = myrandom(x)
122123
rewrap = Rewrap(contexts...)
123124
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
125+
local prepstrict
124126
preptup_cands_val, preptup_cands_noval = map(1:2) do _
125127
new_smaller =
126128
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
@@ -182,9 +184,9 @@ for op in ALL_OPS
182184
end
183185
end
184186
@test_throws PME $val_and_op!(
185-
nothing, res1_in1_val, prepstrict, ba, x, contexts...
187+
nothing, mysimilar(res1), prepstrict, ba, x, contexts...
186188
)
187-
@test_throws PME $op!(nothing, res1_in1_noval, prepstrict, ba, x, contexts...)
189+
@test_throws PME $op!(nothing, mysimilar(res1), prepstrict, ba, x, contexts...)
188190
scenario_intact && @test new_scen == scen
189191
return nothing
190192
end
@@ -204,6 +206,7 @@ for op in ALL_OPS
204206
xrand, yrand = myrandom(x), myrandom(y)
205207
rewrap = Rewrap(contexts...)
206208
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
209+
local prepstrict
207210
preptup_cands_val, preptup_cands_noval = map(1:2) do _
208211
new_smaller =
209212
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
@@ -260,8 +263,10 @@ for op in ALL_OPS
260263
@test mynnz(res1_out2_noval) == mynnz(scen.res1)
261264
end
262265
end
263-
@test_throws PME $val_and_op(nothing, y_in1_val, prepstrict, ba, x, contexts...)
264-
@test_throws PME $op(nothing, y_in1_noval, prepstrict, ba, x, contexts...)
266+
@test_throws PME $val_and_op(
267+
nothing, mysimilar(y), prepstrict, ba, x, contexts...
268+
)
269+
@test_throws PME $op(nothing, mysimilar(y), prepstrict, ba, x, contexts...)
265270
scenario_intact && @test new_scen == scen
266271
return nothing
267272
end
@@ -279,6 +284,7 @@ for op in ALL_OPS
279284
xrand, yrand = myrandom(x), myrandom(y)
280285
rewrap = Rewrap(contexts...)
281286
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
287+
local prepstrict
282288
preptup_cands_val, preptup_cands_noval = map(1:2) do _
283289
new_smaller =
284290
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
@@ -344,10 +350,10 @@ for op in ALL_OPS
344350
end
345351
end
346352
@test_throws PME $val_and_op!(
347-
nothing, y_in1_val, res1_in1_val, prepstrict, ba, x, contexts...
353+
nothing, mysimilar(y), mysimilar(res1), prepstrict, ba, x, contexts...
348354
)
349355
@test_throws PME $op!(
350-
nothing, y_in1_noval, res1_in1_noval, prepstrict, ba, x, contexts...
356+
nothing, mysimilar(y), mysimilar(res1), prepstrict, ba, x, contexts...
351357
)
352358
scenario_intact && @test new_scen == scen
353359
return nothing
@@ -367,6 +373,7 @@ for op in ALL_OPS
367373
xrand = myrandom(x)
368374
rewrap = Rewrap(contexts...)
369375
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
376+
local prepstrict
370377
preptup_cands_val, preptup_cands_noval = map(1:2) do _
371378
new_smaller =
372379
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
@@ -436,6 +443,7 @@ for op in ALL_OPS
436443
xrand = myrandom(x)
437444
rewrap = Rewrap(contexts...)
438445
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
446+
local prepstrict
439447
preptup_cands_val, preptup_cands_noval = map(1:2) do _
440448
new_smaller =
441449
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
@@ -501,9 +509,9 @@ for op in ALL_OPS
501509
end
502510
end
503511
@test_throws PME $val_and_op!(
504-
nothing, res1_in1_val, res2_in1_val, prepstrict, ba, x, contexts...
512+
nothing, mysimilar(res1), mysimilar(res2), prepstrict, ba, x, contexts...
505513
)
506-
@test_throws PME $op!(nothing, res2_in1_noval, prepstrict, ba, x, contexts...)
514+
@test_throws PME $op!(nothing, mysimilar(res2), prepstrict, ba, x, contexts...)
507515
scenario_intact && @test new_scen == scen
508516
return nothing
509517
end
@@ -522,6 +530,7 @@ for op in ALL_OPS
522530
xrand, tangrand = myrandom(x), myrandom(tang)
523531
rewrap = Rewrap(contexts...)
524532
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
533+
local prepstrict
525534
preptup_cands_val, preptup_cands_noval = map(1:2) do _
526535
new_smaller =
527536
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
@@ -588,6 +597,7 @@ for op in ALL_OPS
588597
xrand, tangrand = myrandom(x), myrandom(tang)
589598
rewrap = Rewrap(contexts...)
590599
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
600+
local prepstrict
591601
preptup_cands_val, preptup_cands_noval = map(1:2) do _
592602
new_smaller =
593603
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
@@ -648,10 +658,10 @@ for op in ALL_OPS
648658
end
649659
end
650660
@test_throws PME $val_and_op!(
651-
nothing, res1_in1_val, prepstrict, ba, x, tang, contexts...
661+
nothing, mysimilar(res1), prepstrict, ba, x, tang, contexts...
652662
)
653663
@test_throws PME $op!(
654-
nothing, res1_in1_noval, prepstrict, ba, x, tang, contexts...
664+
nothing, mysimilar(res1), prepstrict, ba, x, tang, contexts...
655665
)
656666
scenario_intact && @test new_scen == scen
657667
return nothing
@@ -670,6 +680,7 @@ for op in ALL_OPS
670680
xrand, yrand, tangrand = myrandom(x), myrandom(y), myrandom(tang)
671681
rewrap = Rewrap(contexts...)
672682
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
683+
local prepstrict
673684
preptup_cands_val, preptup_cands_noval = map(1:2) do _
674685
new_smaller =
675686
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
@@ -730,9 +741,11 @@ for op in ALL_OPS
730741
end
731742
end
732743
@test_throws PME $val_and_op(
733-
nothing, y_in1_val, prepstrict, ba, x, tang, contexts...
744+
nothing, mysimilar(y), prepstrict, ba, x, tang, contexts...
745+
)
746+
@test_throws PME $op(
747+
nothing, mysimilar(y), prepstrict, ba, x, tang, contexts...
734748
)
735-
@test_throws PME $op(nothing, y_in1_noval, prepstrict, ba, x, tang, contexts...)
736749
scenario_intact && @test new_scen == scen
737750
return nothing
738751
end
@@ -750,6 +763,7 @@ for op in ALL_OPS
750763
xrand, yrand, tangrand = myrandom(x), myrandom(y), myrandom(tang)
751764
rewrap = Rewrap(contexts...)
752765
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
766+
local prepstrict
753767
preptup_cands_val, preptup_cands_noval = map(1:2) do _
754768
new_smaller =
755769
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
@@ -828,10 +842,10 @@ for op in ALL_OPS
828842
end
829843
end
830844
@test_throws PME $val_and_op!(
831-
nothing, y_in1_val, res1_in1_val, prepstrict, ba, x, tang, contexts...
845+
nothing, mysimilar(y), mysimilar(res1), prepstrict, ba, x, tang, contexts...
832846
)
833847
@test_throws PME $op!(
834-
nothing, y_in2_noval, res1_in2_noval, prepstrict, ba, x, tang, contexts...
848+
nothing, mysimilar(y), mysimilar(res1), prepstrict, ba, x, tang, contexts...
835849
)
836850
scenario_intact && @test new_scen == scen
837851
return nothing
@@ -851,6 +865,7 @@ for op in ALL_OPS
851865
xrand, tangrand = myrandom(x), myrandom(tang)
852866
rewrap = Rewrap(contexts...)
853867
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
868+
local prepstrict
854869
preptup_cands_val, preptup_cands_noval = map(1:2) do _
855870
new_smaller =
856871
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
@@ -917,6 +932,7 @@ for op in ALL_OPS
917932
xrand, tangrand = myrandom(x), myrandom(tang)
918933
rewrap = Rewrap(contexts...)
919934
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
935+
local prepstrict
920936
preptup_cands_val, preptup_cands_noval = map(1:2) do _
921937
new_smaller =
922938
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
@@ -993,10 +1009,17 @@ for op in ALL_OPS
9931009
end
9941010
end
9951011
@test_throws PME $op!(
996-
nothing, res2_in1_noval, prepstrict, ba, x, tang, contexts...
1012+
nothing, mysimilar(res2), prepstrict, ba, x, tang, contexts...
9971013
)
9981014
@test_throws PME $val_and_op!(
999-
nothing, res1_in1_val, res2_in1_val, prepstrict, ba, x, tang, contexts...
1015+
nothing,
1016+
mysimilar(res1),
1017+
mysimilar(res2),
1018+
prepstrict,
1019+
ba,
1020+
x,
1021+
tang,
1022+
contexts...,
10001023
)
10011024
scenario_intact && @test new_scen == scen
10021025
return nothing

0 commit comments

Comments
 (0)