Skip to main content

VisionModel

Struct VisionModel 

Source
pub struct VisionModel {
    pub config: VisionConfig,
    pub patch_embed: VisionLinear,
    pub blocks: Vec<VisionBlock>,
    pub norm: Vec<f32>,
    pub aligner_w1: VisionLinear,
    pub aligner_w2: VisionLinear,
    pub image_start: Vec<f32>,
    pub image_end: Vec<f32>,
    pub image_newline: Vec<f32>,
}
Expand description

Loaded V4.1 vision tower plus projector/marker embeddings.

Fields§

§config: VisionConfig§patch_embed: VisionLinear§blocks: Vec<VisionBlock>§norm: Vec<f32>§aligner_w1: VisionLinear§aligner_w2: VisionLinear§image_start: Vec<f32>§image_end: Vec<f32>§image_newline: Vec<f32>

Implementations§

Source§

impl VisionModel

Source

pub fn from_model( model: &Arc<CmfModel>, config: VisionConfig, ) -> Result<Self, String>

Load canonical V4.1 names from a CMF model. The marker vectors are required whenever the tower is enabled because they replace the image-start/end/newline token embeddings in the text hidden state.

Source

pub fn encode_image( &self, image: &ImageInput, pool: Option<&Pool>, ) -> Result<Vec<f32>, String>

Compute a vision image embedding with the official ViT and aligner. The returned rows correspond only to IMAGE positions, in reading order; marker vectors remain separate for the text runtime to insert.

Source

pub fn fill_image_span( &self, image: &ImageInput, span: &mut [f32], pool: Option<&Pool>, ) -> Result<(), String>

Insert image marker/projector rows into a text hidden-state span. span must have the exact ImageInput::types length and be laid out with the text hidden size in its last dimension.

Source

pub fn image_span( &self, image: &ImageInput, pool: Option<&Pool>, ) -> Result<Vec<f32>, String>

Return one complete text-hidden image span (markers plus projected image rows) for callers that do not already own a preallocated hidden buffer. The runtime’s batched prefill can copy these rows directly over the corresponding placeholder positions.

Trait Implementations§

Source§

impl Debug for VisionModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Instrument for T

Source§

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

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

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 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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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