1 //
2 //  Macro.h
3 //  MNN
4 //
5 //  Created by MNN on 2018/07/26.
6 //  Copyright © 2018, Alibaba Group Holding Limited
7 //
8 
9 #ifndef macro_h
10 #define macro_h
11 #include <MNN/MNNDefine.h>
12 
13 #define ALIMIN(x, y) ((x) < (y) ? (x) : (y))
14 #define ALIMAX(x, y) ((x) > (y) ? (x) : (y))
15 
16 #define UP_DIV(x, y) (((x) + (y) - (1)) / (y))
17 #define ROUND_UP(x, y) (((x) + (y) - (1)) / (y) * (y))
18 #define ALIGN_UP4(x) ROUND_UP((x), 4)
19 #define ALIGN_UP8(x) ROUND_UP((x), 8)
20 
21 // fraction length difference is 16bit. calculate the real value, it's about 0.00781
22 #define F32_BF16_MAX_LOSS ((0xffff * 1.0f ) / ( 1 << 23 ))
23 
24 
25 #ifndef MNN_USE_NEON
26 #if (__arm__ || __aarch64__) && (defined(__ARM_NEON__) || defined(__ARM_NEON))
27 #define MNN_USE_NEON
28 #endif
29 #endif
30 
31 #if defined(ENABLE_ARMV82)
32 #if defined(MNN_BUILD_FOR_ANDROID) || defined(__aarch64__)
33 #define MNN_USE_ARMV82
34 #endif
35 #endif
36 
37 #endif /* macro_h */
38