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

tracing a 1X1 tensor throws BoundsError #60

Closed
orialb opened this issue Mar 1, 2019 · 4 comments
Closed

tracing a 1X1 tensor throws BoundsError #60

orialb opened this issue Mar 1, 2019 · 4 comments

Comments

@orialb
Copy link

orialb commented Mar 1, 2019

Hi,
first of all let me thank you for this great package that I find really useful.
I encountered an issue with v1.0.3 that didn't occur in v0.7.1 where trying to trace a 1X1 tensor produces an error.
minimal example to reproduce:

M = rand(1,1)
@tensor M[] := M[a,a]

this results in the following error:

ERROR: BoundsError: attempt to access ()
  at index [0]
Stacktrace:
 [1] getindex(::Tuple{}, ::Int64) at ./tuple.jl:24
 [2] stride( :Strided.UnsafeStridedView{Float64,0,Float64,typeof(identity)}, ::Int64) at /home/user/.julia/packages/Strided/89nTo/src/unsafestridedview.jl:31
[3] #72 at /home/user/.julia/packages/Strided/89nTo/src/broadcast.jl:66 [inlined]
 [4] ntuple at ./tuple.jl:156 [inlined]
 [5] promoteshape1 at /home/user/.julia/packages/Strided/89nTo/src/broadcast.jl:64 [inlined]
 [6] promoteshape at /home/user/.julia/packages/Strided/89nTo/src/broadcast.jl:49 [inlined]
 [7] _mapreducedim! at /home/user/.julia/packages/Strided/89nTo/src/mapreduce.jl:74 [inlined]
 [8] _trace!(::Int64, ::Strided.UnsafeStridedView{Float64,2,Float64,typeof(identity)}, ::Bool, 
::Strided.UnsafeStridedView{Float64,0,Float64,typeof(identity)}, ::Tuple{}, ::Tuple{Int64}, ::Tuple{Int64}) at /home/user/.julia/packages/TensorOperations/RSY9n/src/implementation/stridedarray.jl:220
 [9] trace!(::Int64, ::Array{Float64,2}, ::Symbol, ::Bool, ::Array{Float64,0}, ::Tuple{}, ::Tuple{Int64}, ::Tuple{Int64}) at ./gcutils.jl:87
 [10] trace!(::Int64, ::Array{Float64,2}, ::Symbol, ::Bool, ::Array{Float64,0}, ::Tuple{}, ::Tuple{}, ::Tuple{Int64}, ::Tuple{Int64}) at /home/user/.julia/packages/TensorOperations/RSY9n/src/implementation/stridedarray.jl:62
 [11] top-level scope at /home/user/.julia/packages/TensorOperations/RSY9n/src/indexnotation/tensormacro.jl:352

I'm on Julia 1.0.3 .

@Jutho
Copy link
Owner

Jutho commented Mar 1, 2019

Nice catch; should be fixed when v0.2.6 of the package Strided is registered in METADATA; shouldn't take too long.

Your syntax invocation is a bit strange though, you overwrite the rank 2 array M with a rank zero array, i.e. M. If you just want the trace as a scalar, you could also do

M = randn(1,1)
@tensor t = M[a,a]

@orialb
Copy link
Author

orialb commented Mar 1, 2019

should be fixed when v0.2.6 of the package Strided is registered in METADATA; shouldn't take too long.

cool, thanks for the quick reply!

Your syntax invocation is a bit strange though, you overwrite the rank 2 array M with a rank zero array, i.e. M. If you just want the trace as a scalar, you could also do ...

Oh I didn't know that's possible, thanks for the tip.

@Jutho
Copy link
Owner

Jutho commented Mar 1, 2019

Can you try pkg> update and see whether the problem persists or is solved?

@orialb
Copy link
Author

orialb commented Mar 3, 2019

The issue seems to be solved after the update of Strided.jl to v0.2.6.
Thanks!

@orialb orialb closed this as completed Mar 3, 2019
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

No branches or pull requests

2 participants