Contenu principal

Cette page a été traduite par traduction automatique. Cliquez ici pour voir la dernière version en anglais.

Travailler avec des tableaux parcimonieux sur un GPU

Créer des matrices de GPU parcimonieuses

Vous pouvez créer un gpuArray parcimonieux soit en appelant sparse avec une entrée gpuArray, soit en appelant gpuArray avec une entrée parcimonieuse. Par exemple,

X = [0 1 0 0 0; 0 0 0 0 1]
     0     1     0     0     0
     0     0     0     0     1
S = sparse(X)
   (1,2)        1
   (2,5)        1
G = gpuArray(S);   % G is a sparse gpuArray
Gt = transpose(G); % Gt is a sparse gpuArray
F = full(Gt)       % F is a full gpuArray
     0     0
     1     0
     0     0
     0     0
     0     1

Indexation des matrices GPU

Les tableaux GPU parcimonieux prennent uniquement en charge le référencement de lignes ou de colonnes entières par index. Par exemple, pour accéder à la cinquième ligne de la matrice creuse A, appelez A(5,:) ou A(5,1:end) .

A = gpuArray.speye(10);
A(5,:)
   (1,5)       1
full(A(5,:))
     0     0     0     0     1     0     0     0     0     0

Pour localiser les éléments non nuls d’un tableau GPU parcimonieux, utilisez la fonction find. Vous pouvez ensuite remplacer les valeurs souhaitées et construire un nouveau gpuArray parcimonieux.

A = gpuArray.speye(10);
[row,col] = find(A);
[row,col]
     1     1
     2     2
     3     3
     4     4
     5     5
     6     6
     7     7
     8     8
     9     9
    10    10

L'attribution de valeurs à des tableaux GPU parcimonieux par index n'est pas supporté.

Fonctions prenant en charge les GPU Arrays parcimonieux

Ce tableau répertorie les fonctions qui prennent en charge les objets gpuArray parcimonieux.

abs
acos
acosd
acosh
acot
acotd
acoth
acsc
acscd
acsch
angle
asec
asecd
asech
asin
asind
asinh
atan
atand
atanh
bicg
bicgstab
ceil
cgs
classUnderlying
conj
cos
cosd
cosh
cospi
cot
cotd
coth
csc
cscd
csch
ctranspose
deg2rad
diag
end
eps
exp
expint
expm1
find
fix
floor
full
gmres
gpuArray.speye
imag
isaUnderlying
isdiag
isempty
isequal
isequaln
isfinite
isfloat
isinteger
islogical
isnumeric
isreal
issparse
istril
istriu
isUnderlyingType
length
log
log2
log10
log1p
lsqr
minus
mtimes
mpower
mustBeUnderlyingType
ndims
nextpow2
nnz
nonzeros
norm
numel
nzmax
pcg
plus
power
qmr
rad2deg
real
reallog
realsqrt
round
sec
secd
sech
sign
sin
sind
sinh
sinpi
size
sparse
spfun
spones
sprandsym
sqrt
subsref
sum
tan
tand
tanh
tfqmr
times (.*)
trace
transpose
tril
triu
uminus
underlyingType
uplus 

Voir aussi

| |

Rubriques