|
1 | 1 | #pragma once |
2 | 2 |
|
3 | 3 | #include "../device.hpp" |
| 4 | +#include "../graph/graph.hpp" |
4 | 5 | #include "common/op.hpp" |
5 | 6 | #include <optional> |
6 | 7 |
|
7 | 8 | namespace infinicore::op { |
8 | 9 |
|
9 | | -class PagedAttention { |
10 | | -public: |
11 | | - using schema = void (*)(Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, std::optional<Tensor>, float); |
12 | | - static void execute(Tensor out, Tensor q, Tensor k_cache, Tensor v_cache, Tensor block_tables, Tensor cache_lens, std::optional<Tensor> alibi_slopes, float); |
13 | | - static common::OpDispatcher<schema> &dispatcher(); |
14 | | -}; |
| 10 | +INFINICORE_GRAPH_OP_CLASS(PagedAttention, Tensor, const Tensor &, const Tensor &, const Tensor &, const Tensor &, const Tensor &, std::optional<Tensor>, float); |
| 11 | + |
| 12 | +Tensor paged_attention(const Tensor &q, const Tensor &k_cache, const Tensor &v_cache, |
| 13 | + const Tensor &block_tables, const Tensor &kv_lens, |
| 14 | + std::optional<Tensor> alibi_slopes, float scale); |
| 15 | + |
| 16 | +void paged_attention_(Tensor out, const Tensor &q, const Tensor &k_cache, const Tensor &v_cache, |
| 17 | + const Tensor &block_tables, const Tensor &kv_lens, |
| 18 | + std::optional<Tensor> alibi_slopes, float scale); |
15 | 19 |
|
16 | | -Tensor paged_attention(Tensor q, Tensor k_cache, Tensor v_cache, Tensor block_tables, Tensor cache_lens, std::optional<Tensor> alibi_slopes, float scale); |
17 | | -void paged_attention_(Tensor out, Tensor q, Tensor k_cache, Tensor v_cache, Tensor block_tables, Tensor cache_lens, std::optional<Tensor> alibi_slopes, float scale); |
18 | 20 | } // namespace infinicore::op |
0 commit comments