Kernels
flashinfer-draft / torch-ext /torch_binding.cpp
drbh
feat: generate and vendor flashinfer kernels
57c3a10
Raw
History Blame Contribute Delete
3.59 kB
#include <torch/library.h>
#include "registration.h"
#include "torch_binding.h"
TORCH_LIBRARY_EXPAND(TORCH_EXTENSION_NAME, ops) {
ops.def("gelu_and_mul(Tensor! out, Tensor! input, bool enable_pdl) -> ()");
ops.impl("gelu_and_mul", torch::kCUDA, &gelu_and_mul);
ops.def("gelu_tanh_and_mul(Tensor! out, Tensor! input, bool enable_pdl) -> ()");
ops.impl("gelu_tanh_and_mul", torch::kCUDA, &gelu_tanh_and_mul);
ops.def("silu_and_mul(Tensor! out, Tensor! input, bool enable_pdl) -> ()");
ops.impl("silu_and_mul", torch::kCUDA, &silu_and_mul);
// Register variant-specific operators directly
// ops.def(
// "BatchDecodeWithPagedKVCachePlan_swa_false("
// "Tensor float_workspace_buffer, "
// "Tensor int_workspace_buffer, "
// "Tensor page_locked_int_workspace_buffer, "
// "Tensor indptr, "
// "int batch_size, "
// "int num_qo_heads, "
// "int num_kv_heads, "
// "int page_size, "
// "bool enable_cuda_graph, "
// "int window_left, "
// "float logits_soft_cap, "
// "int head_dim_qk, "
// "int head_dim_vo, "
// "Tensor empty_q_data, "
// "Tensor empty_kv_data) -> Tensor"
// );
// ops.impl("BatchDecodeWithPagedKVCachePlan_swa_false", torch::kCUDA, &BatchDecodeWithPagedKVCachePlan_swa_false);
// ops.def(
// "BatchDecodeWithPagedKVCacheRun_swa_false("
// "Tensor float_workspace_buffer, "
// "Tensor int_workspace_buffer, "
// "Tensor plan_info_vec, "
// "Tensor q, "
// "Tensor paged_k_cache, "
// "Tensor paged_v_cache, "
// "Tensor paged_kv_indptr, "
// "Tensor paged_kv_indices, "
// "Tensor paged_kv_last_page_len, "
// "Tensor o, "
// "Tensor? maybe_lse, "
// "int kv_layout_code, "
// "int window_left, "
// "bool enable_pdl, "
// "Tensor? maybe_alibi_slopes, "
// "float logits_soft_cap, "
// "float sm_scale, "
// "float rope_rcp_scale, "
// "float rope_rcp_theta) -> ()"
// );
// ops.impl("BatchDecodeWithPagedKVCacheRun_swa_false", torch::kCUDA, &BatchDecodeWithPagedKVCacheRun_swa_false);
// ops.def(
// "BatchDecodeWithPagedKVCachePlan_swa_true("
// "Tensor float_workspace_buffer, "
// "Tensor int_workspace_buffer, "
// "Tensor page_locked_int_workspace_buffer, "
// "Tensor indptr, "
// "int batch_size, "
// "int num_qo_heads, "
// "int num_kv_heads, "
// "int page_size, "
// "bool enable_cuda_graph, "
// "int window_left, "
// "float logits_soft_cap, "
// "int head_dim_qk, "
// "int head_dim_vo, "
// "Tensor empty_q_data, "
// "Tensor empty_kv_data) -> Tensor"
// );
// ops.impl("BatchDecodeWithPagedKVCachePlan_swa_true", torch::kCUDA, &BatchDecodeWithPagedKVCachePlan_swa_true);
// ops.def(
// "BatchDecodeWithPagedKVCacheRun_swa_true("
// "Tensor float_workspace_buffer, "
// "Tensor int_workspace_buffer, "
// "Tensor plan_info_vec, "
// "Tensor q, "
// "Tensor paged_k_cache, "
// "Tensor paged_v_cache, "
// "Tensor paged_kv_indptr, "
// "Tensor paged_kv_indices, "
// "Tensor paged_kv_last_page_len, "
// "Tensor o, "
// "Tensor? maybe_lse, "
// "int kv_layout_code, "
// "int window_left, "
// "bool enable_pdl, "
// "Tensor? maybe_alibi_slopes, "
// "float logits_soft_cap, "
// "float sm_scale, "
// "float rope_rcp_scale, "
// "float rope_rcp_theta) -> ()"
// );
// ops.impl("BatchDecodeWithPagedKVCacheRun_swa_true", torch::kCUDA, &BatchDecodeWithPagedKVCacheRun_swa_true);
}
REGISTER_EXTENSION(TORCH_EXTENSION_NAME)