isgpuarray — Return true when a value is stored as a gpuArray handle.
tf = isgpuarray(x) returns a logical scalar that is true when x is a gpuArray handle. All other value kinds, including numeric arrays, logical arrays, characters, structs, and objects, return false.
How does the isgpuarray function behave in MATLAB / RunMat?
- gpuArray values return
truewithout gathering device buffers. - Numeric, logical, complex, string, character, struct, cell, and object inputs return
false. - The result is always a logical scalar.
GPU behavior
The builtin only checks whether the value is a gpuArray handle. It never gathers device buffers or inspects the underlying data contents.
GPU residency
RunMat keeps data on the GPU when a provider is active, and isgpuarray lets you verify residency boundaries in MATLAB-style code.
Examples of using isgpuarray in MATLAB / RunMat
Checking a gpuArray handle
G = gpuArray(reshape(1:12, [3 4]));
tf = isgpuarray(G)Expected output:
tf =
1Host arrays are not gpuArray values
A = [1 2 3];
tf = isgpuarray(A)Expected output:
tf =
0FAQ
Does isgpuarray gather data back to the host?
No. It inspects value metadata and returns a logical scalar without triggering a device transfer.
What happens if no acceleration provider is registered?
isgpuarray still reports accurately for values that are already gpuArray handles. If a value is not a gpuArray handle, it returns false.
See also
gpuArray, gather, islogical, isa
Source & Feedback
- Source code: `crates/runmat-runtime/src/builtins/logical/tests/isgpuarray.rs`
- Found a bug? Open an issue with a minimal reproduction.