Skip to content

Commit 6c9650d

Browse files
committed
Add fallback TensorOperations implementations
1 parent 76424f2 commit 6c9650d

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

ext/TensorAlgebraTensorOperationsExt.jl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module TensorAlgebraTensorOperationsExt
33
using TensorAlgebra: TensorAlgebra, BlockedPermutation, Algorithm
44
using TupleTools
55
using TensorOperations
6-
using TensorOperations: AbstractBackend
6+
using TensorOperations: AbstractBackend, DefaultBackend
77

88
"""
99
TensorOperationsAlgorithm(backend::AbstractBackend)
@@ -120,4 +120,31 @@ function TensorOperations.tensorcontract!(
120120
return TensorAlgebra.contract!(backend, C, bipermAB, A′, bipermA, B′, bipermB, α, β)
121121
end
122122

123+
# For now no trace/add is supported, so simply reselect default backend from TensorOperations
124+
function TensorOperations.tensortrace!(
125+
C::AbstractArray,
126+
A::AbstractArray,
127+
p::Index2Tuple,
128+
q::Index2Tuple,
129+
conjA::Bool,
130+
α::Number,
131+
β::Number,
132+
::Algorithm,
133+
allocator,
134+
)
135+
return TensorOperations.tensortrace!(C, A, p, q, conjA, α, β, DefaultBackend(), allocator)
136+
end
137+
function TensorOperations.tensoradd!(
138+
C::AbstractArray,
139+
A::AbstractArray,
140+
pA::Index2Tuple,
141+
conjA::Bool,
142+
α::Number,
143+
β::Number,
144+
::Algorithm,
145+
allocator,
146+
)
147+
return TensorOperations.tensoradd!(C, A, pA, conjA, α, β, DefaultBackend(), allocator)
148+
end
149+
123150
end

0 commit comments

Comments
 (0)