Skip to content

Commit a1753ae

Browse files
authored
feat: add support for Bumper.ResizeBuffer (#275)
1 parent f71ddaf commit a1753ae

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

ext/TensorOperationsBumperExt.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ module TensorOperationsBumperExt
33
using TensorOperations
44
using Bumper
55

6-
const BumperBuffer = Union{SlabBuffer, AllocBuffer}
6+
const BumperBuffer = @static if isdefined(Bumper, :ResizeBuffer)
7+
Union{SlabBuffer, AllocBuffer, Bumper.ResizeBuffer}
8+
else
9+
Union{SlabBuffer, AllocBuffer}
10+
end
711

812
function TensorOperations.tensoralloc(
913
::Type{A}, structure, ::Val{istemp}, buf::BumperBuffer

test/butensor.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,19 @@ using Bumper
7878
@test E5 isa T
7979
@test HRAA5 HRAA1
8080
@test E5 E1
81+
82+
# resizebuffer (Bumper >= 0.7.2)
83+
@static if isdefined(Bumper, :ResizeBuffer)
84+
resizebuf = Bumper.ResizeBuffer()
85+
@no_escape resizebuf @tensor allocator = resizebuf begin
86+
HRAA6[a, s1, s2, c] := ρₗ[a, a'] * A1[a', t1, b] * A2[b, t2, c'] * ρᵣ[c', c] *
87+
H[s1, s2, t1, t2]
88+
E6 = ρₗ[a', a] * A1[a, s, b] * A2[b, s', c] * ρᵣ[c, c'] * H[t, t', s, s'] *
89+
conj(A1[a', t, b']) * conj(A2[b', t', c'])
90+
end
91+
@test HRAA6 isa Array{T, 4}
92+
@test E6 isa T
93+
@test HRAA6 HRAA1
94+
@test E6 E1
95+
end
8196
end

0 commit comments

Comments
 (0)