#include #include #include #include #include #include #ifdef TK_COMPILE_BLOCK_SPARSE extern std::vector block_sparse_attention_forward( torch::Tensor q, torch::Tensor k, torch::Tensor v, torch::Tensor q2k_block_sparse_index, torch::Tensor q2k_block_sparse_num, torch::Tensor block_size, torch::Tensor q_block_size ); extern std::vector block_sparse_attention_backward( torch::Tensor q, torch::Tensor k, torch::Tensor v, torch::Tensor o, torch::Tensor l_vec, torch::Tensor og, torch::Tensor k2q_block_sparse_index, torch::Tensor k2q_block_sparse_num, torch::Tensor block_size, torch::Tensor q_block_size ); #endif PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { m.doc() = "Video Sparse Attention Kernels"; // optional module docstring #ifdef TK_COMPILE_BLOCK_SPARSE m.def("block_sparse_fwd", torch::wrap_pybind_function(block_sparse_attention_forward), "block sparse attention"); m.def("block_sparse_bwd", torch::wrap_pybind_function(block_sparse_attention_backward), "block sparse attention backward"); #endif }