Closed jofrevalles closed 3 months ago
When attempting to perform a sum or subtraction between two tensors that have matching inds but in a different permutation, the operation fails with a DimensionMismatch error. I instead expected that these operations were possible.
inds
DimensionMismatch
Example:
julia> using Tenet julia> A = Tensor(rand(2, 4, 2), (:i, :j, :k)) 2×4×2 Tensor{Float64, 3, Array{Float64, 3}}: [:, :, 1] = 0.864098 0.504478 0.764864 0.576408 0.17088 0.644568 0.889588 0.883436 [:, :, 2] = 0.0782172 0.893183 0.507304 0.758659 0.836397 0.00498142 0.103803 0.176029 julia> B = Tensor(rand(4, 2, 2), (:j, :i, :k)) 4×2×2 Tensor{Float64, 3, Array{Float64, 3}}: [:, :, 1] = 0.932157 0.505743 0.865242 0.1574 0.290655 0.269668 0.267595 0.609859 [:, :, 2] = 0.675176 0.725486 0.737603 0.377162 0.254187 0.925577 0.980923 0.207142 julia> A - B ERROR: DimensionMismatch: dimensions must match: a has dims (Base.OneTo(2), Base.OneTo(4), Base.OneTo(2)), b has dims (Base.OneTo(4), Base.OneTo(2), Base.OneTo(2)), mismatch at 1 Stacktrace: [1] promote_shape @ ./indices.jl:178 [inlined] [2] promote_shape(a::Tensor{Float64, 3, Array{Float64, 3}}, b::Tensor{Float64, 3, Array{Float64, 3}}) @ Base ./indices.jl:169 [3] -(A::Tensor{Float64, 3, Array{Float64, 3}}, B::Tensor{Float64, 3, Array{Float64, 3}}) @ Base ./arraymath.jl:7 [4] top-level scope @ REPL[5]:1
When attempting to perform a sum or subtraction between two tensors that have matching
inds
but in a different permutation, the operation fails with aDimensionMismatch
error. I instead expected that these operations were possible.Example: