gpuArray
Determine whether input is gpuArray
TF = isgpuarray(X)
example
TF = isgpuarray(X) returns logical 1 (true) if X is a gpuArray, and logical 0 (false) otherwise. You can use this function with an if statement to avoid executing code that expects gpuArray input.
TF
X
1
true
0
false
if
collapse all
Create an array of random numbers.
X = rand(3,3);
Copy the array onto the GPU.
Y = gpuArray(X);
Use the function isgpuArray to verify that Y is a gpuArray.
isgpuArray
Y
isgpuArray(Y)
ans = 1
Verify that X is not a gpuArray.
isgpuarray(X)
ans = 0
Input variable, specified as a workspace variable. X can be any data type.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU.
canUseGPU | existsOnGPU | gather | gpuArray
canUseGPU
existsOnGPU
gather