Error when using sptensor in parfor
2 ビュー (過去 30 日間)
古いコメントを表示
I am trying to edit a sparse tensor from the Tensor Toolbox inside a parfor loop. However I am getting the "Unable to classify the variable 'tau' in the body of the parfor-loop. I thought this might be a slicing issue, however when I tried testing using a 3D matrix with smaller dimensions the parfor loop runs. Unfortunately the needed tensor size is too big for me to use a native 3D matrix, and so I am trying to stay with a sparse tensor if possible. Any ideas how I can correct this? A simplified code is provided:
tau = sptensor([],[],[N N M]);
opts = parforOptions(gcp,'RangePartitionMethod','fixed','SubrangeSize',100);
parfor (i = 1:N-1, opts)
mytemp_p_k = sptensor([],[],[N M]);
mytemp_p_k(a,b) = <edit matrix>
tau(i,:,:) = mytemp_p_k;
end
1 件のコメント
Matt J
2022 年 8 月 5 日
However I am getting the "Unable to classify the variable 'tau' in the body of the parfor-loop.
Do you mean a Code Analyzer warning? I, for one, get no such warning.
採用された回答
Matt J
2022 年 8 月 5 日
You could try with ndSparse() instead of sptensor()
The following modified code ran fine for me.
[N,M]=deal(100);
tau = ndSparse.spalloc([N N M],N^2*M/100);
opts = parforOptions(gcp,'RangePartitionMethod','fixed','SubrangeSize',100);
parfor (i = 1:N-1, opts)
mytemp_p_k = sprand(N,M,0.01);
tau(i,:,:) = mytemp_p_k;
end
6 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Parallel for-Loops (parfor) についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!