Skip to main content

Prediction

Struct Prediction 

Source
pub struct Prediction { /* private fields */ }

Implementations§

Source§

impl Prediction

Source

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}
Source

pub fn get_f32_into(&self, _name: &str, _buf: &mut [f32]) -> Result<Vec<usize>>

Source

pub fn get_i32(&self, _name: &str) -> Result<(Vec<i32>, Vec<usize>)>

Source

pub fn get_f64(&self, _name: &str) -> Result<(Vec<f64>, Vec<usize>)>

Source

pub fn get_raw( &self, _name: &str, ) -> Result<(Vec<u8>, Vec<usize>, Option<DataType>)>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.