gpuMatMul (Function)
Signature: gpuMatMul(left: GpuBuffer<float> | GpuBuffer<float32>, right: GpuBuffer<t0>, rows: int, inner: int, cols: int) -> Result<GpuBuffer<t0>, Error>
Description: The dense row-major product of a rows x inner float buffer and an inner x cols one, as a rows x cols buffer. Both operands have the same float or float32 element type. Every element accumulates in k order from 0.0 at that width, without fused multiply-add; a length that disagrees with the stated shape is an Error naming the operand.
Parameters
- left (
GpuBuffer<float> | GpuBuffer<float32>): The rows x inner buffer - right (
GpuBuffer<t0>): The inner x cols buffer - rows (
int): The left operand's row count - inner (
int): The shared dimension - cols (
int): The right operand's column count
Returns: Result<GpuBuffer<t0>, Error>
Example
match toGpu([1.0, 2.0, 3.0, 4.0]) {
Success { value } => { let left = value
match toGpu([5.0, 6.0, 7.0, 8.0]) {
Success { value } => { let right = value
match gpuMatMul(left, right, 2, 2, 2) {
Success { value } => match gpuGet(value, 0) {
Success { value } => print(value)
Error { message } => print(message)
}
Error { message } => print(message)
}
}
Error { message } => print(message)
}
}
Error { message } => print(message)
}
left = toGpu [1.0, 2.0, 3.0, 4.0]
right = toGpu [5.0, 6.0, 7.0, 8.0]
match gpuMatMul (left, right, 2, 2, 2)
Success value => print (gpuGet (value, 0) ?: 0.0) // 19.0
Error message => print message