attention.cpp 626 Bytes
Newer Older
1
#include <torch/extension.h>
Woosuk Kwon's avatar
Woosuk Kwon committed
2
#include <c10/util/Optional.h>
3
4
5
6
7
8

void single_query_cached_kv_attention(
  torch::Tensor& out,
  torch::Tensor& query,
  torch::Tensor& key_cache,
  torch::Tensor& value_cache,
Zhuohan Li's avatar
Zhuohan Li committed
9
  torch::Tensor& head_mapping,
10
11
12
13
  float scale,
  torch::Tensor& block_tables,
  torch::Tensor& context_lens,
  int block_size,
Woosuk Kwon's avatar
Woosuk Kwon committed
14
15
  int max_context_len,
  const c10::optional<torch::Tensor>& alibi_slopes);
16
17
18
19
20
21
22

PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
  m.def(
    "single_query_cached_kv_attention",
    &single_query_cached_kv_attention,
    "Compute the attention between an input query and the cached key/value tensors");
}