You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@mtfishman I found more situations where Contracting a tensor with Diag tensor fails. It looks like the result gives the right numbers but the ordering can be incorrect.
Minimal code demonstrating the bug or unexpected behavior
Minimal runnable code
julia> A =BlockSparseTensor{elt}([(1, 1), (2, 2)], [3, 2, 3], [2, 2])
julia>randn!(A)
julia> t =Tensor(DiagBlockSparse(one(elt),blockoffsets(A)), inds(A))
julia>dense(contract(A, (1, -2), t, (3,-2)))
Dim 1: [3, 2, 3]
Dim 2: [3, 2, 3]
Dense{Float32, Vector{Float32}}
8×80.031554032f00.46567222f00.0f00.0f00.0f00.0f00.0f00.0f0-2.535787f01.2645102f00.0f00.0f00.0f00.0f00.0f00.0f00.22016893f0-0.6247142f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f01.2566022f0-1.7536509f00.0f00.0f00.0f00.0f00.0f00.0f0-0.37950152f00.21746661f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f0
julia>contract(dense(A), (1, -2), dense(t), (3,-2))
Dim 1: [3, 2, 3]
Dim 2: [3, 2, 3]
Dense{Float32, Vector{Float32}}
8×80.031554032f00.46567222f00.0f00.0f00.0f00.0f00.0f00.0f0-2.535787f01.2645102f00.0f00.0f00.0f00.0f00.0f00.0f00.22016893f0-0.6247142f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f01.2566022f0-1.7536509f00.0f00.0f00.0f00.0f00.0f00.0f0-0.37950152f00.21746661f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f00.0f0
julia>dense(contract(A, (-2, 1), t, (-2,3)))
Dim 1: [2, 2]
Dim 2: [2, 2]
Dense{Float32, Vector{Float32}}
4×40.031554032f0-2.535787f00.0f00.0f00.46567222f01.2645102f00.0f00.0f00.0f00.0f01.2566022f0-0.37950152f00.0f00.0f0-1.7536509f00.21746661f0
julia>contract(dense(A), (-2, 1), dense(t), (-2,3))
Dim 1: [2, 2]
Dim 2: [2, 2]
Dense{Float32, Vector{Float32}}
4×40.031554032f0-2.535787f00.22016893f00.0f00.46567222f01.2645102f0-0.6247142f00.0f00.0f00.0f00.0f01.2566022f00.0f00.0f00.0f0-1.7536509f0
julia>contract(A, (-1,-2), t, (-1,-2))[]
2.770133f0
julia>contract(dense(A), (-1,-2), dense(t), (-1,-2))[]
-0.45758677f0### These work properly
julia>dot(A, t)
-0.45758677f0
julia>dot(dense(A), dense(t))
-0.45758677f0
Version information
Output from versioninfo():
julia>versioninfo()
Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-3010:59 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU:10× Apple M1 Max
WORD_SIZE:64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads:1 default, 0 interactive, 1 GC (on 8 virtual cores)
Environment:
LD_LIBRARY_PATH =/Users/kpierce/Software/triqs/triqs_install/lib::/opt/intel/oneapi/mkl/latest/lib
JULIA_EDITOR = code
JULIA_NUM_THREADS =
The text was updated successfully, but these errors were encountered:
mtfishman
changed the title
[NDTensors] [BUG] Contracting with Diag can give the wrong answer
[NDTensors] [BUG] Contracting with DiagBlockSparse can give the wrong answer
May 30, 2024
@mtfishman I haven't tried with more square tensors just this one example so far. ** edit: I just tried where all the blocks are the same (i.e. a 4x4 tensor with uniform 2x2 blocks) and all contractions give the correct values and order
Description of bug
@mtfishman I found more situations where Contracting a tensor with Diag tensor fails. It looks like the result gives the right numbers but the ordering can be incorrect.
Minimal code demonstrating the bug or unexpected behavior
Minimal runnable code
Version information
versioninfo()
:The text was updated successfully, but these errors were encountered: