15 template <
typename Function>
20 template <typename F, unsigned Arity = function_traits<F>::arity>
22 #define GET_ARG(num) \
23 using remove_reference##num##_t = typename remove_reference<typename function_traits<F>::arg##num##_type>::type; \
24 remove_reference##num##_t* a##num; \
25 a##num = *((remove_reference##num##_t**)(buffer)); \
27 if constexpr (is_ndarray_v<remove_reference##num##_t>) \
30 void* argAddress = *(void**)buffer; \
31 a##num = *((remove_reference##num##_t**)(argAddress)); \
33 else if constexpr (is_pointer<remove_reference##num##_t>::value) \
36 if ((ndarrayValueBit & (1ull << (num - 1))) != 0) \
38 auto ndarray = reinterpret_cast<mu::NDArray<char>*>(buffer); \
39 void* data_ptr = ndarray->data(); \
40 a##num = *reinterpret_cast<remove_reference##num##_t**>(data_ptr); \
46 if (isNormalMode(mode) == false) \
48 void* argAddress = *(void**)buffer; \
49 if ((ndarrayValueBit & (1ull << (num - 1))) != 0) \
51 auto ndarray = reinterpret_cast<mu::NDArray<char>*>(argAddress); \
52 void* data_ptr = ndarray->data(); \
53 a##num = *reinterpret_cast<remove_reference##num##_t**>(data_ptr); \
57 a##num = *((remove_reference##num##_t**)(argAddress)); \
61 buffer += sizeof(void*);
63 #define PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
64 #define ARGS(x) PRIMITIVE_CAT(ARGS_, x)
66 #define ARGS_1 GET_ARG(1);
67 #define ARGS_2 ARGS_1 GET_ARG(2);
68 #define ARGS_3 ARGS_2 GET_ARG(3);
69 #define ARGS_4 ARGS_3 GET_ARG(4);
70 #define ARGS_5 ARGS_4 GET_ARG(5);
71 #define ARGS_6 ARGS_5 GET_ARG(6);
72 #define ARGS_7 ARGS_6 GET_ARG(7);
73 #define ARGS_8 ARGS_7 GET_ARG(8);
74 #define ARGS_9 ARGS_8 GET_ARG(9);
76 #define CALL_PARAMS(x) PRIMITIVE_CAT(CALL_PARAMS_, x)
78 #define CALL_PARAMS_1 *a1
79 #define CALL_PARAMS_2 CALL_PARAMS_1, *a2
80 #define CALL_PARAMS_3 CALL_PARAMS_2, *a3
81 #define CALL_PARAMS_4 CALL_PARAMS_3, *a4
82 #define CALL_PARAMS_5 CALL_PARAMS_4, *a5
83 #define CALL_PARAMS_6 CALL_PARAMS_5, *a6
84 #define CALL_PARAMS_7 CALL_PARAMS_6, *a7
85 #define CALL_PARAMS_8 CALL_PARAMS_7, *a8
86 #define CALL_PARAMS_9 CALL_PARAMS_8, *a9
87 #define CALL_FUNC(x) fp(CALL_PARAMS(x))
89 #define CALL_HELPER(_NUM) \
90 template <typename F> \
91 class CallHelper<F, _NUM> \
94 template <typename FP> \
95 static void invoke(FP fp, [[maybe_unused]] uint32_t mode, uint32_t ndarrayValueBit, [[maybe_unused]] char* buffer) \
140 template <
typename FP>
141 inline void callMain(FP func, uint32_t mode, uint32_t ndarrayValueBit,
char* buffer)
void callMain(FP func, uint32_t mode, uint32_t ndarrayValueBit, char *buffer)
bool isNormalMode(uint32_t mode)