|
| 1 | +// This file is part of OpenCV project. |
| 2 | +// It is subject to the license terms in the LICENSE file found in the top-level directory |
| 3 | +// of this distribution and at http://opencv.org/license.html. |
| 4 | + |
| 5 | +#ifndef OPENCV_HAL_RVV_COMMON_HPP_INCLUDED |
| 6 | +#define OPENCV_HAL_RVV_COMMON_HPP_INCLUDED |
| 7 | + |
| 8 | +#include <riscv_vector.h> |
| 9 | + |
| 10 | +namespace cv { namespace cv_hal_rvv { namespace custom_intrin { |
| 11 | + |
| 12 | +#define CV_HAL_RVV_COMMON_CUSTOM_INTRIN_ABS(_Tpvs, _Tpvd, shift, suffix) \ |
| 13 | + inline _Tpvd __riscv_vabs(const _Tpvs& v, const int vl) { \ |
| 14 | + _Tpvs mask = __riscv_vsra(v, shift, vl); \ |
| 15 | + _Tpvs v_xor = __riscv_vxor(v, mask, vl); \ |
| 16 | + return __riscv_vreinterpret_##suffix( \ |
| 17 | + __riscv_vsub(v_xor, mask, vl) \ |
| 18 | + ); \ |
| 19 | + } |
| 20 | + |
| 21 | +CV_HAL_RVV_COMMON_CUSTOM_INTRIN_ABS(vint8m2_t, vuint8m2_t, 7, u8m2) |
| 22 | +CV_HAL_RVV_COMMON_CUSTOM_INTRIN_ABS(vint8m8_t, vuint8m8_t, 7, u8m8) |
| 23 | +CV_HAL_RVV_COMMON_CUSTOM_INTRIN_ABS(vint16m4_t, vuint16m4_t, 15, u16m4) |
| 24 | +CV_HAL_RVV_COMMON_CUSTOM_INTRIN_ABS(vint16m8_t, vuint16m8_t, 15, u16m8) |
| 25 | +CV_HAL_RVV_COMMON_CUSTOM_INTRIN_ABS(vint32m4_t, vuint32m4_t, 31, u32m4) |
| 26 | +CV_HAL_RVV_COMMON_CUSTOM_INTRIN_ABS(vint32m8_t, vuint32m8_t, 31, u32m8) |
| 27 | + |
| 28 | +}}} // cv::cv_hal_rvv::custom_intrin |
| 29 | + |
| 30 | +#endif |
0 commit comments