Skip to main content

Sam3

Struct Sam3 

Source
pub struct Sam3 {
    pub manifest: Manifest,
    pub store: Store,
    pub cfg: Config,
    pub tokenizer: Tokenizer,
    pub timing: Timing,
    /* private fields */
}

Fields§

§manifest: Manifest§store: Store§cfg: Config§tokenizer: Tokenizer§timing: Timing

Implementations§

Source§

impl Sam3

Source

pub fn detr_encoder( &mut self, fpn2: &[f32], text: &Text, ) -> Result<Vec<f32>, Error>

The DETR encoder: fpn2 [T, 256] (the 72 x 72 level, raster) and the prompt -> [T, 256].

Source

pub fn detr_decoder( &mut self, enc: &[f32], text: &Text, ) -> Result<Decoded, Error>

The DETR decoder + scoring: enc [T, 256] and the prompt -> Decoded.

Source§

impl Sam3

Source

pub fn mask_decoder( &mut self, hidden: &[f32], fpn: &[Vec<f32>; 3], enc: &[f32], text: &Text, ) -> Result<(Vec<f32>, Vec<f32>), Error>

(pred_masks [Q, S, S], semantic [S, S]) from the decoder’s last normalised query states, the FPN levels (channels-last) and the DETR encoder output.

Source§

impl Sam3

Source

pub fn neck(&mut self, vit: &[f32]) -> Result<[Vec<f32>; 3], Error>

The backbone’s [T, 1024] (raster) -> FPN levels 0-2, channels-last f32: [288^2, 256], [144^2, 256], [72^2, 256].

Source§

impl Sam3

Source

pub fn text(&self, ids: &[u32], mask: &[u32]) -> Result<Text, Error>

The CLIP text encoder over the tokens (ids, mask as the tokenizer gives them) -> the prompt features [L, 256].

Source§

impl Sam3

Source

pub fn vit(&mut self, pixels: &[f32]) -> Result<Vec<f32>, Error>

pixels [3, S, S] -> the backbone’s last hidden state [T, 1024], raster order.

Source§

impl Sam3

Source

pub fn load(dir: &Path) -> Result<Self, Error>

Loads the bundle, opens the NPU, loads every kernel and uploads the packed weights.

Source

pub fn contexts(&self) -> (usize, usize)

Hardware contexts created and evicted so far (evictions happen when another process holds some of the NPU’s contexts).

Source

pub fn segment(&mut self, pixels: &[f32], prompt: &str) -> Result<Output, Error>

Everything for one image and prompt: pixels is the preprocessed [3, 1008, 1008] image (preprocess). The text encoder (host) runs on a side thread while the ViT has the NPU.

Source

pub fn forward(&mut self, pixels: &[f32], text: &Text) -> Result<Output, Error>

The forward from preprocessed pixels and an encoded prompt.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Sam3

§

impl !Sync for Sam3

§

impl Freeze for Sam3

§

impl Send for Sam3

§

impl Unpin for Sam3

§

impl UnsafeUnpin for Sam3

§

impl UnwindSafe for Sam3

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.