|
29 | 29 |
|
30 | 30 | #include "cpu/ref_io_helper.hpp"
|
31 | 31 |
|
| 32 | +//NOLINTBEGIN(bugprone-macro-parentheses) |
| 33 | +// These macros are actual pieces of code, can't put certain pieces into `()`. |
| 34 | +// TODO: consider making them functions. |
32 | 35 | #define DEFINE_ARG_SCALES_BUFFER_ATTR(attr, scales, arg) \
|
33 | 36 | alignas(16) float CONCAT2(scales, _buf16)[16] = {0}; \
|
34 | 37 | const float *scales {nullptr}; \
|
|
37 | 40 | utils::array_set(CONCAT2(scales, _buf16), 1.0f, 16); \
|
38 | 41 | scales = CONCAT2(scales, _buf16); \
|
39 | 42 | } else { \
|
40 |
| - scales = CTX_IN_MEM(const float *, DNNL_ARG_ATTR_SCALES | arg); \ |
| 43 | + scales = CTX_IN_MEM(const float *, DNNL_ARG_ATTR_SCALES | (arg)); \ |
41 | 44 | VCHECK_ATTR(scales != nullptr, \
|
42 |
| - "Scales buffer for arg %d is missing", arg); \ |
43 |
| - const auto scales_d = ctx.memory_mdw(DNNL_ARG_ATTR_SCALES | arg); \ |
| 45 | + "Scales buffer for arg %d is missing", (arg)); \ |
| 46 | + const auto scales_d \ |
| 47 | + = ctx.memory_mdw(DNNL_ARG_ATTR_SCALES | (arg)); \ |
44 | 48 | VCHECK_ATTR( \
|
45 | 49 | utils::one_of(scales_d.data_type(), data_type::f32, \
|
46 | 50 | data_type::f16, data_type::bf16, data_type::e8m0), \
|
47 | 51 | "Unsupported scales data type"); \
|
48 | 52 | if (scales_d.nelems() == 1) { \
|
49 | 53 | const float s = cpu::io::load_float_value( \
|
50 | 54 | scales_d.data_type(), scales, 0); \
|
51 |
| - if (utils::one_of(arg, DNNL_ARG_DST, \ |
| 55 | + if (utils::one_of((arg), DNNL_ARG_DST, \ |
52 | 56 | DNNL_ARG_ATTR_POST_OP_DW | DNNL_ARG_DST)) { \
|
53 | 57 | utils::array_set(CONCAT2(scales, _buf16), 1.f / s, 16); \
|
54 | 58 | } else { \
|
|
61 | 65 | MAYBE_UNUSED(scales);
|
62 | 66 |
|
63 | 67 | #define DEFINE_ARG_SCALES_BUFFER(scales, arg) \
|
64 |
| - DEFINE_ARG_SCALES_BUFFER_ATTR(pd()->attr(), scales, arg) |
| 68 | + DEFINE_ARG_SCALES_BUFFER_ATTR(pd()->attr(), scales, (arg)) |
65 | 69 |
|
66 | 70 | #define DEFINE_ZERO_POINTS_BUFFER_ATTR(attr, zero_points_ptr, arg) \
|
67 | 71 | int32_t CONCAT2(default_zero_point_, arg) = 0; \
|
|
74 | 78 | * Accessing `zero_points_ptr` by index will lead to a crash for
|
75 | 79 | * datatypes different from s32. */ \
|
76 | 80 | zero_points_ptr = CTX_IN_MEM( \
|
77 |
| - const int32_t *, DNNL_ARG_ATTR_ZERO_POINTS | arg); \ |
| 81 | + const int32_t *, DNNL_ARG_ATTR_ZERO_POINTS | (arg)); \ |
78 | 82 | VCHECK_ATTR(zero_points_ptr != nullptr, \
|
79 |
| - "Zero points buffer for arg %d is missing", arg); \ |
| 83 | + "Zero points buffer for arg %d is missing", (arg)); \ |
80 | 84 | const auto zero_points_d \
|
81 |
| - = ctx.memory_mdw(DNNL_ARG_ATTR_ZERO_POINTS | arg); \ |
| 85 | + = ctx.memory_mdw(DNNL_ARG_ATTR_ZERO_POINTS | (arg)); \ |
82 | 86 | VCHECK_ATTR(utils::one_of(zero_points_d.data_type(), \
|
83 | 87 | data_type::s32, data_type::s8, data_type::u8, \
|
84 | 88 | data_type::s4, data_type::u4), \
|
|
132 | 136 | #define DEFINE_ZERO_POINT_VALUE(zero_point, mem_arg) \
|
133 | 137 | DEFINE_ZERO_POINT_VALUE_ATTR(pd()->attr(), zero_point, mem_arg)
|
134 | 138 |
|
| 139 | +//NOLINTEND(bugprone-macro-parentheses) |
| 140 | + |
135 | 141 | #endif // CPU_CPU_PRIMITIVE_HPP
|
0 commit comments