hi, I’m posting here for better bookkeeping: while playing with diagonal and GPU tensors I stumbled upon a few more odd things,
-
I’m getting “Scalar indexing is disallowed” errors when I calculate the
sum()
of a cuda tensor, and also when computing a product of the formAij*Dij
, where D is a diagonal cuda tensor (whereas it works if D is not diagonal) -
Probably unrelated, I saw there is a
tr()
function for ITensors, but that doesn’t work for me (neither for cpu nor gpu tensors). Since I couldn’t find any doc for it, I imagine it’s not recommended for use - what I found strange is that there seems to be a method for tr(::ITensor), but then the function fails in some inner call.
A MWE recapping all this is:
using ITensors, CUDA
gpu = NDTensors.cu
ij = (Index(3), Index(3))
jk = (ij[2], Index(3))
aij= random_itensor(ij)
bjk = random_itensor(jk)
cij = random_itensor(ij)
djk = diag_itensor([1,2,3.0+im],jk)
cua = gpu(aij)
cub = gpu(bjk)
cuc = gpu(cij)
cud = gpu(djk)
cua * cub # ok, rank2
cua * cuc # ok, rank0
cua * cud # ok, rank2
cub * cud #ERROR: Scalar indexing is disallowed.
# Sum():
sum(aij) # ok, scalar
sum(djk) # ok, scalar
sum(cua) #ERROR: Scalar indexing is disallowed.
sum(cud) #ERROR: Scalar indexing is disallowed.
# tr():
tr(aij) # ERROR: MethodError: no method matching checkdims_perm(::NDTensors.DenseTensor{Float64, 3, Tuple{…}, NDTensors.Dense{…}}, ::NDTensors.DenseTensor{Float64, 2, Tuple{…}, NDTensors.Dense{…}}, ::Tuple{Int64, Int64, Int64})
tr(djk) # ERROR: MethodError: no method matching checkdims_perm(::NDTensors.DenseTensor{…}, ::NDTensors.DenseTensor{…}, ::Tuple{…})
tr(cua) # ERROR: MethodError: no method matching checkdims_perm(::NDTensors.DenseTensor{Float64, 3, Tuple{…}, NDTensors.Dense{…}}, ::NDTensors.DenseTensor{Float64, 2, Tuple{…}, NDTensors.Dense{…}}, ::Tuple{Int64, Int64, Int64})
tr(cud) #ERROR: MethodError: no method matching checkdims_perm(::NDTensors.DenseTensor{…}, ::NDTensors.DenseTensor{…}, ::Tuple{…})
thanks!