use ferrotensor_backend::{ComputeEngine, UnifiedTensor, WgpuContext};
fn main() {
env_logger::init();
pollster::block_on(async {
let ctx = WgpuContext::new().await;
let engine = ComputeEngine::new(&ctx);
println!("--- Testing MatMul ---");
let a = UnifiedTensor::new(&ctx, &[1.0, 2.0, 3.0, 4.0], &[2, 2]);
let b = UnifiedTensor::new(&ctx, &[1.0, 0.0, 0.0, 1.0], &[2, 2]); let out = UnifiedTensor::empty(&ctx, &[2, 2]);
engine.matmul(&ctx, &a, &b, &out);
println!("MatMul Result: {:?}", out.to_vec(&ctx).await);
println!("--- Testing RMSNorm ---");
let rms_in = UnifiedTensor::new(&ctx, &[1.0, 2.0, 3.0, 4.0], &[4]);
let rms_w = UnifiedTensor::new(&ctx, &[1.0, 1.0, 1.0, 1.0], &[4]);
let rms_out = UnifiedTensor::empty(&ctx, &[4]);
engine.rms_norm(&ctx, &rms_in, &rms_w, &rms_out);
println!("RMS Result: {:?}", rms_out.to_vec(&ctx).await);
println!("--- Testing SiLU ---");
let silu_in = UnifiedTensor::new(&ctx, &[1.0, -1.0], &[2]);
let silu_out = UnifiedTensor::empty(&ctx, &[2]);
engine.silu(&ctx, &silu_in, &silu_out);
println!("SiLU Result: {:?}", silu_out.to_vec(&ctx).await);
println!("--- Testing Softmax ---");
let sm_in = UnifiedTensor::new(&ctx, &[1.0, 2.0], &[2]);
let sm_out = UnifiedTensor::empty(&ctx, &[2]);
engine.softmax(&ctx, &sm_in, &sm_out);
println!("Softmax Result: {:?}", sm_out.to_vec(&ctx).await);
});
}