Struct surrealml_core::execution::compute::ModelComputation

source ·
pub struct ModelComputation<'a> {
    pub surml_file: &'a mut SurMlFile,
}
Expand description

A wrapper for the loaded machine learning model so we can perform computations on the loaded model.

§Attributes

  • surml_file - The loaded machine learning model using interior mutability to allow mutable access to the model

Fields§

§surml_file: &'a mut SurMlFile

Implementations§

source§

impl<'a> ModelComputation<'a>

source

pub fn input_tensor_from_key_bindings( &self, input_values: HashMap<String, f32> ) -> Result<ArrayD<f32>, SurrealError>

Creates a Tensor that can be used as input to the loaded model from a hashmap of keys and values.

§Arguments
  • input_values - A hashmap of keys and values that will be used to create the input tensor.
§Returns

A Tensor that can be used as input to the loaded model.

source

pub fn input_vector_from_key_bindings( &self, input_values: HashMap<String, f32> ) -> Result<Vec<f32>, SurrealError>

Creates a Vector that can be used manipulated with other operations such as normalisation from a hashmap of keys and values.

§Arguments
  • input_values - A hashmap of keys and values that will be used to create the input vector.
§Returns

A Vector that can be used manipulated with other operations such as normalisation.

source

pub fn raw_compute( &self, tensor: ArrayD<f32>, _dims: Option<(i32, i32)> ) -> Result<Vec<f32>, SurrealError>

Performs a raw computation on the loaded model.

§Arguments
  • tensor - The input tensor to the loaded model.
§Returns

The computed output tensor from the loaded model.

source

pub fn buffered_compute( &self, input_values: &mut HashMap<String, f32> ) -> Result<Vec<f32>, SurrealError>

Checks the header applying normalisers if present and then performs a raw computation on the loaded model. Will also apply inverse normalisers if present on the outputs.

§Notes

This function is fairly coupled and will consider breaking out the functions later on if needed.

§Arguments
  • input_values - A hashmap of keys and values that will be used to create the input tensor.
§Returns

The computed output tensor from the loaded model.

Auto Trait Implementations§

§

impl<'a> Freeze for ModelComputation<'a>

§

impl<'a> RefUnwindSafe for ModelComputation<'a>

§

impl<'a> Send for ModelComputation<'a>

§

impl<'a> Sync for ModelComputation<'a>

§

impl<'a> Unpin for ModelComputation<'a>

§

impl<'a> !UnwindSafe for ModelComputation<'a>

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

§

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>,

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more