MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / cache_view

Function cache_view

src/models/heartmula/mula.cpp:207–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205 return matmul.build(ctx, attn, v_heads);
206}
207
208core::TensorValue flash_attention_from_grouped_heads(
209 core::ModuleBuildContext & ctx,
210 const core::TensorValue & q_heads,
211 const core::TensorValue & k_heads,
212 const core::TensorValue & v_heads,
213 int64_t dim,
214 const core::TensorValue & attention_mask) {
215 if (!core::has_backend_addressable_layout(q_heads.tensor)) {
216 throw std::runtime_error("HeartMuLa flash attention expects contiguous Q heads");
217 }
218 auto * flash = ggml_flash_attn_ext(
219 ctx.ggml,
220 q_heads.tensor,
221 k_heads.tensor,
222 v_heads.tensor,
223 attention_mask.tensor,
224 1.0F / std::sqrt(static_cast<float>(dim)),
225 0.0F,
226 0.0F);
227 ggml_flash_attn_ext_set_prec(flash, GGML_PREC_F32);
228 return core::wrap_tensor(
229 flash,
230 core::TensorShape::from_dims({q_heads.shape.dims[0], q_heads.shape.dims[2], q_heads.shape.dims[1], dim}),
231 GGML_TYPE_F32);
232}
233
234core::TensorValue apply_scaled_llama3_rope(

Calls 2

wrap_tensorFunction · 0.85
ggml_view_4dFunction · 0.85

Tested by

no test coverage detected