style: format Rust workspace
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use half::bf16;
|
||||
use xserv_kernels::{matmul, GemmBackend};
|
||||
use xserv_kernels::{GemmBackend, matmul};
|
||||
use xserv_tensor::{Device, Tensor};
|
||||
|
||||
fn cpu_matmul_f32(a: &[f32], b: &[f32], m: usize, n: usize, k: usize) -> Vec<f32> {
|
||||
@@ -75,70 +75,110 @@ fn run_gemm_test_bf16(backend: GemmBackend, m: usize, n: usize, k: usize) {
|
||||
// --- F32 tests ---
|
||||
|
||||
#[test]
|
||||
fn test_gemm_naive_f32_small() { run_gemm_test_f32(GemmBackend::Naive, 4, 4, 4); }
|
||||
fn test_gemm_naive_f32_small() {
|
||||
run_gemm_test_f32(GemmBackend::Naive, 4, 4, 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_naive_f32_medium() { run_gemm_test_f32(GemmBackend::Naive, 64, 64, 64); }
|
||||
fn test_gemm_naive_f32_medium() {
|
||||
run_gemm_test_f32(GemmBackend::Naive, 64, 64, 64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_naive_f32_rect() { run_gemm_test_f32(GemmBackend::Naive, 32, 64, 48); }
|
||||
fn test_gemm_naive_f32_rect() {
|
||||
run_gemm_test_f32(GemmBackend::Naive, 32, 64, 48);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_tiled_f32_small() { run_gemm_test_f32(GemmBackend::Tiled, 4, 4, 4); }
|
||||
fn test_gemm_tiled_f32_small() {
|
||||
run_gemm_test_f32(GemmBackend::Tiled, 4, 4, 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_tiled_f32_medium() { run_gemm_test_f32(GemmBackend::Tiled, 128, 128, 128); }
|
||||
fn test_gemm_tiled_f32_medium() {
|
||||
run_gemm_test_f32(GemmBackend::Tiled, 128, 128, 128);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_tiled_f32_rect() { run_gemm_test_f32(GemmBackend::Tiled, 65, 33, 97); }
|
||||
fn test_gemm_tiled_f32_rect() {
|
||||
run_gemm_test_f32(GemmBackend::Tiled, 65, 33, 97);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_cublas_f32_small() { run_gemm_test_f32(GemmBackend::CuBlas, 4, 4, 4); }
|
||||
fn test_gemm_cublas_f32_small() {
|
||||
run_gemm_test_f32(GemmBackend::CuBlas, 4, 4, 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_cublas_f32_medium() { run_gemm_test_f32(GemmBackend::CuBlas, 256, 256, 256); }
|
||||
fn test_gemm_cublas_f32_medium() {
|
||||
run_gemm_test_f32(GemmBackend::CuBlas, 256, 256, 256);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_cublas_f32_rect() { run_gemm_test_f32(GemmBackend::CuBlas, 65, 33, 97); }
|
||||
fn test_gemm_cublas_f32_rect() {
|
||||
run_gemm_test_f32(GemmBackend::CuBlas, 65, 33, 97);
|
||||
}
|
||||
|
||||
// --- BF16 tests ---
|
||||
|
||||
#[test]
|
||||
fn test_gemm_naive_bf16_small() { run_gemm_test_bf16(GemmBackend::Naive, 4, 4, 4); }
|
||||
fn test_gemm_naive_bf16_small() {
|
||||
run_gemm_test_bf16(GemmBackend::Naive, 4, 4, 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_naive_bf16_medium() { run_gemm_test_bf16(GemmBackend::Naive, 64, 64, 64); }
|
||||
fn test_gemm_naive_bf16_medium() {
|
||||
run_gemm_test_bf16(GemmBackend::Naive, 64, 64, 64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_tiled_bf16_small() { run_gemm_test_bf16(GemmBackend::Tiled, 4, 4, 4); }
|
||||
fn test_gemm_tiled_bf16_small() {
|
||||
run_gemm_test_bf16(GemmBackend::Tiled, 4, 4, 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_tiled_bf16_medium() { run_gemm_test_bf16(GemmBackend::Tiled, 128, 128, 128); }
|
||||
fn test_gemm_tiled_bf16_medium() {
|
||||
run_gemm_test_bf16(GemmBackend::Tiled, 128, 128, 128);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_cublas_bf16_small() { run_gemm_test_bf16(GemmBackend::CuBlas, 4, 4, 4); }
|
||||
fn test_gemm_cublas_bf16_small() {
|
||||
run_gemm_test_bf16(GemmBackend::CuBlas, 4, 4, 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_cublas_bf16_medium() { run_gemm_test_bf16(GemmBackend::CuBlas, 256, 256, 256); }
|
||||
fn test_gemm_cublas_bf16_medium() {
|
||||
run_gemm_test_bf16(GemmBackend::CuBlas, 256, 256, 256);
|
||||
}
|
||||
|
||||
// --- Custom GEMV tests (M=1, BF16 fast path) ---
|
||||
|
||||
#[test]
|
||||
fn test_gemv_bf16_small() { run_gemm_test_bf16(GemmBackend::CuBlas, 1, 64, 64); }
|
||||
fn test_gemv_bf16_small() {
|
||||
run_gemm_test_bf16(GemmBackend::CuBlas, 1, 64, 64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemv_bf16_medium() { run_gemm_test_bf16(GemmBackend::CuBlas, 1, 256, 256); }
|
||||
fn test_gemv_bf16_medium() {
|
||||
run_gemm_test_bf16(GemmBackend::CuBlas, 1, 256, 256);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemv_bf16_4096() { run_gemm_test_bf16(GemmBackend::CuBlas, 1, 4096, 4096); }
|
||||
fn test_gemv_bf16_4096() {
|
||||
run_gemm_test_bf16(GemmBackend::CuBlas, 1, 4096, 4096);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemv_bf16_rect() { run_gemm_test_bf16(GemmBackend::CuBlas, 1, 512, 4096); }
|
||||
fn test_gemv_bf16_rect() {
|
||||
run_gemm_test_bf16(GemmBackend::CuBlas, 1, 512, 4096);
|
||||
}
|
||||
|
||||
// --- Larger benchmark-style tests ---
|
||||
|
||||
#[test]
|
||||
fn test_gemm_cublas_f32_1024() { run_gemm_test_f32(GemmBackend::CuBlas, 1024, 1024, 1024); }
|
||||
fn test_gemm_cublas_f32_1024() {
|
||||
run_gemm_test_f32(GemmBackend::CuBlas, 1024, 1024, 1024);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gemm_consistency_all_backends() {
|
||||
|
||||
Reference in New Issue
Block a user