hanzo-ml 0.11.25

Fast multi-backend tensor & ML framework for Rust (CPU/CUDA/Metal/Vulkan/ROCm) with quantization — the compute core of the Hanzo stack.
Documentation
#version 450
// scatter set along `dim`. ids/src share a shape; for src flat index g = (outer, j, inner)
// with inner < right and j < dim_src, write dst[outer*(dim_dst*right) + ids[g]*right + inner] = src[g].
// (Duplicate ids -> last writer wins, which is unspecified but matches hanzo-ml's contract.)
layout(local_size_x = 64) in;
layout(set = 0, binding = 0) buffer Dst { float dst[]; };
layout(set = 0, binding = 1) readonly buffer Src { float src[]; };
layout(set = 0, binding = 2) readonly buffer Ids { uint ids[]; };
layout(push_constant) uniform Pc { uint n; uint right; uint dim_src; uint dim_dst; };
void main() {
    uint g = gl_GlobalInvocationID.x;
    if (g >= n) { return; }
    uint inner = g % right;
    uint outer = g / (right * dim_src);
    uint id = ids[g];
    // Bounds-check the index: a stray id (corrupt/model-bug) must not write OOB in dst.
    if (id < dim_dst) {
        dst[outer * (dim_dst * right) + id * right + inner] = src[g];
    }
}