#tile
Xu 0.13.1 API
导入方式: #tile
公开 API: 33 函数, 0 方法, 5 类型, 16 常量, 0 方法集
标准库包 `#tile`。
gemm_i64
pub fn gemm_i64(c $&[]int, a &[]int, b &[]int, m int, n int, k int)
用途
通用 64 位整数矩阵乘法计算(C = A * B + C)。
参数
c $&[]int- 字节或字符码(独占借用,可修改原值;类型 $&[]int)
a &[]int- 要处理的切片(只读借用,调用方仍持有原值;类型 &[]int)
b &[]int- 要处理的切片(只读借用,调用方仍持有原值;类型 &[]int)
m int- m(int)
n int- 数量、长度或上限(int)
k int- 键或下标(int)
返回值
不返回值。
gemm_f64
pub fn gemm_f64(c $&[]f64, a &[]f64, b &[]f64, m int, n int, k int)
用途
通用 64 位浮点矩阵乘法计算(C = alpha * A * B + beta * C)。
参数
c $&[]f64- 字节或字符码(独占借用,可修改原值;类型 $&[]f64)
a &[]f64- 要处理的切片(只读借用,调用方仍持有原值;类型 &[]f64)
b &[]f64- 要处理的切片(只读借用,调用方仍持有原值;类型 &[]f64)
m int- m(int)
n int- 数量、长度或上限(int)
k int- 键或下标(int)
返回值
不返回值。
madd_i64
pub fn madd_i64(c $&[]int, off_c int, b &[]int, off_b int, factor int, len int)
用途
矩阵乘累加运算。
参数
c $&[]int- 字节或字符码(独占借用,可修改原值;类型 $&[]int)
off_c int- off_c(int)
b &[]int- 要处理的切片(只读借用,调用方仍持有原值;类型 &[]int)
off_b int- off_b(int)
factor int- factor(int)
len int- len(int)
返回值
不返回值。
fill_i64
pub fn fill_i64(dst $&[]int, val int, len int)
用途
使用指定标量整数填充矩阵或切片区域。
参数
dst $&[]int- 目标(独占借用,可修改原值;类型 $&[]int)
val int- 值(int)
len int- len(int)
返回值
不返回值。
copy_i64
pub fn copy_i64(dst $&[]int, src &[]int, len int)
用途
拷贝i64。
参数
dst $&[]int- 目标(独占借用,可修改原值;类型 $&[]int)
src &[]int- 源数据(只读借用,调用方仍持有原值;类型 &[]int)
len int- len(int)
返回值
不返回值。
sum_i64
pub fn sum_i64(src &[]int, len int) int
用途
摘要i64。
参数
src &[]int- 源数据(只读借用,调用方仍持有原值;类型 &[]int)
len int- len(int)
返回值
int — 该类型的值
const DL_DEVICE_CPU
pub const DL_DEVICE_CPU = 1
用途
常量 DL_DEVICE_CPU,定义了相关的协议或算法配置参数。
const DL_DEVICE_CUDA
pub const DL_DEVICE_CUDA = 2
用途
常量 DL_DEVICE_CUDA,定义了相关的协议或算法配置参数。
const DL_DEVICE_CPU_PINNED
pub const DL_DEVICE_CPU_PINNED = 3
用途
常量 DL_DEVICE_CPU_PINNED,定义了相关的协议或算法配置参数。
const DL_DEVICE_OPENCL
pub const DL_DEVICE_OPENCL = 4
用途
常量 DL_DEVICE_OPENCL,定义了相关的协议或算法配置参数。
const DL_DEVICE_VULKAN
pub const DL_DEVICE_VULKAN = 7
用途
常量 DL_DEVICE_VULKAN,定义了相关的协议或算法配置参数。
const DL_DEVICE_METAL
pub const DL_DEVICE_METAL = 8
用途
常量 DL_DEVICE_METAL,定义了相关的协议或算法配置参数。
const DL_DEVICE_VPI
pub const DL_DEVICE_VPI = 9
用途
常量 DL_DEVICE_VPI,定义了相关的协议或算法配置参数。
const DL_DEVICE_ROCM
pub const DL_DEVICE_ROCM = 10
用途
常量 DL_DEVICE_ROCM,定义了相关的协议或算法配置参数。
const DL_DEVICE_ONEAPI
pub const DL_DEVICE_ONEAPI = 14
用途
常量 DL_DEVICE_ONEAPI,定义了相关的协议或算法配置参数。
const DL_DTYPE_INT
pub const DL_DTYPE_INT = 0
用途
常量 DL_DTYPE_INT,定义了相关的协议或算法配置参数。
const DL_DTYPE_UINT
pub const DL_DTYPE_UINT = 1
用途
常量 DL_DTYPE_UINT,定义了相关的协议或算法配置参数。
const DL_DTYPE_FLOAT
pub const DL_DTYPE_FLOAT = 2
用途
常量 DL_DTYPE_FLOAT,定义了相关的协议或算法配置参数。
const DL_DTYPE_OPAQUE
pub const DL_DTYPE_OPAQUE = 3
用途
常量 DL_DTYPE_OPAQUE,定义了相关的协议或算法配置参数。
const DL_DTYPE_BFLOAT
pub const DL_DTYPE_BFLOAT = 4
用途
常量 DL_DTYPE_BFLOAT,定义了相关的协议或算法配置参数。
const DL_DTYPE_COMPLEX
pub const DL_DTYPE_COMPLEX = 5
用途
常量 DL_DTYPE_COMPLEX,定义了相关的协议或算法配置参数。
const DL_DTYPE_BOOL
pub const DL_DTYPE_BOOL = 6
用途
常量 DL_DTYPE_BOOL,定义了相关的协议或算法配置参数。
struct DLDevice
pub struct DLDevice {
pub device_type int
pub device_id int
}
用途
承载 device_type、device_id 等属性的结构体。
公开字段
device_type int- 字段(int)
device_id int- 字段(int)
struct DLDataType
pub struct DLDataType {
pub code int
pub bits int
pub lanes int
}
用途
承载 code、bits、lanes 等属性的结构体。
公开字段
code int- 码
bits int- 比特数
lanes int- 字段(int)
struct DLTensor
pub struct DLTensor {
pub data_ptr int
pub device DLDevice
pub ndim int
pub dtype DLDataType
pub shape []int
pub strides []int
pub byte_offset int
}
用途
承载 data_ptr、device、ndim、dtype、shape 等属性的结构体。
公开字段
data_ptr int- 字段(int)
device DLDevice- 字段(DLDevice)
ndim int- 字段(int)
dtype DLDataType- 字段(DLDataType)
shape []int- 字段([]int)
strides []int- 字段([]int)
byte_offset int- 字段(int)
dlpack_cpu_device
pub fn dlpack_cpu_device() DLDevice
用途
执行 dlpack cpu device 操作。
参数
无需传入参数。
返回值
DLDevice — 该类型的值
dlpack_dtype_i64
pub fn dlpack_dtype_i64() DLDataType
用途
执行 dlpack dtype i64 操作。
参数
无需传入参数。
返回值
DLDataType — 该类型的值
dlpack_dtype_f64
pub fn dlpack_dtype_f64() DLDataType
用途
执行 dlpack dtype f64 操作。
参数
无需传入参数。
返回值
DLDataType — 该类型的值
dlpack_dtype_u8
pub fn dlpack_dtype_u8() DLDataType
用途
执行 dlpack dtype u8 操作。
参数
无需传入参数。
返回值
DLDataType — 该类型的值
dlpack_tensor_1d
pub fn dlpack_tensor_1d(data_ptr int, length int, dtype DLDataType) DLTensor
用途
执行 dlpack tensor 1d 操作。
参数
data_ptr int- data_ptr(int)
length int- length(int)
dtype DLDataType- dtype(DLDataType)
返回值
DLTensor — 该类型的值
dlpack_tensor_2d
pub fn dlpack_tensor_2d(data_ptr int, m int, n int, dtype DLDataType) DLTensor
用途
执行 dlpack tensor 2d 操作。
参数
data_ptr int- data_ptr(int)
m int- m(int)
n int- 数量、长度或上限(int)
dtype DLDataType- dtype(DLDataType)
返回值
DLTensor — 该类型的值
dlpack_element_count
pub fn dlpack_element_count(t &DLTensor) int
用途
执行 dlpack element count 操作。
参数
t &DLTensor- t(只读借用,调用方仍持有原值;类型 &DLTensor)
返回值
int — 该类型的值
dlpack_byte_size
pub fn dlpack_byte_size(t &DLTensor) int
用途
执行 dlpack byte size 操作。
参数
t &DLTensor- t(只读借用,调用方仍持有原值;类型 &DLTensor)
返回值
int — 该类型的值
dlpack_validate
pub fn dlpack_validate(t &DLTensor) bool
用途
执行 dlpack validate 操作。
参数
t &DLTensor- t(只读借用,调用方仍持有原值;类型 &DLTensor)
返回值
bool — 是否成立
lut_gemm_u4_reference
pub fn lut_gemm_u4_reference(c $&[]int, a &[]int, w_packed &[]int, m int, n int, k_pairs int)
用途
执行 lut gemm u4 reference 操作。
参数
c $&[]int- 字节或字符码(独占借用,可修改原值;类型 $&[]int)
a &[]int- 要处理的切片(只读借用,调用方仍持有原值;类型 &[]int)
w_packed &[]int- w_packed(只读借用,调用方仍持有原值;类型 &[]int)
m int- m(int)
n int- 数量、长度或上限(int)
k_pairs int- k_pairs(int)
返回值
不返回值。
lut_gemm_u4
pub fn lut_gemm_u4(c $&[]int, a &[]int, w_packed &[]int, m int, n int, k_pairs int)
用途
执行 lut gemm u4 操作。
参数
c $&[]int- 字节或字符码(独占借用,可修改原值;类型 $&[]int)
a &[]int- 要处理的切片(只读借用,调用方仍持有原值;类型 &[]int)
w_packed &[]int- w_packed(只读借用,调用方仍持有原值;类型 &[]int)
m int- m(int)
n int- 数量、长度或上限(int)
k_pairs int- k_pairs(int)
返回值
不返回值。
lut_gemm_s4_reference
pub fn lut_gemm_s4_reference(c $&[]int, a &[]int, w_packed &[]int, m int, n int, k_pairs int)
用途
执行 lut gemm s4 reference 操作。
参数
c $&[]int- 字节或字符码(独占借用,可修改原值;类型 $&[]int)
a &[]int- 要处理的切片(只读借用,调用方仍持有原值;类型 &[]int)
w_packed &[]int- w_packed(只读借用,调用方仍持有原值;类型 &[]int)
m int- m(int)
n int- 数量、长度或上限(int)
k_pairs int- k_pairs(int)
返回值
不返回值。
lut_gemm_s4
pub fn lut_gemm_s4(c $&[]int, a &[]int, w_packed &[]int, m int, n int, k_pairs int)
用途
执行 lut gemm s4 操作。
参数
c $&[]int- 字节或字符码(独占借用,可修改原值;类型 $&[]int)
a &[]int- 要处理的切片(只读借用,调用方仍持有原值;类型 &[]int)
w_packed &[]int- w_packed(只读借用,调用方仍持有原值;类型 &[]int)
m int- m(int)
n int- 数量、长度或上限(int)
k_pairs int- k_pairs(int)
返回值
不返回值。
lut_gemm_u2_reference
pub fn lut_gemm_u2_reference(c $&[]int, a &[]int, w_packed &[]int, m int, n int, k_quads int)
用途
执行 lut gemm u2 reference 操作。
参数
c $&[]int- 字节或字符码(独占借用,可修改原值;类型 $&[]int)
a &[]int- 要处理的切片(只读借用,调用方仍持有原值;类型 &[]int)
w_packed &[]int- w_packed(只读借用,调用方仍持有原值;类型 &[]int)
m int- m(int)
n int- 数量、长度或上限(int)
k_quads int- k_quads(int)
返回值
不返回值。
lut_gemm_u2
pub fn lut_gemm_u2(c $&[]int, a &[]int, w_packed &[]int, m int, n int, k_quads int)
用途
执行 lut gemm u2 操作。
参数
c $&[]int- 字节或字符码(独占借用,可修改原值;类型 $&[]int)
a &[]int- 要处理的切片(只读借用,调用方仍持有原值;类型 &[]int)
w_packed &[]int- w_packed(只读借用,调用方仍持有原值;类型 &[]int)
m int- m(int)
n int- 数量、长度或上限(int)
k_quads int- k_quads(int)
返回值
不返回值。
fused_saxpy_sum_i64
pub fn fused_saxpy_sum_i64(x &[]int, y &[]int, a int, len int) int
用途
执行 fused saxpy sum i64 操作。
参数
x &[]int- 值(只读借用,调用方仍持有原值;类型 &[]int)
y &[]int- 值(只读借用,调用方仍持有原值;类型 &[]int)
a int- 值(int)
len int- len(int)
返回值
int — 该类型的值
fused_norm2_i64
pub fn fused_norm2_i64(x &[]int, len int) int
用途
执行 fused norm2 i64 操作。
参数
x &[]int- 值(只读借用,调用方仍持有原值;类型 &[]int)
len int- len(int)
返回值
int — 该类型的值
fused_norm2_f64
pub fn fused_norm2_f64(x &[]f64, len int) f64
用途
执行 fused norm2 f64 操作。
参数
x &[]f64- 值(只读借用,调用方仍持有原值;类型 &[]f64)
len int- len(int)
返回值
f64 — 该类型的值
struct OnlineSoftmaxState
pub struct OnlineSoftmaxState {
pub max_val f64
pub sum_exp f64
}
用途
承载 max_val、sum_exp 等属性的结构体。
公开字段
max_val f64- 字段(f64)
sum_exp f64- 字段(f64)
online_softmax_init
pub fn online_softmax_init(init_val f64) OnlineSoftmaxState
用途
执行 online softmax init 操作。
参数
init_val f64- init_val(f64)
返回值
OnlineSoftmaxState — 该类型的值
online_softmax_update
pub fn online_softmax_update(state $&OnlineSoftmaxState, val f64)
用途
执行 online softmax update 操作。
参数
state $&OnlineSoftmaxState- state(独占借用,可修改原值;类型 $&OnlineSoftmaxState)
val f64- 值(f64)
返回值
不返回值。
online_softmax_vector
pub fn online_softmax_vector(vals &[]f64) OnlineSoftmaxState
用途
执行 online softmax vector 操作。
参数
vals &[]f64- vals(只读借用,调用方仍持有原值;类型 &[]f64)
返回值
OnlineSoftmaxState — 该类型的值
struct TileArchProfile
pub struct TileArchProfile {
pub arch_name string
pub l1d_bytes int
pub l2_bytes int
pub simd_bits int
pub pref_bm int
pub pref_bn int
pub pref_bk int
pub reg_m int
pub reg_n int
}
用途
承载 arch_name、l1d_bytes、l2_bytes、simd_bits、pref_bm 等属性的结构体。
公开字段
arch_name string- 字段(string)
l1d_bytes int- 字段(int)
l2_bytes int- 字段(int)
simd_bits int- 字段(int)
pref_bm int- 字段(int)
pref_bn int- 字段(int)
pref_bk int- 字段(int)
reg_m int- 字段(int)
reg_n int- 字段(int)
tile_arch_generic
pub fn tile_arch_generic() TileArchProfile
用途
执行 tile arch generic 操作。
参数
无需传入参数。
返回值
TileArchProfile — 该类型的值
tile_arch_apple_m
pub fn tile_arch_apple_m() TileArchProfile
用途
执行 tile arch apple m 操作。
参数
无需传入参数。
返回值
TileArchProfile — 该类型的值
tile_arch_avx512
pub fn tile_arch_avx512() TileArchProfile
用途
执行 tile arch avx512 操作。
参数
无需传入参数。
返回值
TileArchProfile — 该类型的值
tile_arch_detect
pub fn tile_arch_detect() TileArchProfile
用途
执行 tile arch detect 操作。
参数
无需传入参数。
返回值
TileArchProfile — 该类型的值
tile_compute_blocking
pub fn tile_compute_blocking(prof &TileArchProfile, m int, n int, k int) []int
用途
执行 tile compute blocking 操作。
参数
prof &TileArchProfile- prof(只读借用,调用方仍持有原值;类型 &TileArchProfile)
m int- m(int)
n int- 数量、长度或上限(int)
k int- 键或下标(int)
返回值
[]int — 切片结果
tile_working_set_fits_l1
pub fn tile_working_set_fits_l1(prof &TileArchProfile, bm int, bn int, bk int, elem_bytes int) bool
用途
执行 tile working set fits l1 操作。
参数
prof &TileArchProfile- prof(只读借用,调用方仍持有原值;类型 &TileArchProfile)
bm int- bm(int)
bn int- bn(int)
bk int- bk(int)
elem_bytes int- elem_bytes(int)
返回值
bool — 是否成立