attention.cpp 626 B

12345678910111213141516171819202122
  1. #include <torch/extension.h>
  2. #include <c10/util/Optional.h>
  3. void single_query_cached_kv_attention(
  4. torch::Tensor& out,
  5. torch::Tensor& query,
  6. torch::Tensor& key_cache,
  7. torch::Tensor& value_cache,
  8. torch::Tensor& head_mapping,
  9. float scale,
  10. torch::Tensor& block_tables,
  11. torch::Tensor& context_lens,
  12. int block_size,
  13. int max_context_len,
  14. const c10::optional<torch::Tensor>& alibi_slopes);
  15. PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
  16. m.def(
  17. "single_query_cached_kv_attention",
  18. &single_query_cached_kv_attention,
  19. "Compute the attention between an input query and the cached key/value tensors");
  20. }