infinicore.h 2.57 KB
Newer Older
PanZezhongQY's avatar
PanZezhongQY committed
1
2
3
4
5
6
7
8
#ifndef __INFINICORE_H__
#define __INFINICORE_H__
#include <stdint.h>

#ifndef __INFINICORE_EXPORT_C__
#define __INFINICORE_EXPORT_C__
#if defined(_WIN32)
#define __export __declspec(dllexport)
PanZezhong's avatar
PanZezhong committed
9
10
#elif defined(__GNUC__) &&                                                     \
    ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
PanZezhongQY's avatar
PanZezhongQY committed
11
12
13
14
15
16
17
18
19
20
21
22
#define __export __attribute__((visibility("default")))
#else
#define __export
#endif

#ifdef __cplusplus
#define __C extern "C"
#include <cstddef>
#else
#define __C
#include <stddef>
#endif
PanZezhong's avatar
PanZezhong committed
23
#endif // __INFINICORE_EXPORT_C__
PanZezhongQY's avatar
PanZezhongQY committed
24
25
26

#ifndef __INFINI_DEVICE__
#define __INFINI_DEVICE__
PanZezhong's avatar
PanZezhong committed
27
typedef enum {
PanZezhongQY's avatar
PanZezhongQY committed
28
29
30
31
32
33
34
35
36
37
    INFINI_DEVICE_CPU = 0,
    INFINI_DEVICE_NVIDIA = 1,
    INFINI_DEVICE_CAMBRICON = 2,
    INFINI_DEVICE_ASCEND = 3,
    INFINI_DEVICE_METAX = 4,
    INFINI_DEVICE_MOORE = 5,
    INFINI_DEVICE_ILUVATAR = 6,
    INFINI_DEVICE_KUNLUN = 7,
    INFINI_DEVICE_SUGON = 8,
} infiniDevice_t;
PanZezhong's avatar
PanZezhong committed
38
#endif // __INFINI_DEVICE__
PanZezhongQY's avatar
PanZezhongQY committed
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

#ifndef __INFINI_DTYPE__
#define __INFINI_DTYPE__
typedef enum {
    INFINI_DTYPE_INVALID = 0,
    INFINI_DTYPE_BYTE = 1,
    INFINI_DTYPE_BOOL = 2,
    INFINI_DTYPE_I8 = 3,
    INFINI_DTYPE_I16 = 4,
    INFINI_DTYPE_I32 = 5,
    INFINI_DTYPE_I64 = 6,
    INFINI_DTYPE_U8 = 7,
    INFINI_DTYPE_U16 = 8,
    INFINI_DTYPE_U32 = 9,
    INFINI_DTYPE_U64 = 10,
    INFINI_DTYPE_F8 = 11,
    INFINI_DTYPE_F16 = 12,
    INFINI_DTYPE_F32 = 13,
    INFINI_DTYPE_F64 = 14,
    INFINI_DTYPE_C8 = 15,
    INFINI_DTYPE_C16 = 16,
    INFINI_DTYPE_C32 = 17,
    INFINI_DTYPE_C64 = 18,
    INFINI_DTYPE_BF16 = 19,
} infiniDtype_t;

PanZezhong's avatar
PanZezhong committed
65
inline size_t infiniSizeof(infiniDtype_t dtype) {
PanZezhongQY's avatar
PanZezhongQY committed
66
    switch (dtype) {
PanZezhong's avatar
PanZezhong committed
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
    case INFINI_DTYPE_INVALID:
        return 0;
    case INFINI_DTYPE_BYTE:
        return 1;
    case INFINI_DTYPE_BOOL:
        return 1;
    case INFINI_DTYPE_I8:
        return 1;
    case INFINI_DTYPE_I16:
        return 2;
    case INFINI_DTYPE_I32:
        return 4;
    case INFINI_DTYPE_I64:
        return 8;
    case INFINI_DTYPE_U8:
        return 1;
    case INFINI_DTYPE_U16:
        return 2;
    case INFINI_DTYPE_U32:
        return 4;
    case INFINI_DTYPE_U64:
        return 8;
    case INFINI_DTYPE_F8:
        return 1;
    case INFINI_DTYPE_F16:
        return 2;
    case INFINI_DTYPE_F32:
        return 4;
    case INFINI_DTYPE_F64:
        return 8;
    case INFINI_DTYPE_C8:
        return 2;
    case INFINI_DTYPE_C16:
        return 4;
    case INFINI_DTYPE_C32:
        return 8;
    case INFINI_DTYPE_C64:
        return 16;
    case INFINI_DTYPE_BF16:
        return 2;
    default:
        return 0;
PanZezhongQY's avatar
PanZezhongQY committed
109
110
    }
}
PanZezhong's avatar
PanZezhong committed
111
#endif // __INFINI_DTYPE__
PanZezhongQY's avatar
PanZezhongQY committed
112

PanZezhong's avatar
PanZezhong committed
113
#endif // __INFINICORE_H__