Upload edit\Qwen3-TTS-test\.venv\Lib\site-packages\torch\include\ATen\native\transformers\attention.h with huggingface_hub
Browse files
edit//Qwen3-TTS-test//.venv//Lib//site-packages//torch//include//ATen//native//transformers//attention.h
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
#include <ATen/core/Tensor.h>
|
| 3 |
+
#include <c10/macros/Export.h>
|
| 4 |
+
#include <ATen/native/DispatchStub.h>
|
| 5 |
+
#include <ATen/native/transformers/attention.h>
|
| 6 |
+
#include <optional>
|
| 7 |
+
|
| 8 |
+
namespace at::native {
|
| 9 |
+
|
| 10 |
+
using fused_sdp_choice_fn = int64_t (*)(const Tensor& query_, const Tensor& key, const Tensor& value,
|
| 11 |
+
const std::optional<Tensor>& attn_mask_, double dropout_p, bool is_causal, std::optional<double> scale, bool enable_gqa);
|
| 12 |
+
|
| 13 |
+
DECLARE_DISPATCH(fused_sdp_choice_fn, _fused_sdp_choice_stub)
|
| 14 |
+
|
| 15 |
+
TORCH_API Tensor bmm_nt(const Tensor& a, const Tensor& b);
|
| 16 |
+
TORCH_API Tensor masked_softmax(
|
| 17 |
+
Tensor& attn_scores,
|
| 18 |
+
std::optional<Tensor> attn_mask,
|
| 19 |
+
const Tensor& query,
|
| 20 |
+
std::optional<int64_t> mask_type = {});
|
| 21 |
+
|
| 22 |
+
using transform_bias_rescale_qkv_fn = void(*)(
|
| 23 |
+
at::ScalarType type,
|
| 24 |
+
void* _q_k_v,
|
| 25 |
+
const void* _qkv,
|
| 26 |
+
const void* _qkv_bias,
|
| 27 |
+
int64_t B,
|
| 28 |
+
int64_t T,
|
| 29 |
+
int64_t D,
|
| 30 |
+
int64_t num_head);
|
| 31 |
+
|
| 32 |
+
DECLARE_DISPATCH(transform_bias_rescale_qkv_fn, transform_bias_rescale_qkv_stub)
|
| 33 |
+
|
| 34 |
+
TORCH_API Tensor transform0213_gemm_nt_bias(
|
| 35 |
+
const Tensor& a,
|
| 36 |
+
const Tensor& b,
|
| 37 |
+
const Tensor& c,
|
| 38 |
+
const Tensor& query);
|
| 39 |
+
|
| 40 |
+
TORCH_API Tensor bmm_nn(Tensor& out, const Tensor& a, const Tensor& b);
|
| 41 |
+
|
| 42 |
+
TORCH_API void debug_assert_shape(int line, const Tensor& t, c10::IntArrayRef shape);
|
| 43 |
+
|
| 44 |
+
TORCH_API Tensor qkv_projection(
|
| 45 |
+
const Tensor& query,
|
| 46 |
+
const Tensor& key,
|
| 47 |
+
const Tensor& value,
|
| 48 |
+
const int64_t embed_dim,
|
| 49 |
+
const Tensor& qkv_weight);
|
| 50 |
+
|
| 51 |
+
using flash_attention_fn = void (*)(
|
| 52 |
+
const Tensor& output, const Tensor& logsumexp,
|
| 53 |
+
const Tensor& query, const Tensor& key, const Tensor& value,
|
| 54 |
+
double dropout_p, bool is_causal,
|
| 55 |
+
std::optional<Tensor> attn_mask,
|
| 56 |
+
std::optional<double> scale);
|
| 57 |
+
|
| 58 |
+
using flash_attention_backward_fn = void (*)(
|
| 59 |
+
const Tensor& grad_q, const Tensor& grad_k,
|
| 60 |
+
const Tensor& grad_v, const Tensor& grad_out,
|
| 61 |
+
const Tensor& query, const Tensor& key,
|
| 62 |
+
const Tensor& value, const Tensor& out, const Tensor& logsumexp,
|
| 63 |
+
double dropout_p, bool is_causal,
|
| 64 |
+
std::optional<Tensor> attn_mask,
|
| 65 |
+
std::optional<double> scale);
|
| 66 |
+
|
| 67 |
+
DECLARE_DISPATCH(flash_attention_fn, flash_attention_kernel)
|
| 68 |
+
DECLARE_DISPATCH(flash_attention_backward_fn, flash_attention_backward_kernel)
|
| 69 |
+
|
| 70 |
+
} // namespace at
|