Effacer les filtres
Effacer les filtres

Issues with gpuArray Interpn

24 vues (au cours des 30 derniers jours)
deathtime
deathtime le 22 Mai 2023
Modifié(e) : Manish le 22 Août 2024 à 8:40
I have a series of 3 2D datasets (each one is 3x3 array):
f = rand(3, 3, 3);
In the above, the third dimension represents the dataset number.
These are essentially data at the following sample points for each dimension:
dimOneArray = [0.1 0.2 0.3];
dimTwoArray = [2 3 4];
For each dataset, I would like to interpolate the following targets in each dimension:
dimOneTarget = 0.15;
dimTwoTarget = 3;
In order to do this, I first generate ndgrid for both dimension sample points and then use interpn on the data f:
[dimOne, dimTwo] = ndgrid(dimOneArray, dimTwoArray);
serialInterp = interpn(dimOneArray, dimTwoArray, f, dimOneTarget, dimTwoTarget)
serialInterp =
serialInterp(:,:,1) = 0.5409 serialInterp(:,:,2) = 0.6143 serialInterp(:,:,3) = 0.6527
As can be seen, this results in an array with interpolants for each dataset as expect.
However when I run this using GPU, I get an error:
gpuInterp = interpn(dimOneArray, dimTwoArray, gpuArray(f), dimOneTarget, dimTwoTarget)
Error using gpuArray/interpn
The input arguments are invalid. For supported syntaxes, see help gpuArray.interpn.
Error in test4 (line 13)
gpuInterp = interpn(dimOneArray, dimTwoArray, gpuArray(f), dimOneTarget, dimTwoTarget);
Can someone see what the issue is?

Réponses (1)

Manish
Manish le 22 Août 2024 à 8:38
Modifié(e) : Manish le 22 Août 2024 à 8:40
Hi,
I was working on the similar usecase and encountered a similar issue. After trying several approaches, I found a workaround that might be helpful for you as well.
gpuInterp = interpn(dimOneArray, dimTwoArray, 1:3, gpuArray(f), dimOneTarget, dimTwoTarget, 1:3);
I also checked the latest MATLAB R2021a documentation, and it provides clear understanding in the extended capabilities section. Please refer to the documentation below to know more about it.
Hope it helps!

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by