pub struct Sam2VideoState {
pub memory: Vec<Sam2MemoryEncoderOutput>,
pub obj_ptr_queue: Vec<Vec<f32>>,
}Expand description
Per-track state for Sam2::predict_video_frame. Stores up to
max_obj_ptrs_in_encoder past memory tokens + the rolling
object-pointer queue.
Fields§
§memory: Vec<Sam2MemoryEncoderOutput>Each entry: (features [out_dim, h, w] flat, pos [..., h, w] flat, h, w).
obj_ptr_queue: Vec<Vec<f32>>Implementations§
Source§impl Sam2VideoState
impl Sam2VideoState
pub fn new() -> Sam2VideoState
Sourcepub fn num_obj_ptr_tokens(&self, _mem_dim: usize) -> usize
pub fn num_obj_ptr_tokens(&self, _mem_dim: usize) -> usize
Total number of memory tokens (spatial + obj-ptr) in the
concatenated memory bank. mem_dim is the obj-pointer
channel dim (typically 64).
Sourcepub fn assembled_memory(
&self,
kv_in_dim: usize,
_mem_dim: usize,
) -> (Vec<f32>, Vec<f32>, usize)
pub fn assembled_memory( &self, kv_in_dim: usize, _mem_dim: usize, ) -> (Vec<f32>, Vec<f32>, usize)
Concatenate the per-frame memories into a single
(memory [N_mem, kv_in_dim], memory_pos [N_mem, kv_in_dim])
pair for the memory-attention call. Spatial tokens go first,
object-pointer tokens at the tail (so num_k_exclude_rope
works correctly).
Trait Implementations§
Source§impl Default for Sam2VideoState
impl Default for Sam2VideoState
Source§fn default() -> Sam2VideoState
fn default() -> Sam2VideoState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Sam2VideoState
impl RefUnwindSafe for Sam2VideoState
impl Send for Sam2VideoState
impl Sync for Sam2VideoState
impl Unpin for Sam2VideoState
impl UnsafeUnpin for Sam2VideoState
impl UnwindSafe for Sam2VideoState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more