Skip to content

Commit 23caf6d

Browse files
committed
Update allocation tests for Julia version compatibility
Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com>
1 parent 0b97be5 commit 23caf6d

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/test_utils.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,12 @@ function test_rrule_performance(
820820

821821
# Test allocations in primal.
822822
f(x...)
823-
@test (@allocations f(x...)) == 0
823+
824+
@static if VERSION >= v"1.12-"
825+
@test Base.allocations(f, x...) == 0
826+
else
827+
@test (@allocations f(x...)) == 0
828+
end
824829

825830
# Test allocations in round-trip.
826831
f_f̄_fwds = to_fwds(f_f̄)

src/utils.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,15 +377,15 @@ function misty_closure(
377377
end
378378

379379
@unstable begin
380-
@static if VERSION > v"1.12-"
381-
compute_ir_rettype(ir) = CC.compute_ir_rettype(ir)
382-
compute_oc_signature(ir, nargs, isva) = CC.compute_oc_signature(ir, nargs, isva)
383-
else
384-
compute_ir_rettype(ir) = Base.Experimental.compute_ir_rettype(ir)
385-
compute_oc_signature(ir, nargs, isva) = Base.Experimental.compute_oc_signature(
386-
ir, nargs, isva
387-
)
388-
end
380+
@static if VERSION > v"1.12-"
381+
compute_ir_rettype(ir) = CC.compute_ir_rettype(ir)
382+
compute_oc_signature(ir, nargs, isva) = CC.compute_oc_signature(ir, nargs, isva)
383+
else
384+
compute_ir_rettype(ir) = Base.Experimental.compute_ir_rettype(ir)
385+
compute_oc_signature(ir, nargs, isva) = Base.Experimental.compute_oc_signature(
386+
ir, nargs, isva
387+
)
388+
end
389389
end
390390

391391
"""

0 commit comments

Comments
 (0)