beat_this/runtime.rs
1pub mod ort;
2
3pub mod rten;
4
5use anyhow::Result;
6use std::collections::HashMap;
7use std::path::Path;
8
9/// Simple f32 tensor with shape (row-major / C-order).
10#[derive(Debug, Clone)]
11pub struct Tensor {
12 pub shape: Vec<usize>,
13 pub data: Vec<f32>,
14}
15
16/// A loaded model session ready for inference.
17pub trait InferenceSession {
18 /// Run inference with named inputs, return named outputs.
19 fn run(&mut self, inputs: &[(&str, &Tensor)]) -> Result<HashMap<String, Tensor>>;
20}
21
22/// Factory for creating sessions from ONNX model files.
23pub trait InferenceRuntime {
24 type Session: InferenceSession;
25
26 fn load_model(&self, path: &Path) -> Result<Self::Session>;
27}