Skip to main content

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, serde::Serialize, serde::Deserialize)]
11pub struct Tensor {
12    pub shape: Vec<usize>,
13    pub data: Vec<f32>,
14}
15
16/// A loaded model ready for inference.
17pub trait Model {
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 loading models from ONNX files.
23pub trait Runtime {
24    type Model: Model;
25
26    fn load_model(&self, path: &Path) -> Result<Self::Model>;
27}