#[cfg(test)]
mod webgpu_tests {
use crate::webgpu::{BackendSelector, ComputeProfile, MatrixSize, OperationType};
fn is_ci_environment() -> bool {
std::env::var("RUV_FANN_CI_TESTING").is_ok()
}
#[test]
#[cfg_attr(miri, ignore = "Miri cannot handle WebGPU FFI calls")]
fn test_backend_selector_creation() {
if is_ci_environment() {
println!("Skipping WebGPU test in CI environment");
return;
}
let selector = BackendSelector::<f32>::new();
let capabilities = selector.capabilities();
assert!(!capabilities.is_empty());
for cap in &capabilities {
assert!(cap.supports_f32);
}
}
#[test]
#[cfg_attr(miri, ignore = "Miri cannot handle WebGPU FFI calls")]
fn test_compute_profile_selection() {
if is_ci_environment() {
println!("Skipping WebGPU test in CI environment");
return;
}
let selector = BackendSelector::<f32>::new();
let profiles = vec![
ComputeProfile {
matrix_size: MatrixSize::Small,
batch_size: 1,
operation_type: OperationType::ForwardPass,
},
ComputeProfile {
matrix_size: MatrixSize::Large,
batch_size: 32,
operation_type: OperationType::Inference,
},
];
for profile in profiles {
let backend = selector.select_backend(&profile);
assert!(backend.is_some(), "Should always find a backend");
}
}
}