rope.h 1.28 KB
Newer Older
1
2
#ifndef __INFINIOP_ROPE_API_H__
#define __INFINIOP_ROPE_API_H__
PanZezhongQY's avatar
PanZezhongQY committed
3

PanZezhong's avatar
PanZezhong committed
4
#include "../operator_descriptor.h"
PanZezhongQY's avatar
PanZezhongQY committed
5

6
7
8
9
10
11
12
typedef enum {
    INFINIOP_ROPE_ALGO_GPT_J = 0,    // GPT-J style RoPE algorithm (Interleave even and odd dimensions)
    INFINIOP_ROPE_ALGO_GPT_NEOX = 1, // GPT-NeoX style RoPE algorithm (First half dimensions for sin, second half for cos)
    // Count
    INFINIOP_ROPE_ALGO_COUNT = 2,
} infiniopRoPEAlgo_t;

13
typedef struct InfiniopDescriptor *infiniopRoPEDescriptor_t;
PanZezhongQY's avatar
PanZezhongQY committed
14

15
__INFINI_C __export infiniStatus_t infiniopCreateRoPEDescriptor(
PanZezhongQY's avatar
PanZezhongQY committed
16
17
    infiniopHandle_t handle,
    infiniopRoPEDescriptor_t *desc_ptr,
18
19
    infiniopTensorDescriptor_t y,
    infiniopTensorDescriptor_t x,
PanZezhongQY's avatar
PanZezhongQY committed
20
21
    infiniopTensorDescriptor_t pos_ids,
    infiniopTensorDescriptor_t sin_table,
22
23
    infiniopTensorDescriptor_t cos_table,
    infiniopRoPEAlgo_t algo);
PanZezhongQY's avatar
PanZezhongQY committed
24

25
__INFINI_C __export infiniStatus_t infiniopGetRoPEWorkspaceSize(infiniopRoPEDescriptor_t desc, size_t *size);
PanZezhongQY's avatar
PanZezhongQY committed
26

27
__INFINI_C __export infiniStatus_t infiniopRoPE(
PanZezhongQY's avatar
PanZezhongQY committed
28
29
30
    infiniopRoPEDescriptor_t desc,
    void *workspace,
    size_t workspace_size,
31
32
    void *y,
    const void *x,
PanZezhongQY's avatar
PanZezhongQY committed
33
34
35
36
37
    void const *pos_ids,
    void const *sin_table,
    void const *cos_table,
    void *stream);

38
__INFINI_C __export infiniStatus_t infiniopDestroyRoPEDescriptor(infiniopRoPEDescriptor_t desc);
PanZezhongQY's avatar
PanZezhongQY committed
39
40

#endif