Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ext/TensorOperationsBumperExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ module TensorOperationsBumperExt
using TensorOperations
using Bumper

const BumperBuffer = Union{SlabBuffer, AllocBuffer}
const BumperBuffer = @static if isdefined(Bumper, :ResizeBuffer)
Union{SlabBuffer, AllocBuffer, Bumper.ResizeBuffer}
else
Union{SlabBuffer, AllocBuffer}
end

function TensorOperations.tensoralloc(
::Type{A}, structure, ::Val{istemp}, buf::BumperBuffer
Expand Down
15 changes: 15 additions & 0 deletions test/butensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,19 @@ using Bumper
@test E5 isa T
@test HRAA5 ≈ HRAA1
@test E5 ≈ E1

# resizebuffer (Bumper >= 0.7.2)
@static if isdefined(Bumper, :ResizeBuffer)
resizebuf = Bumper.ResizeBuffer()
@no_escape resizebuf @tensor allocator = resizebuf begin
HRAA6[a, s1, s2, c] := ρₗ[a, a'] * A1[a', t1, b] * A2[b, t2, c'] * ρᵣ[c', c] *
H[s1, s2, t1, t2]
E6 = ρₗ[a', a] * A1[a, s, b] * A2[b, s', c] * ρᵣ[c, c'] * H[t, t', s, s'] *
conj(A1[a', t, b']) * conj(A2[b', t', c'])
end
@test HRAA6 isa Array{T, 4}
@test E6 isa T
@test HRAA6 ≈ HRAA1
@test E6 ≈ E1
end
end
Loading