Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TensorAlgebra] [BUG] TensorAlgebra.contract fails for full contraction #1428

Open
ogauthe opened this issue May 10, 2024 · 0 comments · May be fixed by #1459
Open

[TensorAlgebra] [BUG] TensorAlgebra.contract fails for full contraction #1428

ogauthe opened this issue May 10, 2024 · 0 comments · May be fixed by #1459
Labels
bug Something isn't working ITensors Issues or pull requests related to the `ITensors` package. NDTensors Requires changes to the NDTensors.jl library.

Comments

@ogauthe
Copy link
Contributor

ogauthe commented May 10, 2024

TensorAlgebra.contract crashes when one tries to contract all axes from exactly one input.

using NDTensors.TensorAlgebra
mat = ones((1,1))
vec = ones((1,))
TensorAlgebra.contract(mat, (1, 2), mat, (2, 3))  # OK
TensorAlgebra.contract(mat, (1, 2), mat, (1, 2))  # OK
TensorAlgebra.contract(vec, (1,), vec, (1,))  # OK
TensorAlgebra.contract(mat, (1, 2), vec, (2,))  # MethodError
TensorAlgebra.contract(vec, (1,), mat, (1,2))  # MethodError
ERROR: MethodError: no method matching output_axes(::typeof(NDTensors.TensorAlgebra.contract), ::NDTensors.TensorAlgebra.BlockedPermutation{…}, ::Vector{…}, ::NDTensors.TensorAlgebra.BlockedPermutation{…}, ::Matrix{…}, ::NDTensors.TensorAlgebra.BlockedPermutation{…}, ::Bool)

Closest candidates are:
  output_axes(::typeof(NDTensors.TensorAlgebra.contract), ::NDTensors.TensorAlgebra.BlockedPermutation{0, Length, Blocks} where {Length, Blocks<:Tuple{}}, ::AbstractArray, ::NDTensors.TensorAlgebra.BlockedPermutation{1, Length, Blocks} where {Length, Blocks<:Tuple{Tuple{Vararg{Int64}}}}, ::AbstractArray, ::NDTensors.TensorAlgebra.BlockedPermutation{1, Length, Blocks} where {Length, Blocks<:Tuple{Tuple{Vararg{Int64}}}}, ::Number)
   @ NDTensors ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/allocate_output.jl:23
  output_axes(::typeof(NDTensors.TensorAlgebra.contract), ::NDTensors.TensorAlgebra.BlockedPermutation{2, Length, Blocks} where {Length, Blocks<:Tuple{Tuple{Vararg{Int64}}, Tuple{Vararg{Int64}}}}, ::AbstractArray, ::NDTensors.TensorAlgebra.BlockedPermutation{2, Length, Blocks} where {Length, Blocks<:Tuple{Tuple{Vararg{Int64}}, Tuple{Vararg{Int64}}}}, ::AbstractArray, ::NDTensors.TensorAlgebra.BlockedPermutation{2, Length, Blocks} where {Length, Blocks<:Tuple{Tuple{Vararg{Int64}}, Tuple{Vararg{Int64}}}}, ::Number)
   @ NDTensors ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/allocate_output.jl:5
  output_axes(::typeof(NDTensors.TensorAlgebra.contract), ::NDTensors.TensorAlgebra.BlockedPermutation{0, Length, Blocks} where {Length, Blocks<:Tuple{}}, ::AbstractArray, ::NDTensors.TensorAlgebra.BlockedPermutation{1, Length, Blocks} where {Length, Blocks<:Tuple{Tuple{Vararg{Int64}}}}, ::AbstractArray, ::NDTensors.TensorAlgebra.BlockedPermutation{1, Length, Blocks} where {Length, Blocks<:Tuple{Tuple{Vararg{Int64}}}})
   @ NDTensors ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/allocate_output.jl:23
  ...

Stacktrace:
  [1] allocate_output(::typeof(NDTensors.TensorAlgebra.contract), biperm_dest::NDTensors.TensorAlgebra.BlockedPermutation{…}, a1::Vector{…}, biperm1::NDTensors.TensorAlgebra.BlockedPermutation{…}, a2::Matrix{…}, biperm2::NDTensors.TensorAlgebra.BlockedPermutation{…}, α::Bool)
    @ NDTensors.TensorAlgebra ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/allocate_output.jl:49
  [2] contract(alg::NDTensors.BackendSelection.Algorithm{…}, biperm_dest::NDTensors.TensorAlgebra.BlockedPermutation{…}, a1::Vector{…}, biperm1::NDTensors.TensorAlgebra.BlockedPermutation{…}, a2::Matrix{…}, biperm2::NDTensors.TensorAlgebra.BlockedPermutation{…}, α::Bool; kwargs::@Kwargs{})
    @ NDTensors.TensorAlgebra ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/contract.jl:117
  [3] contract(alg::NDTensors.BackendSelection.Algorithm{…}, biperm_dest::NDTensors.TensorAlgebra.BlockedPermutation{…}, a1::Vector{…}, biperm1::NDTensors.TensorAlgebra.BlockedPermutation{…}, a2::Matrix{…}, biperm2::NDTensors.TensorAlgebra.BlockedPermutation{…}, α::Bool)
    @ NDTensors.TensorAlgebra ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/contract.jl:107
  [4] contract(alg::NDTensors.BackendSelection.Algorithm{…}, labels_dest::Tuple{…}, a1::Vector{…}, labels1::Tuple{…}, a2::Matrix{…}, labels2::Tuple{…}, α::Bool; kwargs::@Kwargs{})
    @ NDTensors.TensorAlgebra ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/contract.jl:88
  [5] contract(alg::NDTensors.BackendSelection.Algorithm{…}, labels_dest::Tuple{…}, a1::Vector{…}, labels1::Tuple{…}, a2::Matrix{…}, labels2::Tuple{…}, α::Bool)
    @ NDTensors.TensorAlgebra ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/contract.jl:77
  [6] contract(alg::NDTensors.BackendSelection.Algorithm{…}, a1::Vector{…}, labels1::Tuple{…}, a2::Matrix{…}, labels2::Tuple{…}, α::Bool; kwargs::@Kwargs{})
    @ NDTensors.TensorAlgebra ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/contract.jl:45
  [7] contract
    @ ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/contract.jl:35 [inlined]
  [8] #contract#31
    @ ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/contract.jl:32 [inlined]
  [9] contract
    @ ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/contract.jl:23 [inlined]
 [10] contract(a1::Vector{Float64}, labels1::Tuple{Int64}, a2::Matrix{Float64}, labels2::Tuple{Int64, Int64})
    @ NDTensors.TensorAlgebra ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/TensorAlgebra/src/contract/contract.jl:23
 [11] top-level scope
    @ REPL[18]:1
Some type information was truncated. Use `show(err)` to see complete types.
@ogauthe ogauthe added bug Something isn't working ITensors Issues or pull requests related to the `ITensors` package. labels May 10, 2024
@ogauthe ogauthe changed the title [NDTensors] [BUG] TensorAlgebra.contracts fails for full contraction [NDTensors] [BUG] TensorAlgebra.contract fails for full contraction May 10, 2024
@mtfishman mtfishman changed the title [NDTensors] [BUG] TensorAlgebra.contract fails for full contraction [TensorAlgebra] [BUG] TensorAlgebra.contract fails for full contraction May 10, 2024
@mtfishman mtfishman added the NDTensors Requires changes to the NDTensors.jl library. label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ITensors Issues or pull requests related to the `ITensors` package. NDTensors Requires changes to the NDTensors.jl library.
Projects
None yet
2 participants