|
10 | 10 | #if defined(GGML_COMMON_DECL_C) |
11 | 11 | #include <stdint.h> |
12 | 12 |
|
| 13 | +// --- Begin MSVC SIMD operator overloads --- |
| 14 | +#ifdef _MSC_VER |
| 15 | +#include <immintrin.h> |
| 16 | + |
| 17 | +// AVX-512 integer bitwise operators |
| 18 | +inline __m512i operator|(const __m512i& a, const __m512i& b) { return _mm512_or_si512(a, b); } |
| 19 | +inline __m512i operator&(const __m512i& a, const __m512i& b) { return _mm512_and_si512(a, b); } |
| 20 | +inline __m512i operator^(const __m512i& a, const __m512i& b) { return _mm512_xor_si512(a, b); } |
| 21 | + |
| 22 | +// AVX2 integer bitwise operators |
| 23 | +inline __m256i operator|(const __m256i& a, const __m256i& b) { return _mm256_or_si256(a, b); } |
| 24 | +inline __m256i operator&(const __m256i& a, const __m256i& b) { return _mm256_and_si256(a, b); } |
| 25 | +inline __m256i operator^(const __m256i& a, const __m256i& b) { return _mm256_xor_si256(a, b); } |
| 26 | + |
| 27 | +#ifdef __ARM_NEON |
| 28 | +#include <arm_neon.h> |
| 29 | +inline uint8x16_t operator|(uint8x16_t a, uint8x16_t b) { return vorrq_u8(a, b); } |
| 30 | +inline uint8x16_t operator&(uint8x16_t a, uint8x16_t b) { return vandq_u8(a, b); } |
| 31 | +inline int8x16_t operator|(int8x16_t a, int8x16_t b) { return vreinterpretq_s8_u8(vorrq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b))); } |
| 32 | +inline int8x16_t operator&(int8x16_t a, int8x16_t b) { return vreinterpretq_s8_u8(vandq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b))); } |
| 33 | +#endif |
| 34 | +#endif |
| 35 | +// --- End MSVC SIMD operator overloads --- |
| 36 | + |
13 | 37 | typedef uint16_t ggml_half; |
14 | 38 | typedef uint32_t ggml_half2; |
15 | 39 |
|
|
0 commit comments