Skip to main content

Mojo trait

ScoreModTrait

The ScoreMod trait desctribes score_mod for mha kernel like alibi bias.

Implemented traits

AnyType, UnknownDestructibility

Aliases

__del__is_trivial

alias __del__is_trivial

A flag (often compiler generated) to indicate whether the implementation of __del__ is trivial.

The implementation of __del__ is considered to be trivial if:

  • The struct has a compiler-generated trivial destructor and all its fields have a trivial __del__ method.

In practice, it means that the __del__ can be considered as no-op.

name_str

alias name_str

Methods

score_mod

score_mod[dtype: DType, width: Int, //, *, element_type: DType = int32](self: _Self, coord: IndexList[4, element_type=element_type], score_vec: SIMD[dtype, width], max_prompt_len: Int = 0) -> SIMD[dtype, width]

Return score vector at given coordinates given a score_mod.

Arguments: coord is (seq_id, head, q_idx, k_idx) score_vec is at coord of the score matrix

Score_mod calculates a tensor given the functor and adds to score_vec.

Returns:

SIMD

Was this page helpful?