MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ attention_scores_stage()

DependencyStage MayaFlux::Yantra::TensorKernels::attention_scores_stage ( uint64_t q,
uint64_t k,
uint64_t scores,
uint32_t heads,
uint32_t dim,
uint32_t time,
float scale )
inlinenodiscard

One nn_attention_scores dispatch: scale times the dot product of every query with every key, per head.

q and k are [heads * dim, time], head h owning channels h * dim onwards. scores is [heads, time, time], indexed head, query, key.

Exceptions
std::invalid_argumentWhen heads, dim or time is 0.

Definition at line 214 of file Stages.hpp.

216{
217 if (heads == 0 || dim == 0 || time == 0) {
218 detail::refuse("Attention needs heads, a head width and positions");
219 }
220 const AttentionScoresPC pc { .q = q, .k = k, .scores = scores, .heads = heads, .dim = dim, .time = time, .scale = scale };
221 return detail::make_grid_stage(attention_scores_shader, pc, static_cast<size_t>(heads) * time * time);
222}
void refuse(std::string_view message)
Definition Layers.hpp:74
DependencyStage make_grid_stage(const char *shader, const PC &pc, size_t invocations)
Definition Stages.hpp:38
constexpr const char * attention_scores_shader
Definition Layouts.hpp:30

References attention_scores_shader, MayaFlux::Yantra::TensorKernels::detail::make_grid_stage(), and MayaFlux::Yantra::TensorKernels::detail::refuse().

Referenced by MayaFlux::Yantra::HubertPhonemeModel::Impl::run().

Here is the call graph for this function:
Here is the caller graph for this function: