Struct tch::CModule[][src]

pub struct CModule { /* fields omitted */ }

A jit PyTorch module.

These modules can be created via the TorchScript python api.

Implementations

impl CModule[src]

pub fn load<T: AsRef<Path>>(path: T) -> Result<CModule, TchError>[src]

Loads a PyTorch saved JIT model from a file.

pub fn load_on_device<T: AsRef<Path>>(
    path: T,
    device: Device
) -> Result<CModule, TchError>
[src]

Loads a PyTorch saved JIT model from a file onto the given device.

This function loads the model directly on the specified device, which means it also allows loading a GPU model on the CPU without having a CUDA enabled GPU.

pub fn load_data<T: Read>(f: &mut T) -> Result<CModule, TchError>[src]

Loads a PyTorch saved JIT model from a read instance.

pub fn load_data_on_device<T: Read>(
    f: &mut T,
    device: Device
) -> Result<CModule, TchError>
[src]

Loads a PyTorch saved JIT model from a read instance.

This function loads the model directly on the specified device, which means it also allows loading a GPU model on the CPU without having a CUDA enabled GPU.

pub fn forward_ts<T: Borrow<Tensor>>(
    &self,
    ts: &[T]
) -> Result<Tensor, TchError>
[src]

Performs the forward pass for a model on some specified tensor inputs.

pub fn forward_is<T: Borrow<IValue>>(
    &self,
    ts: &[T]
) -> Result<IValue, TchError>
[src]

Performs the forward pass for a model on some specified ivalue inputs.

pub fn method_ts<T: Borrow<Tensor>>(
    &self,
    method_name: &str,
    ts: &[T]
) -> Result<Tensor, TchError>
[src]

Runs a specified entry point for a model on some given tensor inputs.

pub fn method_is<T: Borrow<IValue>>(
    &self,
    method_name: &str,
    ts: &[T]
) -> Result<IValue, TchError>
[src]

Runs a specified entry point for a model on some given ivalue inputs.

pub fn f_set_eval(&mut self) -> Result<(), TchError>[src]

Switches the module to evaluation mode.

pub fn set_eval(&mut self)[src]

Switches the module to evaluation mode.

pub fn f_set_train(&mut self) -> Result<(), TchError>[src]

Switches the module to training mode.

pub fn set_train(&mut self)[src]

Switches the module to training mode.

pub fn to(&mut self, device: Device, kind: Kind, non_blocking: bool)[src]

pub fn save<T: AsRef<Path>>(&self, path: T) -> Result<(), TchError>[src]

Saves a module to a given path.

pub fn named_parameters(&self) -> Result<Vec<(String, Tensor)>, TchError>[src]

Loads some named tensors from a module

pub fn create_by_tracing<F>(
    modl_name: &str,
    fn_name: &str,
    inputs: &[Tensor],
    closure: &mut F
) -> Result<CModule, TchError> where
    F: FnMut(&[Tensor]) -> Vec<Tensor>, 
[src]

Create a new module by tracing the application of the specified function on the given inputs.

Trait Implementations

impl Debug for CModule[src]

impl Drop for CModule[src]

impl Module for CModule[src]

impl Send for CModule[src]

impl Sync for CModule[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,