Skip to main content

load_and_run/
load_and_run.rs

1use ferrotensor_backend::{ComputeEngine, UnifiedTensor, WgpuContext};
2use ferrotensor_loader::WeightsContext;
3use std::sync::Arc;
4
5fn main() {
6    env_logger::init();
7    pollster::block_on(async {
8        // 1. Setup Backend
9        let ctx = Arc::new(WgpuContext::new().await);
10        let engine = ComputeEngine::new(&ctx);
11
12        // 2. Setup Context (Mocking usage since we don't have a real file in this test)
13        let _weights_ctx = WeightsContext::new();
14
15        println!("Demonstrating full pipeline (conceptual)...");
16
17        // 3. Create GPU Tensors
18        let shape = vec![4];
19        let gpu_int8 = UnifiedTensor::new(&ctx, &[1.0, 2.0, 3.0, 4.0], &shape);
20        let gpu_fp32 = UnifiedTensor::empty(&ctx, &shape);
21
22        // 4. Dequantize
23        engine.dequantize(&ctx, &gpu_int8, &gpu_fp32);
24
25        // 5. Sequential Ops instead of Fused
26        let gpu_c = UnifiedTensor::new(&ctx, &[2.0, 2.0, 2.0, 2.0], &shape);
27        let gpu_out = UnifiedTensor::empty(&ctx, &shape);
28        let temp = UnifiedTensor::empty(&ctx, &shape);
29
30        engine.add(&ctx, &gpu_fp32, &gpu_c, &temp);
31        engine.mul(&ctx, &temp, &gpu_c, &gpu_out);
32
33        let result = gpu_out.to_vec(&ctx).await;
34        println!("Result: {:?}", result);
35        println!("SUCCESS: Pipeline logic verified!");
36    });
37}