Module ml::gpu_spirv
Structs
| SpirvBuf | A Vulkan device buffer. 'handle' is its buffer device address (what the kernels and VulkanTensor.device_buffer() name it by), 0 for an invalid (failed or freed) buffer; every op returns 0 for one. 'bytes' is the size it was made with, 'dtype' its element type (informational: the ops below take fp32). Buffers come from the device's memory cache; free() returns one to it, exactly once, and may wait for queued work that uses it. |
Functions
| spirv_add | out may be an input (in place). 1 = queued, 0 = no device or an invalid or too small buffer. |
| spirv_sub | |
| spirv_mul | |
| spirv_div | |
| spirv_pow | a^b as exp(b log a) and sqrt(a) as exp(log(a) / 2): for a >= 0 (a negative base gives NaN, as powf does for a non-integer exponent). |
| spirv_sqrt | |
| spirv_relu | |
| spirv_log | |
| spirv_exp | |
| spirv_scale | |
| spirv_sum | out[0] = the sum of a's n values (out must not be a) |
| spirv_matmul | out [M, N] = a [M, K] . b [K, N], row-major |
| spirv_sync | Waits for every queued op. 1 on success. |
| spirv_add_f32 | 1 = done on the GPU, 0 = no device (out untouched): compute on the CPU. |
| spirv_sub_f32 | |
| spirv_mul_f32 | |
| spirv_div_f32 | |
| spirv_pow_f32 | |
| spirv_relu_f32 | |
| spirv_log_f32 | |
| spirv_exp_f32 | |
| spirv_sqrt_f32 | |
| spirv_scale_f32 | |
| spirv_sum_f32 | |
| spirv_matmul_f32 | |
| spirv_available | 1 if a Vulkan GPU the backend can use is present (initializes it). |
Macros
| SPIRV_FP16 | Element types of a buffer (SpirvBuf.dtype): 0 = fp32, or 16-bit values. |
| SPIRV_BF16 |