@@ -36,7 +36,7 @@ function ChainRulesCore.rrule(
3636 # for non-symmetric tensors this might be more efficient like this,
3737 # but for symmetric tensors an intermediate object will anyways be created
3838 # and then it might be more efficient to use an addition and inner product
39- tΔC = _twist_nocopy (ΔC, filter(x -> isdual(space(ΔC, x)), allind(ΔC)))
39+ tΔC = twist (ΔC, filter(x -> isdual(space(ΔC, x)), allind(ΔC)); copy = false )
4040 _dα = tensorscalar(
4141 tensorcontract(
4242 A, ((), linearize(pA)), ! conjA,
@@ -85,12 +85,12 @@ function ChainRulesCore.rrule(
8585 conjB′ = conjA ? conjB : ! conjB
8686 TA = promote_contract(scalartype(ΔC), scalartype(B), scalartype(α))
8787 # TODO : allocator
88- tB = _twist_nocopy (
88+ tB = twist (
8989 B,
9090 TupleTools. vcat(
9191 filter(x -> ! isdual(space(B, x)), pB[1 ]),
9292 filter(x -> isdual(space(B, x)), pB[2 ])
93- )
93+ ); copy = false
9494 )
9595 _dA = tensoralloc_contract(
9696 TA, ΔC, pΔC, conjΔC, tB, reverse(pB), conjB′, ipA, Val(false )
@@ -110,12 +110,12 @@ function ChainRulesCore.rrule(
110110 conjA′ = conjB ? conjA : ! conjA
111111 TB = promote_contract(scalartype(ΔC), scalartype(A), scalartype(α))
112112 # TODO : allocator
113- tA = _twist_nocopy (
113+ tA = twist (
114114 A,
115115 TupleTools. vcat(
116116 filter(x -> isdual(space(A, x)), pA[1 ]),
117117 filter(x -> ! isdual(space(A, x)), pA[2 ])
118- )
118+ ); copy = false
119119 )
120120 _dB = tensoralloc_contract(
121121 TB, tA, reverse(pA), conjA′, ΔC, pΔC, conjΔC, ipB, Val(false )
@@ -207,10 +207,3 @@ function ChainRulesCore.rrule(::typeof(TensorKit.scalar), t::AbstractTensorMap)
207207 end
208208 return val, scalar_pullback
209209end
210-
211- # temporary function to avoid copies when not needed
212- # TODO : remove once `twist(t; copy=false)` is defined
213- function _twist_nocopy(t, inds; kwargs... )
214- (BraidingStyle(sectortype(t)) isa Bosonic || isempty(inds)) && return t
215- return twist(t, inds; kwargs... )
216- end
0 commit comments