okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-own-2a (7c09c4a75) into f-own-int: the Strata quant layer and the x86 CPU rows9c143c403

main
18.7 KiB358 linesraw
1// x86_helpers.inc - ggml's x86 helpers (horizontal sums, nibble and bit unpacking, scale shuffles, sign tables) (llama.cpp ggml/src/ggml-cpu/arch/x86/quants.c at 3cf03257f219afbe7334045ff7c6a06ac68c627d,
2// Copyright (c) 2023-2026 The ggml authors, MIT) in the layer's signature.  Included by dot_avx.cpp and dot_avx2.cpp inside their tier namespace: the
3// #if __AVX2__ / __AVX__ / generic branches are ggml's own, so each tier gives the bits of ggml-cpu built for that flavour.
4// Needs before it: <immintrin.h>, internal.hpp, h2f / f2h (fp16 conversions) and the strata::quant::generic dot declarations.
5
6// some compilers don't provide _mm256_set_m128i, e.g. gcc 7
7#define MM256_SET_M128I(a, b) _mm256_insertf128_si256(_mm256_castsi128_si256(b), (a), 1)
8
9#if defined(__AVX__) || defined(__AVX2__) || defined(__AVX512F__) || defined(__SSSE3__)
10// multiply int8_t, add results pairwise twice
11static inline __m128i mul_sum_i8_pairs(const __m128i x, const __m128i y) {
12    // Get absolute values of x vectors
13    const __m128i ax = _mm_sign_epi8(x, x);
14    // Sign the values of the y vectors
15    const __m128i sy = _mm_sign_epi8(y, x);
16    // Perform multiplication and create 16-bit values
17    const __m128i dot = _mm_maddubs_epi16(ax, sy);
18    const __m128i ones = _mm_set1_epi16(1);
19    return _mm_madd_epi16(ones, dot);
20}
21
22#if __AVX__ || __AVX2__ || __AVX512F__
23// horizontally add 8 floats
24static inline float hsum_float_8(const __m256 x) {
25    __m128 res = _mm256_extractf128_ps(x, 1);
26    res = _mm_add_ps(res, _mm256_castps256_ps128(x));
27    res = _mm_add_ps(res, _mm_movehl_ps(res, res));
28    res = _mm_add_ss(res, _mm_movehdup_ps(res));
29    return _mm_cvtss_f32(res);
30}
31
32// horizontally add 8 int32_t
33static inline int hsum_i32_8(const __m256i a) {
34    const __m128i sum128 = _mm_add_epi32(_mm256_castsi256_si128(a), _mm256_extractf128_si256(a, 1));
35    const __m128i hi64 = _mm_unpackhi_epi64(sum128, sum128);
36    const __m128i sum64 = _mm_add_epi32(hi64, sum128);
37    const __m128i hi32  = _mm_shuffle_epi32(sum64, _MM_SHUFFLE(2, 3, 0, 1));
38    return _mm_cvtsi128_si32(_mm_add_epi32(sum64, hi32));
39}
40
41// horizontally add 4 int32_t
42static inline int hsum_i32_4(const __m128i a) {
43    const __m128i hi64 = _mm_unpackhi_epi64(a, a);
44    const __m128i sum64 = _mm_add_epi32(hi64, a);
45    const __m128i hi32  = _mm_shuffle_epi32(sum64, _MM_SHUFFLE(2, 3, 0, 1));
46    return _mm_cvtsi128_si32(_mm_add_epi32(sum64, hi32));
47}
48
49#if defined(__AVX2__) || defined(__AVX512F__)
50static inline __m256i mul_add_epi8(const __m256i x, const __m256i y) {
51    const __m256i ax = _mm256_sign_epi8(x, x);
52    const __m256i sy = _mm256_sign_epi8(y, x);
53    return _mm256_maddubs_epi16(ax, sy);
54}
55
56// spread 32 bits to 32 bytes { 0x00, 0xFF }
57static inline __m256i bytes_from_bits_32(const uint8_t * x) {
58    uint32_t x32;
59    memcpy(&x32, x, sizeof(uint32_t));
60    const __m256i shuf_mask = _mm256_set_epi64x(
61            0x0303030303030303, 0x0202020202020202,
62            0x0101010101010101, 0x0000000000000000);
63    __m256i bytes = _mm256_shuffle_epi8(_mm256_set1_epi32(x32), shuf_mask);
64    const __m256i bit_mask = _mm256_set1_epi64x(0x7fbfdfeff7fbfdfe);
65    bytes = _mm256_or_si256(bytes, bit_mask);
66    return _mm256_cmpeq_epi8(bytes, _mm256_set1_epi64x(-1));
67}
68
69// Unpack 32 4-bit fields into 32 bytes
70// The output vector contains 32 bytes, each one in [ 0 .. 15 ] interval
71static inline __m256i bytes_from_nibbles_32(const uint8_t * rsi)
72{
73    const __m128i tmp = _mm_loadu_si128((const __m128i *)rsi);
74    const __m256i bytes = MM256_SET_M128I(_mm_srli_epi16(tmp, 4), tmp);
75    const __m256i lowMask = _mm256_set1_epi8( 0xF );
76    return _mm256_and_si256(lowMask, bytes);
77}
78
79// add int16_t pairwise and return as float vector
80static inline __m256 sum_i16_pairs_float(const __m256i x) {
81    const __m256i ones = _mm256_set1_epi16(1);
82    const __m256i summed_pairs = _mm256_madd_epi16(ones, x);
83    return _mm256_cvtepi32_ps(summed_pairs);
84}
85
86static inline __m256 mul_sum_us8_pairs_float(const __m256i ax, const __m256i sy) {
87#if defined(__AVX512VNNI__) && defined(__AVX512VL__)
88    const __m256i zero = _mm256_setzero_si256();
89    const __m256i summed_pairs = _mm256_dpbusd_epi32(zero, ax, sy);
90    return _mm256_cvtepi32_ps(summed_pairs);
91#elif defined(__AVXVNNI__)
92    const __m256i zero = _mm256_setzero_si256();
93    const __m256i summed_pairs = _mm256_dpbusd_avx_epi32(zero, ax, sy);
94    return _mm256_cvtepi32_ps(summed_pairs);
95#else
96    // Perform multiplication and create 16-bit values
97    const __m256i dot = _mm256_maddubs_epi16(ax, sy);
98    return sum_i16_pairs_float(dot);
99#endif
100}
101
102// multiply int8_t, add results pairwise twice and return as float vector
103static inline __m256 mul_sum_i8_pairs_float(const __m256i x, const __m256i y) {
104#if __AVXVNNIINT8__
105    const __m256i zero = _mm256_setzero_si256();
106    const __m256i summed_pairs = _mm256_dpbssd_epi32(zero, x, y);
107    return _mm256_cvtepi32_ps(summed_pairs);
108#else
109    // Get absolute values of x vectors
110    const __m256i ax = _mm256_sign_epi8(x, x);
111    // Sign the values of the y vectors
112    const __m256i sy = _mm256_sign_epi8(y, x);
113    return mul_sum_us8_pairs_float(ax, sy);
114#endif
115}
116
117static inline __m128i packNibbles( __m256i bytes )
118{
119    // Move bits within 16-bit lanes from 0000_abcd_0000_efgh into 0000_0000_abcd_efgh
120#if __AVX512F__
121    const __m256i bytes_srli_4 = _mm256_srli_epi16(bytes, 4);   // 0000_0000_abcd_0000
122    bytes = _mm256_or_si256(bytes, bytes_srli_4);               // 0000_abcd_abcd_efgh
123    return _mm256_cvtepi16_epi8(bytes);                         // abcd_efgh
124#else
125    const __m256i lowByte = _mm256_set1_epi16( 0xFF );
126    __m256i high = _mm256_andnot_si256( lowByte, bytes );
127    __m256i low = _mm256_and_si256( lowByte, bytes );
128    high = _mm256_srli_epi16( high, 4 );
129    bytes = _mm256_or_si256( low, high );
130
131    // Compress uint16_t lanes into bytes
132    __m128i r0 = _mm256_castsi256_si128( bytes );
133    __m128i r1 = _mm256_extracti128_si256( bytes, 1 );
134    return _mm_packus_epi16( r0, r1 );
135#endif
136}
137#elif defined(__AVX__)
138static inline __m128i packNibbles( __m128i bytes1, __m128i bytes2 )
139{
140    // Move bits within 16-bit lanes from 0000_abcd_0000_efgh into 0000_0000_abcd_efgh
141    const __m128i lowByte = _mm_set1_epi16( 0xFF );
142    __m128i high = _mm_andnot_si128( lowByte, bytes1 );
143    __m128i low = _mm_and_si128( lowByte, bytes1 );
144    high = _mm_srli_epi16( high, 4 );
145    bytes1 = _mm_or_si128( low, high );
146    high = _mm_andnot_si128( lowByte, bytes2 );
147    low = _mm_and_si128( lowByte, bytes2 );
148    high = _mm_srli_epi16( high, 4 );
149    bytes2 = _mm_or_si128( low, high );
150
151    return _mm_packus_epi16( bytes1, bytes2);
152}
153
154static inline __m128i mul_add_epi8_sse(const __m128i x, const __m128i y) {
155    const __m128i ax = _mm_sign_epi8(x, x);
156    const __m128i sy = _mm_sign_epi8(y, x);
157    return _mm_maddubs_epi16(ax, sy);
158}
159
160// spread 32 bits to 32 bytes { 0x00, 0xFF }
161static inline __m256i bytes_from_bits_32(const uint8_t * x) {
162    uint32_t x32;
163    memcpy(&x32, x, sizeof(uint32_t));
164    const __m128i shuf_maskl = _mm_set_epi64x(0x0101010101010101, 0x0000000000000000);
165    const __m128i shuf_maskh = _mm_set_epi64x(0x0303030303030303, 0x0202020202020202);
166    __m128i bytesl = _mm_shuffle_epi8(_mm_set1_epi32(x32), shuf_maskl);
167    __m128i bytesh = _mm_shuffle_epi8(_mm_set1_epi32(x32), shuf_maskh);
168    const __m128i bit_mask = _mm_set1_epi64x(0x7fbfdfeff7fbfdfe);
169    bytesl = _mm_or_si128(bytesl, bit_mask);
170    bytesh = _mm_or_si128(bytesh, bit_mask);
171    bytesl = _mm_cmpeq_epi8(bytesl, _mm_set1_epi64x(-1));
172    bytesh = _mm_cmpeq_epi8(bytesh, _mm_set1_epi64x(-1));
173    return MM256_SET_M128I(bytesh, bytesl);
174}
175
176// Unpack 32 4-bit fields into 32 bytes
177// The output vector contains 32 bytes, each one in [ 0 .. 15 ] interval
178static inline __m256i bytes_from_nibbles_32(const uint8_t * rsi)
179{
180    // Load 16 bytes from memory
181    __m128i tmpl = _mm_loadu_si128((const __m128i *)rsi);
182    __m128i tmph = _mm_srli_epi16(tmpl, 4);
183    const __m128i lowMask = _mm_set1_epi8(0xF);
184    tmpl = _mm_and_si128(lowMask, tmpl);
185    tmph = _mm_and_si128(lowMask, tmph);
186    return MM256_SET_M128I(tmph, tmpl);
187}
188
189// add int16_t pairwise and return as float vector
190static inline __m256 sum_i16_pairs_float(const __m128i xh, const __m128i xl) {
191    const __m128i ones = _mm_set1_epi16(1);
192    const __m128i summed_pairsl = _mm_madd_epi16(ones, xl);
193    const __m128i summed_pairsh = _mm_madd_epi16(ones, xh);
194    const __m256i summed_pairs = MM256_SET_M128I(summed_pairsh, summed_pairsl);
195    return _mm256_cvtepi32_ps(summed_pairs);
196}
197
198static inline __m256 mul_sum_us8_pairs_float(const __m256i ax, const __m256i sy) {
199    const __m128i axl = _mm256_castsi256_si128(ax);
200    const __m128i axh = _mm256_extractf128_si256(ax, 1);
201    const __m128i syl = _mm256_castsi256_si128(sy);
202    const __m128i syh = _mm256_extractf128_si256(sy, 1);
203    // Perform multiplication and create 16-bit values
204    const __m128i dotl = _mm_maddubs_epi16(axl, syl);
205    const __m128i doth = _mm_maddubs_epi16(axh, syh);
206    return sum_i16_pairs_float(doth, dotl);
207}
208
209// multiply int8_t, add results pairwise twice and return as float vector
210static inline __m256 mul_sum_i8_pairs_float(const __m256i x, const __m256i y) {
211    const __m128i xl = _mm256_castsi256_si128(x);
212    const __m128i xh = _mm256_extractf128_si256(x, 1);
213    const __m128i yl = _mm256_castsi256_si128(y);
214    const __m128i yh = _mm256_extractf128_si256(y, 1);
215    // Get absolute values of x vectors
216    const __m128i axl = _mm_sign_epi8(xl, xl);
217    const __m128i axh = _mm_sign_epi8(xh, xh);
218    // Sign the values of the y vectors
219    const __m128i syl = _mm_sign_epi8(yl, xl);
220    const __m128i syh = _mm_sign_epi8(yh, xh);
221    // Perform multiplication and create 16-bit values
222    const __m128i dotl = _mm_maddubs_epi16(axl, syl);
223    const __m128i doth = _mm_maddubs_epi16(axh, syh);
224    return sum_i16_pairs_float(doth, dotl);
225}
226
227// larger version of mul_sum_i8_pairs_float where x and y are each represented by four 128-bit vectors
228static inline __m256 mul_sum_i8_quad_float(const __m128i x_1_0, const __m128i x_1_1, const __m128i x_2_0, const __m128i x_2_1,
229                                           const __m128i y_1_0, const __m128i y_1_1, const __m128i y_2_0, const __m128i y_2_1) {
230    const __m128i mone = _mm_set1_epi16(1);
231
232    const __m128i p16_1_0 = mul_add_epi8_sse(x_1_0, y_1_0);
233    const __m128i p16_1_1 = mul_add_epi8_sse(x_1_1, y_1_1);
234    const __m128i p16_2_0 = mul_add_epi8_sse(x_2_0, y_2_0);
235    const __m128i p16_2_1 = mul_add_epi8_sse(x_2_1, y_2_1);
236    const __m128i p_1_0 = _mm_madd_epi16(p16_1_0, mone);
237    const __m128i p_1_1 = _mm_madd_epi16(p16_1_1, mone);
238    const __m128i p_2_0 = _mm_madd_epi16(p16_2_0, mone);
239    const __m128i p_2_1 = _mm_madd_epi16(p16_2_1, mone);
240    const __m128i p_1 = _mm_add_epi32(p_1_0, p_1_1);
241    const __m128i p_2 = _mm_add_epi32(p_2_0, p_2_1);
242    return _mm256_cvtepi32_ps(MM256_SET_M128I(p_2, p_1));
243}
244
245// quad fp16 delta calculation
246static inline __m256 quad_fp16_delta_float(const float x0, const float y0, const float x1, const float y1) {
247    // h2f is faster than Intel F16C
248    return _mm256_set_m128(_mm_set1_ps(h2f(x1) * h2f(y1)),
249                           _mm_set1_ps(h2f(x0) * h2f(y0)));
250}
251
252static inline __m256 quad_mx_delta_float(const uint8_t x0, const float y0, const uint8_t x1, const float y1) {
253    return _mm256_set_m128(_mm_set1_ps(e8m0_to_fp32_half(x1) * h2f(y1)),
254                           _mm_set1_ps(e8m0_to_fp32_half(x0) * h2f(y0)));
255}
256#endif
257#elif defined(__SSSE3__)
258static inline __m128i bytes_from_bits_16(const uint8_t * x) {
259    uint16_t x16;
260    memcpy(&x16, x, sizeof(uint16_t));
261
262    const __m128i shuf_mask = _mm_set_epi64x(0x0101010101010101, 0x0000000000000000);
263    __m128i bytes = _mm_shuffle_epi8(_mm_set1_epi16((short) x16), shuf_mask);
264    const __m128i bit_mask = _mm_set_epi64x(0x7fbfdfeff7fbfdfe, 0x7fbfdfeff7fbfdfe);
265    bytes = _mm_or_si128(bytes, bit_mask);
266
267    return _mm_cmpeq_epi8(bytes, _mm_set1_epi64x(-1));
268}
269
270// horizontally add 4x4 floats
271static inline float hsum_float_4x4(const __m128 a, const __m128 b, const __m128 c, const __m128 d) {
272    __m128 res_0 =_mm_hadd_ps(a, b);
273    __m128 res_1 =_mm_hadd_ps(c, d);
274    __m128 res =_mm_hadd_ps(res_0, res_1);
275    res =_mm_hadd_ps(res, res);
276    res =_mm_hadd_ps(res, res);
277
278    return _mm_cvtss_f32(res);
279}
280#endif // __AVX__ || __AVX2__ || __AVX512F__
281#endif // defined(__AVX__) || defined(__AVX2__) || defined(__AVX512F__) || defined(__SSSE3__)
282
283#if __AVX__ || __AVX2__ || __AVX512F__
284
285// shuffles to pick the required scales in dot products
286static inline __m256i get_scale_shuffle_q3k(int i) {
287    static const uint8_t k_shuffle[128] = {
288         0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,     2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
289         4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5,     6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7,
290         8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9,    10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,
291        12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,    14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15,
292    };
293    return _mm256_loadu_si256((const __m256i*)k_shuffle + i);
294}
295static inline __m256i get_scale_shuffle_k4(int i) {
296    static const uint8_t k_shuffle[256] = {
297         0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
298         2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
299         4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5,
300         6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7,
301         8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9,
302        10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,
303        12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,
304        14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15
305    };
306    return _mm256_loadu_si256((const __m256i*)k_shuffle + i);
307}
308static inline __m128i get_scale_shuffle(int i) {
309    static const uint8_t k_shuffle[128] = {
310         0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
311         2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
312         4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
313         6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
314         8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,
315        10,10,10,10,10,10,10,10, 11,11,11,11,11,11,11,11,
316        12,12,12,12,12,12,12,12, 13,13,13,13,13,13,13,13,
317        14,14,14,14,14,14,14,14, 15,15,15,15,15,15,15,15
318    };
319    return _mm_loadu_si128((const __m128i*)k_shuffle + i);
320}
321#endif
322
323#if defined (__AVX__) || defined (__AVX2__)
324static const int8_t keven_signs_q2xs[1024] = {
325     1,  1,  1,  1,  1,  1,  1,  1, -1,  1,  1,  1,  1,  1,  1, -1,  1, -1,  1,  1,  1,  1,  1, -1, -1, -1,  1,  1,  1,  1,  1,  1,
326     1,  1, -1,  1,  1,  1,  1, -1, -1,  1, -1,  1,  1,  1,  1,  1,  1, -1, -1,  1,  1,  1,  1,  1, -1, -1, -1,  1,  1,  1,  1, -1,
327     1,  1,  1, -1,  1,  1,  1, -1, -1,  1,  1, -1,  1,  1,  1,  1,  1, -1,  1, -1,  1,  1,  1,  1, -1, -1,  1, -1,  1,  1,  1, -1,
328     1,  1, -1, -1,  1,  1,  1,  1, -1,  1, -1, -1,  1,  1,  1, -1,  1, -1, -1, -1,  1,  1,  1, -1, -1, -1, -1, -1,  1,  1,  1,  1,
329     1,  1,  1,  1, -1,  1,  1, -1, -1,  1,  1,  1, -1,  1,  1,  1,  1, -1,  1,  1, -1,  1,  1,  1, -1, -1,  1,  1, -1,  1,  1, -1,
330     1,  1, -1,  1, -1,  1,  1,  1, -1,  1, -1,  1, -1,  1,  1, -1,  1, -1, -1,  1, -1,  1,  1, -1, -1, -1, -1,  1, -1,  1,  1,  1,
331     1,  1,  1, -1, -1,  1,  1,  1, -1,  1,  1, -1, -1,  1,  1, -1,  1, -1,  1, -1, -1,  1,  1, -1, -1, -1,  1, -1, -1,  1,  1,  1,
332     1,  1, -1, -1, -1,  1,  1, -1, -1,  1, -1, -1, -1,  1,  1,  1,  1, -1, -1, -1, -1,  1,  1,  1, -1, -1, -1, -1, -1,  1,  1, -1,
333     1,  1,  1,  1,  1, -1,  1, -1, -1,  1,  1,  1,  1, -1,  1,  1,  1, -1,  1,  1,  1, -1,  1,  1, -1, -1,  1,  1,  1, -1,  1, -1,
334     1,  1, -1,  1,  1, -1,  1,  1, -1,  1, -1,  1,  1, -1,  1, -1,  1, -1, -1,  1,  1, -1,  1, -1, -1, -1, -1,  1,  1, -1,  1,  1,
335     1,  1,  1, -1,  1, -1,  1,  1, -1,  1,  1, -1,  1, -1,  1, -1,  1, -1,  1, -1,  1, -1,  1, -1, -1, -1,  1, -1,  1, -1,  1,  1,
336     1,  1, -1, -1,  1, -1,  1, -1, -1,  1, -1, -1,  1, -1,  1,  1,  1, -1, -1, -1,  1, -1,  1,  1, -1, -1, -1, -1,  1, -1,  1, -1,
337     1,  1,  1,  1, -1, -1,  1,  1, -1,  1,  1,  1, -1, -1,  1, -1,  1, -1,  1,  1, -1, -1,  1, -1, -1, -1,  1,  1, -1, -1,  1,  1,
338     1,  1, -1,  1, -1, -1,  1, -1, -1,  1, -1,  1, -1, -1,  1,  1,  1, -1, -1,  1, -1, -1,  1,  1, -1, -1, -1,  1, -1, -1,  1, -1,
339     1,  1,  1, -1, -1, -1,  1, -1, -1,  1,  1, -1, -1, -1,  1,  1,  1, -1,  1, -1, -1, -1,  1,  1, -1, -1,  1, -1, -1, -1,  1, -1,
340     1,  1, -1, -1, -1, -1,  1,  1, -1,  1, -1, -1, -1, -1,  1, -1,  1, -1, -1, -1, -1, -1,  1, -1, -1, -1, -1, -1, -1, -1,  1,  1,
341     1,  1,  1,  1,  1,  1, -1, -1, -1,  1,  1,  1,  1,  1, -1,  1,  1, -1,  1,  1,  1,  1, -1,  1, -1, -1,  1,  1,  1,  1, -1, -1,
342     1,  1, -1,  1,  1,  1, -1,  1, -1,  1, -1,  1,  1,  1, -1, -1,  1, -1, -1,  1,  1,  1, -1, -1, -1, -1, -1,  1,  1,  1, -1,  1,
343     1,  1,  1, -1,  1,  1, -1,  1, -1,  1,  1, -1,  1,  1, -1, -1,  1, -1,  1, -1,  1,  1, -1, -1, -1, -1,  1, -1,  1,  1, -1,  1,
344     1,  1, -1, -1,  1,  1, -1, -1, -1,  1, -1, -1,  1,  1, -1,  1,  1, -1, -1, -1,  1,  1, -1,  1, -1, -1, -1, -1,  1,  1, -1, -1,
345     1,  1,  1,  1, -1,  1, -1,  1, -1,  1,  1,  1, -1,  1, -1, -1,  1, -1,  1,  1, -1,  1, -1, -1, -1, -1,  1,  1, -1,  1, -1,  1,
346     1,  1, -1,  1, -1,  1, -1, -1, -1,  1, -1,  1, -1,  1, -1,  1,  1, -1, -1,  1, -1,  1, -1,  1, -1, -1, -1,  1, -1,  1, -1, -1,
347     1,  1,  1, -1, -1,  1, -1, -1, -1,  1,  1, -1, -1,  1, -1,  1,  1, -1,  1, -1, -1,  1, -1,  1, -1, -1,  1, -1, -1,  1, -1, -1,
348     1,  1, -1, -1, -1,  1, -1,  1, -1,  1, -1, -1, -1,  1, -1, -1,  1, -1, -1, -1, -1,  1, -1, -1, -1, -1, -1, -1, -1,  1, -1,  1,
349     1,  1,  1,  1,  1, -1, -1,  1, -1,  1,  1,  1,  1, -1, -1, -1,  1, -1,  1,  1,  1, -1, -1, -1, -1, -1,  1,  1,  1, -1, -1,  1,
350     1,  1, -1,  1,  1, -1, -1, -1, -1,  1, -1,  1,  1, -1, -1,  1,  1, -1, -1,  1,  1, -1, -1,  1, -1, -1, -1,  1,  1, -1, -1, -1,
351     1,  1,  1, -1,  1, -1, -1, -1, -1,  1,  1, -1,  1, -1, -1,  1,  1, -1,  1, -1,  1, -1, -1,  1, -1, -1,  1, -1,  1, -1, -1, -1,
352     1,  1, -1, -1,  1, -1, -1,  1, -1,  1, -1, -1,  1, -1, -1, -1,  1, -1, -1, -1,  1, -1, -1, -1, -1, -1, -1, -1,  1, -1, -1,  1,
353     1,  1,  1,  1, -1, -1, -1, -1, -1,  1,  1,  1, -1, -1, -1,  1,  1, -1,  1,  1, -1, -1, -1,  1, -1, -1,  1,  1, -1, -1, -1, -1,
354     1,  1, -1,  1, -1, -1, -1,  1, -1,  1, -1,  1, -1, -1, -1, -1,  1, -1, -1,  1, -1, -1, -1, -1, -1, -1, -1,  1, -1, -1, -1,  1,
355     1,  1,  1, -1, -1, -1, -1,  1, -1,  1,  1, -1, -1, -1, -1, -1,  1, -1,  1, -1, -1, -1, -1, -1, -1, -1,  1, -1, -1, -1, -1,  1,
356     1,  1, -1, -1, -1, -1, -1, -1, -1,  1, -1, -1, -1, -1, -1,  1,  1, -1, -1, -1, -1, -1, -1,  1, -1, -1, -1, -1, -1, -1, -1, -1,
357};
358#endif