diag_itensor constructor on GPU arrays

hi,
my silly idea of the day was to extract the diagonal of a rank2 square ITensor and build a new diagITensor with it - I wasn’t able to find a more clever way to do it than doing something like diag_itensor(array(diag(t)), indices), which works on CPU but not on GPU - I think this is something more general related with the diag_itensor function, ie. it seems that building a diagonal ITensor from a CUDA array is not working. I imagine this is not intended, or am I missing something? A MWE would be

using ITensors, CUDA
ii = (Index(3), Index(3))

v = [1,2,3.0+im]

d = diag_itensor(v,ii) #  works as expected
# but
cud = diag_itensor(NDTensors.cu(v),ii) 
#throws ERROR: MethodError: no method matching _indices(::Tuple{}, ::CuArray{ComplexF64, 1, CUDA.DeviceMemory})

thanks!

That should work, it will probably be easy to fix. As a workaround can you do: cud = NDTensors.cu(diag_itensor(v,ii))?

This will be fixed by [ITensors] Generalize `diag_itensor` constructors to AbstractVector by mtfishman · Pull Request #1510 · ITensor/ITensors.jl · GitHub.

2 Likes

awesome, thanks again for everything!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.