Skip to content

Conversation

lkdvos
Copy link
Contributor

@lkdvos lkdvos commented Aug 27, 2025

This PR adds support both for using TensorOperations backends within TensorAlgebra methods (i.e. TensorAlgebra.contract(StridedBLAS(), args...), as well as TensorAlgebra backends within TensorOperations (TensorOperations.tensorcontract!(args..., Matricize())).

The end result is that we can now use TensorOperations' machinery to chain together contractions, or simplify the interface when NamedDimArrays or ITensor isn't loaded.
For example, here is a twosite dmrg contraction:

using TensorOperations: @tensor
using TensorAlgebra: Matricize

D1, D2, D3 = 30, 40, 20
d1, d2 = 2, 3
A1 = rand(T, D1, d1, D2) .- 1//2
A2 = rand(T, D2, d2, D3) .- 1//2
rhoL = rand(T, D1, D1) .- 1//2
rhoR = rand(T, D3, D3) .- 1//2
H = rand(T, d1, d2, d1, d2) .- 1//2

@tensor HrA12[a, s1, s2, c] :=
    rhoL[a, a'] * A1[a', t1, b] * A2[b, t2, c'] * rhoR[c', c] * H[s1, s2, t1, t2]
@tensor backend = Matricize() HrA12′[a, s1, s2, c] :=
    rhoL[a, a'] * A1[a', t1, b] * A2[b, t2, c'] * rhoR[c', c] * H[s1, s2, t1, t2]

One interesting thing here is that, similar to #75 , there is not enough information to correctly construct the bipermutation of the output.

Copy link

codecov bot commented Aug 27, 2025

Codecov Report

❌ Patch coverage is 32.25806% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.87%. Comparing base (3aaed6c) to head (fa81eca).

Files with missing lines Patch % Lines
ext/TensorAlgebraTensorOperationsExt.jl 32.25% 21 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #78      +/-   ##
==========================================
- Coverage   94.90%   90.87%   -4.03%     
==========================================
  Files          14       15       +1     
  Lines         451      482      +31     
==========================================
+ Hits          428      438      +10     
- Misses         23       44      +21     
Flag Coverage Δ
docs 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant