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