diffusion_rs_common

Type Alias VarBuilder

Source
pub type VarBuilder<'a> = VarBuilderArgs<'a, Box<dyn SimpleBackend + 'a>>;
Expand description

A simple VarBuilder, this is less generic than VarBuilderArgs but should cover most common use cases.

Aliased Type§

struct VarBuilder<'a> {
    pub dtype: DType,
    /* private fields */
}

Fields§

§dtype: DType

Implementations§

Source§

impl<'a> VarBuilder<'a>

Source

pub fn from_backend( backend: Box<dyn SimpleBackend + 'a>, dtype: DType, device: Device, ) -> Self

Initializes a VarBuilder using a custom backend.

It is preferred to use one of the more specific constructors. This constructor is provided to allow downstream users to define their own backends.

Source

pub fn zeros(dtype: DType, dev: &Device) -> Self

Initializes a VarBuilder that uses zeros for any tensor.

Source

pub fn from_tensors( ts: HashMap<String, Tensor>, dtype: DType, dev: &Device, ) -> Self

Initializes a VarBuilder that retrieves tensors stored in a hashtable. An error is returned if no tensor is available under the requested path or on shape mismatches.

Source

pub unsafe fn from_mmaped_safetensors<P: AsRef<Path>>( paths: &[P], dtype: DType, dev: &Device, ) -> Result<Self>

Initializes a VarBuilder that retrieves tensors stored in a collection of safetensors files.

§Safety

The unsafe is inherited from [memmap2::MmapOptions].

Source

pub fn from_buffered_safetensors( data: Vec<u8>, dtype: DType, dev: &Device, ) -> Result<Self>

Initializes a VarBuilder from a binary buffer in the safetensor format.

Source

pub fn from_slice_safetensors( data: &'a [u8], dtype: DType, dev: &Device, ) -> Result<Self>

Initializes a VarBuilder from a binary slice in the safetensor format.