Skip to content

Commit 0ce23a6

Browse files
authored
Update ggml-common.h
Fixes compilation issue for 'avx512_vnni', 'avx512_vnni_bf16', 'avx512_vnni_vbmi', 'avx512_vnni_vbmi_bf16'
1 parent 073fd6d commit 0ce23a6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

ggml/src/ggml-common.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@
1010
#if defined(GGML_COMMON_DECL_C)
1111
#include <stdint.h>
1212

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+
1337
typedef uint16_t ggml_half;
1438
typedef uint32_t ggml_half2;
1539

0 commit comments

Comments
 (0)