| 186 | v_heads.tensor, |
| 187 | attention_mask.tensor, |
| 188 | 1.0F / std::sqrt(static_cast<float>(dim)), |
| 189 | 0.0F, |
| 190 | 0.0F); |
| 191 | ggml_flash_attn_ext_set_prec(flash, precision); |
| 192 | return core::wrap_tensor( |
| 193 | flash, |
| 194 | core::TensorShape::from_dims({q_contiguous.shape.dims[0], q_contiguous.shape.dims[2], q_contiguous.shape.dims[1], dim}), |
| 195 | GGML_TYPE_F32); |
| 196 | } |
| 197 | |
| 198 | core::TensorValue cache_view( |
| 199 | core::ModuleBuildContext & ctx, |
| 200 | const core::TensorValue & cache, |
| 201 | int64_t start, |
| 202 | int64_t steps, |
| 203 | int64_t heads, |
| 204 | int64_t dim) { |
| 205 | if (start < 0 || steps <= 0 || start + steps > cache.shape.dims[1]) { |
| 206 | throw std::runtime_error("Qwen decoder cache view range is invalid"); |
| 207 | } |
no test coverage detected