Skip to main content

insert_class_markers

Function insert_class_markers 

Source
pub(crate) fn insert_class_markers<M: ClassMarker>(
    x: Tensor<3>,
    markers: &[M],
    emb: Option<&Param<Tensor<2>>>,
) -> (Tensor<3>, Vec<usize>)
Expand description

Insert the learnable class tokens emb ([k, width], row imarkers[i]) into x ([batch, orig_len, width]) per the markers, returning the lengthened sequence ([batch, orig_len + k, width]) and, for each marker in Vec order, its position in the output sequence.

markers empty ⇒ x is returned unchanged with an empty index vector.