interplane.Get Omega
Read in your language

ggml

[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)

Brought by drakestapleton

branch master Branches Tags History

ggml / src / ggml-sycl / fattn.hpp

48 lines · 2039 bytes Raw Blame History
1//
2// MIT license
3// Copyright (C) 2025 Intel Corporation
4// SPDX-License-Identifier: MIT
5//
6
7//
8// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
9// See https://llvm.org/LICENSE.txt for license information.
10// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11//
12
13#ifndef GGML_SYCL_FATTN_HPP
14#define GGML_SYCL_FATTN_HPP
15
16#include "common.hpp"
17
18void ggml_sycl_flash_attn_ext(ggml_backend_sycl_context & ctx, ggml_tensor * dst);
19
20bool ggml_sycl_flash_attn_ext_supported(int device, const ggml_tensor * dst);
21
22// Reports if flash attention runs this node with the oneMKL kernel, which waits on the host
23bool ggml_sycl_flash_attn_ext_needs_sync(int device, const ggml_tensor * dst);
24
25// Reports if flash attention runs this node with the oneDNN kernel
26bool ggml_sycl_flash_attn_ext_uses_onednn(int device, const ggml_tensor * dst);
27
28// Scratch that flash attention needs beyond the output tensor
29struct ggml_sycl_fattn_extra {
30 uintptr_t K_buffer_ptr = 0; // F16 copy of the K cache
31 uintptr_t V_buffer_ptr = 0; // F16 copy of the V cache
32 uintptr_t Q_buffer_ptr = 0; // dense F16 copy of Q, oneDNN only
33 uintptr_t scale_buffer_ptr = 0; // the softmax scale as an F16 scalar, oneDNN only
34 uintptr_t out_buffer_ptr = 0; // F16 SDPA output before conversion to F32, oneDNN only
35 uintptr_t end = 0; // one past the last reserved byte; sizes the allocation
36};
37
38// ggml_sycl_fattn_get_extra() is the single source of truth for the layout: it both sizes
39// the reservation and hands out the pointers, so the two cannot disagree.
40// Each field is the address of one reserved block, or 0 if that block was not reserved,
41// in which case the caller allocates from the scratch pool instead.
42ggml_sycl_fattn_extra ggml_sycl_fattn_get_extra(const ggml_tensor * dst);
43
44size_t ggml_sycl_flash_attn_ext_get_alloc_size(const ggml_tensor * dst);
45
46void ggml_sycl_flash_attn_ext_mkl(ggml_backend_sycl_context & ctx, ggml_tensor * dst);
47
48#endif // GGML_SYCL_FATTN_HPP