Kernels
kernel
topk / torch-ext /torch_binding.cpp
marcsun13's picture
marcsun13 HF Staff
topk-metal: top-k over a small row for MoE routers
5bb63f9
Raw History Blame Contribute Delete
320 Bytes
#include <torch/library.h>
#include "registration.h"
#include "torch_binding.h"
TORCH_LIBRARY_EXPAND(TORCH_EXTENSION_NAME, ops) {
ops.def("top_k(Tensor logits, int k, bool softmax) -> Tensor[]");
#if defined(METAL_KERNEL)
ops.impl("top_k", torch::kMPS, &top_k);
#endif
}
REGISTER_EXTENSION(TORCH_EXTENSION_NAME)