|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include "../device.hpp" |
| 4 | +#include "common/op.hpp" |
| 5 | + |
| 6 | +namespace infinicore::op { |
| 7 | + |
| 8 | +class TopKRouter { |
| 9 | +public: |
| 10 | + // values_output: [N, topk] float32 |
| 11 | + // indices_output: [N, topk] int32 |
| 12 | + // input: [N, width] float16/bfloat16/float32 |
| 13 | + // correction_bias: [width] float32 |
| 14 | + using schema = void (*)(Tensor, Tensor, Tensor, Tensor, float, size_t); |
| 15 | + static void execute(Tensor values_output, |
| 16 | + Tensor indices_output, |
| 17 | + Tensor input, |
| 18 | + Tensor correction_bias, |
| 19 | + float routed_scaling_factor, |
| 20 | + size_t topk); |
| 21 | + static common::OpDispatcher<schema> &dispatcher(); |
| 22 | +}; |
| 23 | + |
| 24 | +std::pair<Tensor, Tensor> topkrouter(Tensor input, |
| 25 | + Tensor correction_bias, |
| 26 | + float routed_scaling_factor, |
| 27 | + size_t topk); |
| 28 | + |
| 29 | +void topkrouter_(Tensor values_output, |
| 30 | + Tensor indices_output, |
| 31 | + Tensor input, |
| 32 | + Tensor correction_bias, |
| 33 | + float routed_scaling_factor, |
| 34 | + size_t topk); |
| 35 | + |
| 36 | +} // namespace infinicore::op |
| 37 | + |
| 38 | +#pragma once |
| 39 | + |
| 40 | +#include "../device.hpp" |
| 41 | +#include "common/op.hpp" |
| 42 | + |
| 43 | +namespace infinicore::op { |
| 44 | + |
| 45 | +class TopKRouter { |
| 46 | +public: |
| 47 | + // values_output: [N, topk] float32 |
| 48 | + // indices_output: [N, topk] int32 |
| 49 | + // input: [N, width] float16/bfloat16/float32 |
| 50 | + // correction_bias: [width] float32 |
| 51 | + using schema = void (*)(Tensor, Tensor, Tensor, Tensor, float, size_t); |
| 52 | + static void execute(Tensor values_output, |
| 53 | + Tensor indices_output, |
| 54 | + Tensor input, |
| 55 | + Tensor correction_bias, |
| 56 | + float routed_scaling_factor, |
| 57 | + size_t topk); |
| 58 | + static common::OpDispatcher<schema> &dispatcher(); |
| 59 | +}; |
| 60 | + |
| 61 | +std::pair<Tensor, Tensor> topkrouter(Tensor input, |
| 62 | + Tensor correction_bias, |
| 63 | + float routed_scaling_factor, |
| 64 | + size_t topk); |
| 65 | + |
| 66 | +void topkrouter_(Tensor values_output, |
| 67 | + Tensor indices_output, |
| 68 | + Tensor input, |
| 69 | + Tensor correction_bias, |
| 70 | + float routed_scaling_factor, |
| 71 | + size_t topk); |
| 72 | + |
| 73 | +} // namespace infinicore::op |
| 74 | + |
0 commit comments