Struct carton::carton::Carton

source ·
pub struct Carton { /* private fields */ }

Implementations§

source§

impl Carton

source

pub async fn load<P: AsRef<str>>(url_or_path: P, opts: LoadOpts) -> Result<Self>

Load a carton given a url, path, etc and options

source

pub async fn infer<I, S, T>( &self, tensors: I ) -> Result<HashMap<String, Tensor<RunnerStorage>>>where I: IntoIterator<Item = (S, Tensor<T>)>, String: From<S>, T: TensorStorage,

Infer using a set of inputs. Consider using seal and infer_with_handle in pipelines

source

pub async fn streaming_infer<'a, I, S, T>( &'a self, tensors: I ) -> impl Stream<Item = Result<HashMap<String, Tensor<RunnerStorage>>>> + 'awhere I: IntoIterator<Item = (S, Tensor<T>)> + 'a, String: From<S>, T: TensorStorage,

Infer using a set of inputs. This method has support for intermediate streaming responses Consider using seal and streaming_infer_with_handle in pipelines

source

pub async fn seal<T>( &self, tensors: HashMap<String, Tensor<T>> ) -> Result<SealHandle>where T: TensorStorage,

“Seal” a set of inputs that will be used for inference. This lets carton start processing tensors (e.g. moving them to the correct devices) before actually running inference and can lead to more efficient pipelines.

source

pub async fn infer_with_handle( &self, handle: SealHandle ) -> Result<HashMap<String, Tensor<RunnerStorage>>>

Infer using a handle from seal. This approach can make inference pipelines more efficient vs just using infer

source

pub async fn pack<T, O, P: AsRef<str>>(path: P, opts: O) -> Result<PathBuf>where T: TensorStorage, O: Into<PackOpts<T>>,

Pack a carton given a path and options. Returns the path of the output file

source

pub async fn load_unpacked<T, O, P: AsRef<str>>( path: P, pack_opts: O, load_opts: LoadOpts ) -> Result<Self>where T: TensorStorage + 'static, O: Into<PackOpts<T>>,

Pack a carton given a path and options Functionally equivalent to pack followed by load, but implemented in a more optimized way

source

pub fn get_info(&self) -> &CartonInfoWithExtras<GenericStorage>

Get info for the loaded model

source

pub async fn get_model_info<P: AsRef<str>>( url_or_path: P ) -> Result<CartonInfoWithExtras<GenericStorage>>

Get info for a model

source

pub async fn shrink( path: PathBuf, urls: HashMap<String, Vec<String>> ) -> Result<PathBuf>

Shrink a packed carton by storing links to files instead of the files themselves when possible. Takes a path to a packed carton along with a mapping from sha256 to a list of URLs Returns the path to another packed carton

source

pub async fn alloc_tensor( &self, dtype: DataType, shape: Vec<u64> ) -> Result<Tensor<RunnerStorage>>

Allocate a tensor

Auto Trait Implementations§

§

impl !RefUnwindSafe for Carton

§

impl Send for Carton

§

impl Sync for Carton

§

impl Unpin for Carton

§

impl !UnwindSafe for Carton

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

§

impl<T> Instrument for T

§

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

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

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 Twhere 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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