/** * \file dnn/src/arm_common/intrinsic_helper.h * MegEngine is Licensed under the Apache License, Version 2.0 (the "License") * * Copyright (c) 2014-2020 Megvii Inc. All rights reserved. * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. */ #pragma once #include "src/arm_common/neon_struct.h" #include "src/arm_common/simd_macro/marm_neon.h" #include "src/common/unroll_macro.h" namespace megdnn { namespace { template struct LoadHelper { static void impl(T& weight, T2 ptr, int oc_offset, XT... args); }; #define WEIGHT_CB(step) \ src[step] = Func::impl(ptr + base_offset + step * ptr_step, args...); #define LOAD_HELPER(step) \ template \ struct LoadHelper { \ static void impl(T& src, T2 ptr, int, XT... args) { \ UNROLL_CALL_RAW(step, WEIGHT_CB); \ } \ } LOAD_HELPER(1); LOAD_HELPER(2); LOAD_HELPER(3); LOAD_HELPER(4); LOAD_HELPER(5); LOAD_HELPER(6); LOAD_HELPER(7); LOAD_HELPER(8); LOAD_HELPER(9); LOAD_HELPER(10); LOAD_HELPER(11); LOAD_HELPER(12); LOAD_HELPER(13); LOAD_HELPER(14); LOAD_HELPER(15); LOAD_HELPER(16); #undef LOAD_HELPER #undef WEIGHT_CB ///////////////////////////c_dim = 1///////////////////////// #define WEIGHT_CB(step) \ src[0][step] = Func::impl(ptr + base_offset + step * ptr_step); #define LOAD_HELPER(step) \ template \ struct LoadHelper { \ static void impl(T& src, T2 ptr, int) { \ UNROLL_CALL_RAW(step, WEIGHT_CB); \ } \ } LOAD_HELPER(1); LOAD_HELPER(2); LOAD_HELPER(3); LOAD_HELPER(4); LOAD_HELPER(5); LOAD_HELPER(6); LOAD_HELPER(7); LOAD_HELPER(8); LOAD_HELPER(9); #undef LOAD_HELPER #undef WEIGHT_CB /////////////////////////c_dim = 2/////////////////////////////// #define WEIGHT_CB(step) \ src[0][step] = Func::impl(ptr + base_offset + step * ptr_step); \ src[1][step] = Func::impl(ptr + base_offset + step * ptr_step + oc_offset); #define LOAD_HELPER(step) \ template \ struct LoadHelper { \ static void impl(T& src, T2 ptr, int oc_offset) { \ UNROLL_CALL_RAW(step, WEIGHT_CB); \ } \ } LOAD_HELPER(1); LOAD_HELPER(2); LOAD_HELPER(3); LOAD_HELPER(4); LOAD_HELPER(5); LOAD_HELPER(6); LOAD_HELPER(7); LOAD_HELPER(8); #undef LOAD_HELPER #undef WEIGHT_CB template inline void load_helper(T& weight, T2 ptr, int oc_offset) { LoadHelper::impl( weight, ptr, oc_offset); } template inline void load_helper_x(T& weight, T2 ptr, int oc_offset, XT... args) { LoadHelper::impl(weight, ptr, oc_offset, args...); } } // namespace } // namespace megdnn // vim: syntax=cpp.doxygen