Skip to content

Commit 8129838

Browse files
committed
ggml-cpu: import vecintrin.h to fix compiler errors
Signed-off-by: Aaron Teo <[email protected]>
1 parent 4ad6efa commit 8129838

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

ggml/src/ggml-impl.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,56 @@
2828
#include <immintrin.h>
2929
#endif
3030

31+
#if defined(__VXE__) || defined(__VXE2__)
32+
#include <vecintrin.h>
33+
34+
#define vec_neg(a) (-(a)) // Vector Negate
35+
#define vec_add(a, b) ((a) + (b)) // Vector Add
36+
#define vec_sub(a, b) ((a) - (b)) // Vector Subtract
37+
#define vec_mul(a, b) ((a) * (b)) // Vector Multiply
38+
#define vec_div(a, b) ((a) / (b)) // Vector Divide
39+
#define vec_sl(a, b) ((a) << (b)) // Vector Shift Left
40+
#define vec_sra(a, b) ((a) >> (b)) // Vector Shift Right
41+
#define vec_sr(a, b) ((a) >> (b)) // Vector Shift Right Algebraic
42+
#define vec_slo(a, b) vec_slb(a, (b) << 64) // Vector Shift Left by Octet
43+
#define vec_sro(a, b) vec_srb(a, (b) << 64) // Vector Shift Right by Octet
44+
45+
#ifndef vec_and
46+
#define vec_and(a, b) ((a) & (b)) // Vector AND
47+
#endif
48+
49+
#ifndef vec_or
50+
#define vec_or(a, b) ((a) | (b)) // Vector OR
51+
#endif
52+
53+
#ifndef vec_xor
54+
#define vec_xor(a, b) ((a) ^ (b)) // Vector XOR
55+
#endif
56+
57+
typedef signed char char8x16_t __attribute__((vector_size(16)));
58+
typedef unsigned char uchar8x16_t __attribute__((vector_size(16)));
59+
60+
typedef int8_t int8x16_t __attribute__((vector_size(16)));
61+
typedef int16_t int16x8_t __attribute__((vector_size(16)));
62+
typedef int32_t int32x4_t __attribute__((vector_size(16)));
63+
64+
typedef uint8_t uint8x16_t __attribute__((vector_size(16)));
65+
typedef uint16_t uint16x8_t __attribute__((vector_size(16)));
66+
typedef uint32_t uint32x4_t __attribute__((vector_size(16)));
67+
68+
typedef float float32x4_t __attribute__((vector_size(16)));
69+
typedef double double64x2_t __attribute__((vector_size(16)));
70+
71+
typedef signed long long long64x2_t __attribute__((vector_size(16)));
72+
typedef unsigned long long ulong64x2_t __attribute__((vector_size(16)));
73+
74+
#if defined(GGML_NNPA)
75+
#ifndef __NNPA__
76+
#define __NNPA__
77+
#endif // __NNPA__
78+
#endif // __s390x__ && GGML_NNPA
79+
#endif // __VXE__ || __VXE2__
80+
3181
#ifdef __cplusplus
3282
extern "C" {
3383
#endif

0 commit comments

Comments
 (0)