"examples/pooling/embed/template/dse_qwen2_vl.jinja" did not exist on "2ca8867f0322aac5927d6b6741619ec36349c7ac"
topkrouter.h 3.77 KB
Newer Older
1
2
#ifndef _TOPKTOUTER_H_
#define _TOPKTOUTER_H_
blkmjsian's avatar
blkmjsian committed
3
4
5
6

#include "../../operator.h"
#include "info.h"

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#define DESCRIPTOR(NAMESPACE)                                                          \
                                                                                       \
    namespace op::topkrouter::NAMESPACE {                                              \
    class Descriptor final : public InfiniopDescriptor {                               \
        struct Opaque;                                                                 \
        Opaque *_opaque;                                                               \
        TopkrouterInfo _info;                                                          \
        size_t _workspace_size;                                                        \
                                                                                       \
        Descriptor(Opaque *opaque,                                                     \
                   TopkrouterInfo info,                                                \
                   size_t workspace_size,                                              \
                   infiniDevice_t device_type,                                         \
                   int device_id)                                                      \
            : InfiniopDescriptor{device_type, device_id},                              \
              _opaque(opaque),                                                         \
              _info(info),                                                             \
              _workspace_size(workspace_size) {                                        \
        }                                                                              \
                                                                                       \
    public:                                                                            \
        ~Descriptor();                                                                 \
                                                                                       \
        size_t workspaceSize() const {                                                 \
            return _workspace_size;                                                    \
        }                                                                              \
                                                                                       \
        static infiniStatus_t create(infiniopHandle_t handle,                          \
                                     Descriptor **desc_ptr,                            \
                                     infiniopTensorDescriptor_t x_desc,                \
                                     infiniopTensorDescriptor_t correction_bias_desc); \
                                                                                       \
        infiniStatus_t calculate(void *workspace,                                      \
                                 size_t workspace_size,                                \
                                 float *values,                                        \
                                 int *indices,                                         \
                                 const void *x,                                        \
                                 const float *correction_bias,                         \
                                 const float routed_scaling_factor,                    \
                                 const size_t topk,                                    \
                                 void *stream) const;                                  \
    };                                                                                 \
blkmjsian's avatar
blkmjsian committed
49
50
51
    }

#endif // _Topkrouter_H_