isgpuarray — Test whether values are gpuArray handles in MATLAB and RunMat.
tf = isgpuarray(x) returns true when x is a gpuArray handle and false for other value types, following MATLAB semantics.
Syntax
tf = isgpuarray(A)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
A | Any | Yes | — | Input value to test. |
Returns
| Name | Type | Description |
|---|---|---|
tf | LogicalArray | True when input is a gpuArray handle. |
How isgpuarray works
- 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.
Does RunMat run isgpuarray on the GPU?
The builtin only checks whether the value is a gpuArray handle. It never gathers device buffers or inspects the underlying data contents.
GPU memory and residency
RunMat keeps data on the GPU when a provider is active, and isgpuarray lets you verify residency boundaries in MATLAB-style code.
Examples
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 =
0Using isgpuarray with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how isgpuarray changes the result.
Run a small isgpuarray example, explain the result, then change one input and compare the output.
FAQ
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.
Related Logical functions
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how isgpuarray is executed, line by line, in Rust.
- View the source for isgpuarray in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.