Validate tensor: must be XPU, contiguous, [B, L, H, 128], B=1
| 11 | |
| 12 | // Validate tensor: must be XPU, contiguous, [B, L, H, 128], B=1 |
| 13 | static void check_sdp_tensor(const torch::Tensor& t, const char* name) { |
| 14 | TORCH_CHECK(t.device().type() == c10::DeviceType::XPU, |
| 15 | name, " must be on XPU"); |
| 16 | TORCH_CHECK(t.is_contiguous(), |
| 17 | name, " must be contiguous"); |
| 18 | TORCH_CHECK(t.dim() == 4, |
| 19 | name, " must be 4-D [B, L, H, 128]"); |
| 20 | TORCH_CHECK(t.size(0) == 1, |
| 21 | name, " batch size must be 1"); |
| 22 | TORCH_CHECK(t.size(3) == 128, |
| 23 | name, " head_dim must be 128"); |
| 24 | } |
| 25 | |
| 26 | // ────────────────────────────────────────────────────────────────────────────── |
| 27 | // sdp: unified Flash Attention SDP |