| | #include <torch/library.h> |
| |
|
| | #include "registration.h" |
| | #include "torch_binding.h" |
| |
|
| | TORCH_LIBRARY_EXPAND(TORCH_EXTENSION_NAME, ops) { |
| | |
| | ops.def("silu_and_mul(Tensor! out, Tensor input) -> ()"); |
| | ops.impl("silu_and_mul", torch::kCUDA, &silu_and_mul); |
| |
|
| | |
| | ops.def("topk_softmax(Tensor! topk_weights, Tensor! topk_indices, Tensor! " |
| | "token_expert_indices, Tensor gating_output) -> ()"); |
| | ops.impl("topk_softmax", torch::kCUDA, &topk_softmax); |
| |
|
| | |
| | |
| | ops.def("moe_sum(Tensor! input, Tensor output) -> ()"); |
| | ops.impl("moe_sum", torch::kCUDA, &moe_sum); |
| |
|
| | |
| | |
| | ops.def("moe_align_block_size(Tensor topk_ids, int num_experts," |
| | " int block_size, Tensor! sorted_token_ids," |
| | " Tensor! experts_ids," |
| | " Tensor! num_tokens_post_pad) -> ()"); |
| | ops.impl("moe_align_block_size", torch::kCUDA, &moe_align_block_size); |
| |
|
| | #ifndef USE_ROCM |
| | ops.def("marlin_gemm_moe(Tensor! a, Tensor! b_q_weights, Tensor! sorted_ids, " |
| | "Tensor! topk_weights, Tensor! topk_ids, Tensor! b_scales, Tensor! " |
| | "b_zeros, Tensor! g_idx, Tensor! perm, Tensor! workspace, " |
| | "int b_q_type, SymInt size_m, " |
| | "SymInt size_n, SymInt size_k, bool is_k_full, int num_experts, int " |
| | "topk, " |
| | "int moe_block_size, bool replicate_input, bool apply_weights)" |
| | " -> Tensor"); |
| | #endif |
| | } |
| |
|
| | TORCH_LIBRARY_IMPL_EXPAND(TORCH_EXTENSION_NAME, CUDA, ops) { |
| | ops.impl("marlin_gemm_moe", &marlin_gemm_moe); |
| | } |
| |
|
| | REGISTER_EXTENSION(TORCH_EXTENSION_NAME) |
| |
|