pub struct Prediction { /* private fields */ }Implementations§
Source§impl Prediction
impl Prediction
Sourcepub fn get_f32(&self, _name: &str) -> Result<(Vec<f32>, Vec<usize>)>
pub fn get_f32(&self, _name: &str) -> Result<(Vec<f32>, Vec<usize>)>
Examples found in repository?
examples/load_and_predict.rs (line 23)
7fn main() {
8 let model_path = std::env::args()
9 .nth(1)
10 .unwrap_or_else(|| "tests/fixtures/test_linear.mlmodelc".to_string());
11
12 println!("Loading model: {model_path}");
13 let model = Model::load(&model_path, ComputeUnits::All).expect("Failed to load model");
14
15 // Create a simple input tensor
16 let input_data = vec![1.0f32, 2.0, 3.0, 4.0];
17 let tensor =
18 BorrowedTensor::from_f32(&input_data, &[1, 4]).expect("Failed to create tensor");
19
20 println!("Running prediction...");
21 let prediction = model.predict(&[("input", &tensor)]).expect("Prediction failed");
22
23 let (output, shape) = prediction.get_f32("output").expect("Failed to get output");
24 println!("Output shape: {shape:?}");
25 println!("Output data: {output:?}");
26}pub fn get_f32_into(&self, _name: &str, _buf: &mut [f32]) -> Result<Vec<usize>>
pub fn get_i32(&self, _name: &str) -> Result<(Vec<i32>, Vec<usize>)>
pub fn get_f64(&self, _name: &str) -> Result<(Vec<f64>, Vec<usize>)>
pub fn get_raw( &self, _name: &str, ) -> Result<(Vec<u8>, Vec<usize>, Option<DataType>)>
Auto Trait Implementations§
impl Freeze for Prediction
impl RefUnwindSafe for Prediction
impl Send for Prediction
impl Sync for Prediction
impl Unpin for Prediction
impl UnsafeUnpin for Prediction
impl UnwindSafe for Prediction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more