XU XUv0.16.0

#github.com/xulang-org/packages/gpu

import: gpu #github.com/xulang-org/packages/gpu

counts: 35 functions, 37 methods, 7 types, 4 constants, 0 method sets

Cross-platform unified GPU compute facade over Metal (macOS), CUDA (NVIDIA Linux/Windows), Vulkan (cross-platform SPIR-V compute), and pure-Xu CPU reference fallback.

github.com/xulang-org/packages · 1.17.2 · Install and use

const BACKEND_METAL

XuAPI
pub const BACKEND_METAL = 1

Purpose

Constant BACKEND_METAL, defining protocol or algorithm parameters.

const BACKEND_CUDA

XuAPI
pub const BACKEND_CUDA = 2

Purpose

Constant BACKEND_CUDA, defining protocol or algorithm parameters.

const BACKEND_VULKAN

XuAPI
pub const BACKEND_VULKAN = 3

Purpose

Constant BACKEND_VULKAN, defining protocol or algorithm parameters.

const BACKEND_CPU

XuAPI
pub const BACKEND_CPU = 4

Purpose

Constant BACKEND_CPU, defining protocol or algorithm parameters.

struct Device

XuAPI
pub struct Device {
    pub backend int
    pub dev_name string
    pub closed bool
}

Purpose

Structure encapsulating backend, dev_name, closed.

Public fields

backend int
field (int)
dev_name string
field (string)
closed bool
field (bool)

struct F32Matrix

XuAPI
pub struct F32Matrix {
    pub backend int
    pub n_rows int
    pub n_cols int
    pub closed bool
}

Purpose

Structure encapsulating backend, n_rows, n_cols, closed.

Public fields

backend int
field (int)
n_rows int
field (int)
n_cols int
field (int)
closed bool
field (bool)

struct Q4Matrix

XuAPI
pub struct Q4Matrix {
    pub backend int
    pub n_rows int
    pub n_cols int
    pub closed bool
}

Purpose

Structure encapsulating backend, n_rows, n_cols, closed.

Public fields

backend int
field (int)
n_rows int
field (int)
n_cols int
field (int)
closed bool
field (bool)

struct Q8Matrix

XuAPI
pub struct Q8Matrix {
    pub backend int
    pub n_rows int
    pub n_cols int
    pub closed bool
}

Purpose

Structure encapsulating backend, n_rows, n_cols, closed.

Public fields

backend int
field (int)
n_rows int
field (int)
n_cols int
field (int)
closed bool
field (bool)

struct Q4KMatrix

XuAPI
pub struct Q4KMatrix {
    pub backend int
    pub n_rows int
    pub n_cols int
    pub closed bool
}

Purpose

Structure encapsulating backend, n_rows, n_cols, closed.

Public fields

backend int
field (int)
n_rows int
field (int)
n_cols int
field (int)
closed bool
field (bool)

struct Q5KMatrix

XuAPI
pub struct Q5KMatrix {
    pub backend int
    pub n_rows int
    pub n_cols int
    pub closed bool
}

Purpose

Structure encapsulating backend, n_rows, n_cols, closed.

Public fields

backend int
field (int)
n_rows int
field (int)
n_cols int
field (int)
closed bool
field (bool)

struct Q6KMatrix

XuAPI
pub struct Q6KMatrix {
    pub backend int
    pub n_rows int
    pub n_cols int
    pub closed bool
}

Purpose

Structure encapsulating backend, n_rows, n_cols, closed.

Public fields

backend int
field (int)
n_rows int
field (int)
n_cols int
field (int)
closed bool
field (bool)

detect_backends

XuAPI
pub fn detect_backends() []string

Purpose

Detect backends.

Parameters

No arguments are required.

Returns

[]string — slice result

backend_name

XuAPI
pub fn backend_name(b int) string

Purpose

Backend name.

Parameters

b int
b (int)

Returns

string — result string

open_auto

XuAPI
pub fn open_auto() Device

Purpose

Open auto. Throws on failure; handle the error or propagate it to the caller.

Parameters

No arguments are required.

Returns

Device — a value of this type

open_backend

XuAPI
pub fn open_backend(name string) Device

Purpose

Open backend. Throws on failure; handle the error or propagate it to the caller.

Parameters

name string
name (string)

Returns

Device — a value of this type

(&Device) name

XuAPI
pub fn (d &Device) name() string

Purpose

Execute name on &Device.

Parameters

d &Device
The Device instance used by this call (borrow).

Returns

string — result string

(&Device) backend_id

XuAPI
pub fn (d &Device) backend_id() int

Purpose

Operation on &Device: backend id.

Parameters

d &Device
The Device instance used by this call (borrow).

Returns

int — a value of this type

($&Device) close

XuAPI
pub fn (d $&Device) close() int

Purpose

Operation on $&Device: close the resource.

Parameters

d $&Device
The Device instance used by this call (exclusive borrow).

Returns

int — a value of this type

(&Device) matrix_f32

XuAPI
pub fn (d &Device) matrix_f32(rows int, columns int) F32Matrix

Purpose

Operation on &Device: matrix f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

d &Device
The Device instance used by this call (borrow).
rows int
rows (int)
columns int
columns (int)

Returns

F32Matrix — a value of this type

(&F32Matrix) rows

XuAPI
pub fn (m &F32Matrix) rows() int

Purpose

Execute rows on &F32Matrix.

Parameters

m &F32Matrix
The F32Matrix instance used by this call (borrow).

Returns

int — a value of this type

(&F32Matrix) columns

XuAPI
pub fn (m &F32Matrix) columns() int

Purpose

Execute columns on &F32Matrix.

Parameters

m &F32Matrix
The F32Matrix instance used by this call (borrow).

Returns

int — a value of this type

($&F32Matrix) write_bits

XuAPI
pub fn (m $&F32Matrix) write_bits(values &[]int) int

Purpose

Operation on $&F32Matrix: write bits. Throws on failure; handle the error or propagate it to the caller.

Parameters

m $&F32Matrix
The F32Matrix instance used by this call (exclusive borrow).
values &[]int
values (read-only borrow; caller keeps the original; type &[]int)

Returns

int — a value of this type

($&F32Matrix) write_f32

XuAPI
pub fn (m $&F32Matrix) write_f32(values &[]f32) int

Purpose

Operation on $&F32Matrix: write f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

m $&F32Matrix
The F32Matrix instance used by this call (exclusive borrow).
values &[]f32
values (read-only borrow; caller keeps the original; type &[]f32)

Returns

int — a value of this type

(&F32Matrix) copy_bits

XuAPI
pub fn (m &F32Matrix) copy_bits(out $&[]int) int

Purpose

Operation on &F32Matrix: copy bits. Throws on failure; handle the error or propagate it to the caller.

Parameters

m &F32Matrix
The F32Matrix instance used by this call (borrow).
out $&[]int
out (exclusive borrow; may modify the original; type $&[]int)

Returns

int — a value of this type

(&F32Matrix) bits

XuAPI
pub fn (m &F32Matrix) bits() []int

Purpose

Execute bits on &F32Matrix. Throws on failure; handle the error or propagate it to the caller.

Parameters

m &F32Matrix
The F32Matrix instance used by this call (borrow).

Returns

[]int — slice result

(&F32Matrix) to_f32

XuAPI
pub fn (m &F32Matrix) to_f32() []f32

Purpose

Operation on &F32Matrix: convert to f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

m &F32Matrix
The F32Matrix instance used by this call (borrow).

Returns

[]f32 — slice result

($&F32Matrix) close

XuAPI
pub fn (m $&F32Matrix) close() int

Purpose

Operation on $&F32Matrix: close the resource.

Parameters

m $&F32Matrix
The F32Matrix instance used by this call (exclusive borrow).

Returns

int — a value of this type

(&Device) matrix_q4_0

XuAPI
pub fn (d &Device) matrix_q4_0(rows int, columns int) Q4Matrix

Purpose

Operation on &Device: matrix q4 0. Throws on failure; handle the error or propagate it to the caller.

Parameters

d &Device
The Device instance used by this call (borrow).
rows int
rows (int)
columns int
columns (int)

Returns

Q4Matrix — a value of this type

(&Q4Matrix) rows

XuAPI
pub fn (m &Q4Matrix) rows() int

Purpose

Execute rows on &Q4Matrix.

Parameters

m &Q4Matrix
The Q4Matrix instance used by this call (borrow).

Returns

int — a value of this type

(&Q4Matrix) columns

XuAPI
pub fn (m &Q4Matrix) columns() int

Purpose

Execute columns on &Q4Matrix.

Parameters

m &Q4Matrix
The Q4Matrix instance used by this call (borrow).

Returns

int — a value of this type

($&Q4Matrix) write_bytes

XuAPI
pub fn (m $&Q4Matrix) write_bytes(bytes &string) int

Purpose

Operation on $&Q4Matrix: write bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

m $&Q4Matrix
The Q4Matrix instance used by this call (exclusive borrow).
bytes &string
bytes (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

($&Q4Matrix) close

XuAPI
pub fn (m $&Q4Matrix) close() int

Purpose

Operation on $&Q4Matrix: close the resource.

Parameters

m $&Q4Matrix
The Q4Matrix instance used by this call (exclusive borrow).

Returns

int — a value of this type

(&Device) matrix_q8_0

XuAPI
pub fn (d &Device) matrix_q8_0(rows int, columns int) Q8Matrix

Purpose

Operation on &Device: matrix q8 0. Throws on failure; handle the error or propagate it to the caller.

Parameters

d &Device
The Device instance used by this call (borrow).
rows int
rows (int)
columns int
columns (int)

Returns

Q8Matrix — a value of this type

(&Q8Matrix) rows

XuAPI
pub fn (m &Q8Matrix) rows() int

Purpose

Execute rows on &Q8Matrix.

Parameters

m &Q8Matrix
The Q8Matrix instance used by this call (borrow).

Returns

int — a value of this type

(&Q8Matrix) columns

XuAPI
pub fn (m &Q8Matrix) columns() int

Purpose

Execute columns on &Q8Matrix.

Parameters

m &Q8Matrix
The Q8Matrix instance used by this call (borrow).

Returns

int — a value of this type

($&Q8Matrix) write_bytes

XuAPI
pub fn (m $&Q8Matrix) write_bytes(bytes &string) int

Purpose

Operation on $&Q8Matrix: write bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

m $&Q8Matrix
The Q8Matrix instance used by this call (exclusive borrow).
bytes &string
bytes (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

($&Q8Matrix) close

XuAPI
pub fn (m $&Q8Matrix) close() int

Purpose

Operation on $&Q8Matrix: close the resource.

Parameters

m $&Q8Matrix
The Q8Matrix instance used by this call (exclusive borrow).

Returns

int — a value of this type

(&Device) matrix_q4_k

XuAPI
pub fn (d &Device) matrix_q4_k(rows int, columns int) Q4KMatrix

Purpose

Operation on &Device: matrix q4 k. Throws on failure; handle the error or propagate it to the caller.

Parameters

d &Device
The Device instance used by this call (borrow).
rows int
rows (int)
columns int
columns (int)

Returns

Q4KMatrix — a value of this type

(&Q4KMatrix) rows

XuAPI
pub fn (m &Q4KMatrix) rows() int

Purpose

Execute rows on &Q4KMatrix.

Parameters

m &Q4KMatrix
The Q4KMatrix instance used by this call (borrow).

Returns

int — a value of this type

(&Q4KMatrix) columns

XuAPI
pub fn (m &Q4KMatrix) columns() int

Purpose

Execute columns on &Q4KMatrix.

Parameters

m &Q4KMatrix
The Q4KMatrix instance used by this call (borrow).

Returns

int — a value of this type

($&Q4KMatrix) write_bytes

XuAPI
pub fn (m $&Q4KMatrix) write_bytes(bytes &string) int

Purpose

Operation on $&Q4KMatrix: write bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

m $&Q4KMatrix
The Q4KMatrix instance used by this call (exclusive borrow).
bytes &string
bytes (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

($&Q4KMatrix) close

XuAPI
pub fn (m $&Q4KMatrix) close() int

Purpose

Operation on $&Q4KMatrix: close the resource.

Parameters

m $&Q4KMatrix
The Q4KMatrix instance used by this call (exclusive borrow).

Returns

int — a value of this type

(&Device) matrix_q5_k

XuAPI
pub fn (d &Device) matrix_q5_k(rows int, columns int) Q5KMatrix

Purpose

Operation on &Device: matrix q5 k. Throws on failure; handle the error or propagate it to the caller.

Parameters

d &Device
The Device instance used by this call (borrow).
rows int
rows (int)
columns int
columns (int)

Returns

Q5KMatrix — a value of this type

(&Q5KMatrix) rows

XuAPI
pub fn (m &Q5KMatrix) rows() int

Purpose

Execute rows on &Q5KMatrix.

Parameters

m &Q5KMatrix
The Q5KMatrix instance used by this call (borrow).

Returns

int — a value of this type

(&Q5KMatrix) columns

XuAPI
pub fn (m &Q5KMatrix) columns() int

Purpose

Execute columns on &Q5KMatrix.

Parameters

m &Q5KMatrix
The Q5KMatrix instance used by this call (borrow).

Returns

int — a value of this type

($&Q5KMatrix) write_bytes

XuAPI
pub fn (m $&Q5KMatrix) write_bytes(bytes &string) int

Purpose

Operation on $&Q5KMatrix: write bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

m $&Q5KMatrix
The Q5KMatrix instance used by this call (exclusive borrow).
bytes &string
bytes (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

($&Q5KMatrix) close

XuAPI
pub fn (m $&Q5KMatrix) close() int

Purpose

Operation on $&Q5KMatrix: close the resource.

Parameters

m $&Q5KMatrix
The Q5KMatrix instance used by this call (exclusive borrow).

Returns

int — a value of this type

(&Device) matrix_q6_k

XuAPI
pub fn (d &Device) matrix_q6_k(rows int, columns int) Q6KMatrix

Purpose

Operation on &Device: matrix q6 k. Throws on failure; handle the error or propagate it to the caller.

Parameters

d &Device
The Device instance used by this call (borrow).
rows int
rows (int)
columns int
columns (int)

Returns

Q6KMatrix — a value of this type

(&Q6KMatrix) rows

XuAPI
pub fn (m &Q6KMatrix) rows() int

Purpose

Execute rows on &Q6KMatrix.

Parameters

m &Q6KMatrix
The Q6KMatrix instance used by this call (borrow).

Returns

int — a value of this type

(&Q6KMatrix) columns

XuAPI
pub fn (m &Q6KMatrix) columns() int

Purpose

Execute columns on &Q6KMatrix.

Parameters

m &Q6KMatrix
The Q6KMatrix instance used by this call (borrow).

Returns

int — a value of this type

($&Q6KMatrix) write_bytes

XuAPI
pub fn (m $&Q6KMatrix) write_bytes(bytes &string) int

Purpose

Operation on $&Q6KMatrix: write bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

m $&Q6KMatrix
The Q6KMatrix instance used by this call (exclusive borrow).
bytes &string
bytes (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

($&Q6KMatrix) close

XuAPI
pub fn (m $&Q6KMatrix) close() int

Purpose

Operation on $&Q6KMatrix: close the resource.

Parameters

m $&Q6KMatrix
The Q6KMatrix instance used by this call (exclusive borrow).

Returns

int — a value of this type

gemm_f32

XuAPI
pub fn gemm_f32(dev $&Device, dst $&F32Matrix, a &F32Matrix, b &F32Matrix) int

Purpose

Gemm f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
a &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
b &F32Matrix
b (read-only borrow; caller keeps the original; type &F32Matrix)

Returns

int — a value of this type

gemm_f32_nt

XuAPI
pub fn gemm_f32_nt(dev $&Device, dst $&F32Matrix, a &F32Matrix, b &F32Matrix) int

Purpose

Gemm f32 nt. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
a &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
b &F32Matrix
b (read-only borrow; caller keeps the original; type &F32Matrix)

Returns

int — a value of this type

gemm_f32_tn

XuAPI
pub fn gemm_f32_tn(dev $&Device, dst $&F32Matrix, a &F32Matrix, b &F32Matrix) int

Purpose

Gemm f32 tn. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
a &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
b &F32Matrix
b (read-only borrow; caller keeps the original; type &F32Matrix)

Returns

int — a value of this type

add_f32

XuAPI
pub fn add_f32(dev $&Device, dst $&F32Matrix, a &F32Matrix, b &F32Matrix) int

Purpose

Add f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
a &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
b &F32Matrix
b (read-only borrow; caller keeps the original; type &F32Matrix)

Returns

int — a value of this type

mul_f32

XuAPI
pub fn mul_f32(dev $&Device, dst $&F32Matrix, a &F32Matrix, b &F32Matrix) int

Purpose

Mul f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
a &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
b &F32Matrix
b (read-only borrow; caller keeps the original; type &F32Matrix)

Returns

int — a value of this type

scale_f32

XuAPI
pub fn scale_f32(dev $&Device, dst $&F32Matrix, x &F32Matrix, alpha f64) int

Purpose

Scale f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
x &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
alpha f64
alpha (f64)

Returns

int — a value of this type

rmsnorm_f32

XuAPI
pub fn rmsnorm_f32(dev $&Device, dst $&F32Matrix, x &F32Matrix, weight &F32Matrix, eps f64) int

Purpose

Rmsnorm f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
x &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
weight &F32Matrix
weight (read-only borrow; caller keeps the original; type &F32Matrix)
eps f64
eps (f64)

Returns

int — a value of this type

softmax_f32

XuAPI
pub fn softmax_f32(dev $&Device, dst $&F32Matrix, x &F32Matrix) int

Purpose

Softmax f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
x &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)

Returns

int — a value of this type

swiglu_f32

XuAPI
pub fn swiglu_f32(dev $&Device, dst $&F32Matrix, gate &F32Matrix, up &F32Matrix) int

Purpose

Swiglu f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
gate &F32Matrix
gate (read-only borrow; caller keeps the original; type &F32Matrix)
up &F32Matrix
up (read-only borrow; caller keeps the original; type &F32Matrix)

Returns

int — a value of this type

rope_f32

XuAPI
pub fn rope_f32(dev $&Device, dst $&F32Matrix, x &F32Matrix, pos_offset int, head_dim int, theta f64) int

Purpose

Rope f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
x &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
pos_offset int
pos_offset (int)
head_dim int
head_dim (int)
theta f64
theta (f64)

Returns

int — a value of this type

gemv_q4_0_f32

XuAPI
pub fn gemv_q4_0_f32(dev $&Device, dst $&F32Matrix, x &F32Matrix, w &Q4Matrix) int

Purpose

Gemv q4 0 f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
x &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
w &Q4Matrix
writer or width (read-only borrow; caller keeps the original; type &Q4Matrix)

Returns

int — a value of this type

gemv_q8_0_f32

XuAPI
pub fn gemv_q8_0_f32(dev $&Device, dst $&F32Matrix, x &F32Matrix, w &Q8Matrix) int

Purpose

Gemv q8 0 f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
x &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
w &Q8Matrix
writer or width (read-only borrow; caller keeps the original; type &Q8Matrix)

Returns

int — a value of this type

gemv_q4_k_f32

XuAPI
pub fn gemv_q4_k_f32(dev $&Device, dst $&F32Matrix, x &F32Matrix, w &Q4KMatrix) int

Purpose

Gemv q4 k f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
x &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
w &Q4KMatrix
writer or width (read-only borrow; caller keeps the original; type &Q4KMatrix)

Returns

int — a value of this type

gemv_q5_k_f32

XuAPI
pub fn gemv_q5_k_f32(dev $&Device, dst $&F32Matrix, x &F32Matrix, w &Q5KMatrix) int

Purpose

Gemv q5 k f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
x &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
w &Q5KMatrix
writer or width (read-only borrow; caller keeps the original; type &Q5KMatrix)

Returns

int — a value of this type

gemv_q6_k_f32

XuAPI
pub fn gemv_q6_k_f32(dev $&Device, dst $&F32Matrix, x &F32Matrix, w &Q6KMatrix) int

Purpose

Gemv q6 k f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

dev $&Device
dev (exclusive borrow; may modify the original; type $&Device)
dst $&F32Matrix
destination (exclusive borrow; may modify the original; type $&F32Matrix)
x &F32Matrix
value (read-only borrow; caller keeps the original; type &F32Matrix)
w &Q6KMatrix
writer or width (read-only borrow; caller keeps the original; type &Q6KMatrix)

Returns

int — a value of this type

f16_bits_to_f64

XuAPI
pub fn f16_bits_to_f64(bits int) f64

Purpose

F16 bits to f64.

Parameters

bits int
bit count (int)

Returns

f64 — a value of this type

cpu_gemm_f32

XuAPI
pub fn cpu_gemm_f32(dst $&[]int, a &[]int, b &[]int, m int, n int, k int)

Purpose

Cpu gemm f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
a &[]int
slice to operate on (read-only borrow; caller keeps the original; type &[]int)
b &[]int
slice to operate on (read-only borrow; caller keeps the original; type &[]int)
m int
m (int)
n int
count, length, or limit (int)
k int
key or index (int)

Returns

This call does not return a value.

cpu_gemm_f32_nt

XuAPI
pub fn cpu_gemm_f32_nt(dst $&[]int, a &[]int, b &[]int, m int, n int, k int)

Purpose

Cpu gemm f32 nt.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
a &[]int
slice to operate on (read-only borrow; caller keeps the original; type &[]int)
b &[]int
slice to operate on (read-only borrow; caller keeps the original; type &[]int)
m int
m (int)
n int
count, length, or limit (int)
k int
key or index (int)

Returns

This call does not return a value.

cpu_gemm_f32_tn

XuAPI
pub fn cpu_gemm_f32_tn(dst $&[]int, a &[]int, b &[]int, m int, n int, k int)

Purpose

Cpu gemm f32 tn.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
a &[]int
slice to operate on (read-only borrow; caller keeps the original; type &[]int)
b &[]int
slice to operate on (read-only borrow; caller keeps the original; type &[]int)
m int
m (int)
n int
count, length, or limit (int)
k int
key or index (int)

Returns

This call does not return a value.

cpu_add_f32

XuAPI
pub fn cpu_add_f32(dst $&[]int, a &[]int, b &[]int)

Purpose

Cpu add f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
a &[]int
slice to operate on (read-only borrow; caller keeps the original; type &[]int)
b &[]int
slice to operate on (read-only borrow; caller keeps the original; type &[]int)

Returns

This call does not return a value.

cpu_mul_f32

XuAPI
pub fn cpu_mul_f32(dst $&[]int, a &[]int, b &[]int)

Purpose

Cpu mul f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
a &[]int
slice to operate on (read-only borrow; caller keeps the original; type &[]int)
b &[]int
slice to operate on (read-only borrow; caller keeps the original; type &[]int)

Returns

This call does not return a value.

cpu_scale_f32

XuAPI
pub fn cpu_scale_f32(dst $&[]int, x &[]int, alpha f64)

Purpose

Cpu scale f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
x &[]int
value (read-only borrow; caller keeps the original; type &[]int)
alpha f64
alpha (f64)

Returns

This call does not return a value.

cpu_rmsnorm_f32

XuAPI
pub fn cpu_rmsnorm_f32(dst $&[]int, x &[]int, w &[]int, rows int, cols int, eps f64)

Purpose

Cpu rmsnorm f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
x &[]int
value (read-only borrow; caller keeps the original; type &[]int)
w &[]int
writer or width (read-only borrow; caller keeps the original; type &[]int)
rows int
rows (int)
cols int
cols (int)
eps f64
eps (f64)

Returns

This call does not return a value.

cpu_softmax_f32

XuAPI
pub fn cpu_softmax_f32(dst $&[]int, x &[]int, rows int, cols int)

Purpose

Cpu softmax f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
x &[]int
value (read-only borrow; caller keeps the original; type &[]int)
rows int
rows (int)
cols int
cols (int)

Returns

This call does not return a value.

cpu_swiglu_f32

XuAPI
pub fn cpu_swiglu_f32(dst $&[]int, gate &[]int, up &[]int)

Purpose

Cpu swiglu f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
gate &[]int
gate (read-only borrow; caller keeps the original; type &[]int)
up &[]int
up (read-only borrow; caller keeps the original; type &[]int)

Returns

This call does not return a value.

cpu_rope_f32

XuAPI
pub fn cpu_rope_f32(dst $&[]int, x &[]int, seq_len int, n_heads int, head_dim int, pos_off int, theta f64)

Purpose

Cpu rope f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
x &[]int
value (read-only borrow; caller keeps the original; type &[]int)
seq_len int
seq_len (int)
n_heads int
n_heads (int)
head_dim int
head_dim (int)
pos_off int
pos_off (int)
theta f64
theta (f64)

Returns

This call does not return a value.

cpu_gemv_q4_0_f32

XuAPI
pub fn cpu_gemv_q4_0_f32(dst $&[]int, x &[]int, w &string, rows int, cols int, m_cnt int)

Purpose

Cpu gemv q4 0 f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
x &[]int
value (read-only borrow; caller keeps the original; type &[]int)
w &string
writer or width (read-only borrow; caller keeps the original; type &string)
rows int
rows (int)
cols int
cols (int)
m_cnt int
m_cnt (int)

Returns

This call does not return a value.

cpu_gemv_q8_0_f32

XuAPI
pub fn cpu_gemv_q8_0_f32(dst $&[]int, x &[]int, w &string, rows int, cols int, m_cnt int)

Purpose

Cpu gemv q8 0 f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
x &[]int
value (read-only borrow; caller keeps the original; type &[]int)
w &string
writer or width (read-only borrow; caller keeps the original; type &string)
rows int
rows (int)
cols int
cols (int)
m_cnt int
m_cnt (int)

Returns

This call does not return a value.

cpu_gemv_q4_k_f32

XuAPI
pub fn cpu_gemv_q4_k_f32(dst $&[]int, x &[]int, w &string, rows int, cols int, m_cnt int)

Purpose

Cpu gemv q4 k f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
x &[]int
value (read-only borrow; caller keeps the original; type &[]int)
w &string
writer or width (read-only borrow; caller keeps the original; type &string)
rows int
rows (int)
cols int
cols (int)
m_cnt int
m_cnt (int)

Returns

This call does not return a value.

cpu_gemv_q5_k_f32

XuAPI
pub fn cpu_gemv_q5_k_f32(dst $&[]int, x &[]int, w &string, rows int, cols int, m_cnt int)

Purpose

Cpu gemv q5 k f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
x &[]int
value (read-only borrow; caller keeps the original; type &[]int)
w &string
writer or width (read-only borrow; caller keeps the original; type &string)
rows int
rows (int)
cols int
cols (int)
m_cnt int
m_cnt (int)

Returns

This call does not return a value.

cpu_gemv_q6_k_f32

XuAPI
pub fn cpu_gemv_q6_k_f32(dst $&[]int, x &[]int, w &string, rows int, cols int, m_cnt int)

Purpose

Cpu gemv q6 k f32.

Parameters

dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
x &[]int
value (read-only borrow; caller keeps the original; type &[]int)
w &string
writer or width (read-only borrow; caller keeps the original; type &string)
rows int
rows (int)
cols int
cols (int)
m_cnt int
m_cnt (int)

Returns

This call does not return a value.