1
0

cache.h 659 B

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include <torch/extension.h>
  3. #include <map>
  4. #include <vector>
  5. void swap_blocks(
  6. torch::Tensor& src,
  7. torch::Tensor& dst,
  8. const std::map<int64_t, int64_t>& block_mapping);
  9. void copy_blocks(
  10. std::vector<torch::Tensor>& key_caches,
  11. std::vector<torch::Tensor>& value_caches,
  12. const std::map<int64_t, std::vector<int64_t>>& block_mapping);
  13. void reshape_and_cache(
  14. torch::Tensor& key,
  15. torch::Tensor& value,
  16. torch::Tensor& key_cache,
  17. torch::Tensor& value_cache,
  18. torch::Tensor& slot_mapping,
  19. const std::string& kv_cache_dtype,
  20. const float kv_scale);
  21. void convert_fp8(
  22. torch::Tensor& src_cache,
  23. torch::Tensor& dst_cache);