MicroGPT::CuBLASBackend
Inherits MicroGPT::Backend < Reference < Object
Constants
DeviceToDevice = 3
DeviceToHost = 2
HostToDevice = 1
Constructors
new
SourceInstance methods
add(a : Mat, b : Mat) : Mat
Sourceadd!(a : Mat, b : Mat)
Sourcebatched_matmul(a_list : Array(Mat), b_list : Array(Mat), transpose_a : Bool, transpose_b : Bool) : Array(Mat)
Sourcebias_add(data : Mat, bias : Mat)
Sourcecausal_mask(scores : Mat)
SourceGPU-side embedding gather: output[pos, j] = token_emb[ids[pos], j]
embedding_scatter_add(grad : Mat, ids : Array(Int32), d_token_emb : Mat, seq_len : Int32, d_model : Int32)
GPU-side embedding backward: scatter-add gradients back to d_token_emb
finalize
SourceFused attention: scale + causal mask + softmax in one pass Default implementation falls back to separate ops
Fused bias + ReLU: add bias then apply ReLU in one pass Default falls back to separate ops
Fused softmax + CE loss + gradient in one kernel launch
handle
Sourcematmul_into(a : Mat, b : Mat, dst : Mat)
Sourcerelease(a : Mat)
Sourcerelu_backward(grad : Mat, mask : Mat) : Mat
Sourcerope_apply(x : Mat, cos_cache : Mat, sin_cache : Mat)
RoPE: apply/inverse on GPU if available, default is no-op (handled by RoPE class on CPU)
rope_apply_inverse(x : Mat, cos_cache : Mat, sin_cache : Mat)
Sourcesoftmax_backward(s : Mat, ds : Mat) : Mat
Sourcesync
Sourcetranspose(a : Mat) : Mat
Source