Skip to main content

Module class

Module class 

Source
Expand description

Learnable [CLS]-style class tokens/latents spliced into the sequence.

Macrosยง

impl_class_marker ๐Ÿ”’

Enumsยง

ClassLatent
Position marker for a learnable class latent inserted into a layerโ€™s working sequence (embedding width = d_model).
ClassLatentSerde ๐Ÿ”’
ClassToken
Position marker for a learnable class token inserted into a networkโ€™s input sequence (embedding width = the network input width / โ€œd_inputโ€).
ClassTokenSerde ๐Ÿ”’

Traitsยง

ClassMarker
Shared behaviour of the ClassToken / ClassLatent position markers, letting one generic helper place either kind.

Functionsยง

assert_step_compatible ๐Ÿ”’
Panic if any marker is incompatible with single-token step().
class_marker_output_indices ๐Ÿ”’
The output-sequence position of each marker (in Vec order) for an input of length orig_len, without materialising any tensor. Mirrors the placement in insert_class_markers โ€” useful for reading a class token back out.
class_step_injections ๐Ÿ”’
The output-sequence position of each step-injectable marker (in Vec order), for use by stepโ€™s cursor. Asserts no Middle/End (those need the full length โ€” forward only). Start/Custom positions are length-independent, so an unbounded orig_len resolves them exactly.
init_class_emb ๐Ÿ”’
Build the embedding param for n class markers of the given width (None when there are none โ€” Burn has no zero-width tensors).
insert_class_markers ๐Ÿ”’
Insert the learnable class tokens emb ([k, width], row i โ†” markers[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.