24 #ifndef SRC_CORE_SVE_KERNELS_ELEMENTWISE_LIST_H 25 #define SRC_CORE_SVE_KERNELS_ELEMENTWISE_LIST_H 26 #if defined(ARM_COMPUTE_ENABLE_SVE) 44 template <
typename VectorType>
45 VectorType elementwise_pow(svbool_t &pg,
const VectorType &a,
const VectorType &
b)
47 return svpow_z(pg, a, b);
50 template <
typename VectorType>
51 VectorType elementwise_div(svbool_t &pg,
const VectorType &a,
const VectorType &
b)
53 return svdiv_z(pg, a, b);
56 template <u
int32_t bytew
idth>
57 svbool_t narrow_to_byte_predicate(svbool_t pg)
59 const auto all_false = svpfalse();
64 pg = svuzp1_b32(pg, all_false);
67 pg = svuzp1_b16(pg, all_false);
70 pg = svuzp1_b8(pg, all_false);
78 template <
typename VectorType>
79 VectorType elementwise_arithmetic_op(svbool_t &pg,
const VectorType &a,
const VectorType &
b,
ArithmeticOperation op)
87 res = svmax_z(pg, a, b);
90 res = svmin_z(pg, a, b);
94 const auto tmp = svsub_z(pg, a, b);
95 res = svmul_z(pg, tmp, tmp);
100 const auto zero = svdup_n(ScalarType(0));
101 const auto tmp = svmul_z(pg, a, b);
102 const auto gt = svcmpgt(pg, a, zero);
103 res = svsel(gt, a, tmp);
108 res = elementwise_div(pg, a, b);
113 res = elementwise_pow(pg, a, b);
123 template <
typename InputVectorType,
typename OutputVectorType>
124 OutputVectorType elementwise_comparison_op(svbool_t &pg,
const InputVectorType &a,
const InputVectorType &b,
ComparisonOperation op)
126 svbool_t selection_vector{};
131 selection_vector = svcmpeq(pg, a, b);
134 selection_vector = svcmpne(pg, a, b);
137 selection_vector = svcmpgt(pg, a, b);
140 selection_vector = svcmpge(pg, a, b);
143 selection_vector = svcmplt(pg, a, b);
146 selection_vector = svcmple(pg, a, b);
153 selection_vector = narrow_to_byte_predicate<sizeof(InputScalarType)>(selection_vector);
156 const auto false_vector = svdup_n(static_cast<OutputScalarType>((uint32_t)0));
157 const auto true_vector = svdup_n(static_cast<OutputScalarType>(~(uint32_t)0));
158 auto ret = svsel(selection_vector, true_vector, false_vector);
163 template <ArithmeticOperation op,
typename ScalarType>
164 void elementwise_arithmetic_op(
const ITensor *in1,
const ITensor *in2, ITensor *out,
const Window &window);
166 template <ComparisonOperation op,
typename ScalarType,
typename OutputScalarType = u
int8_t>
167 void elementwise_comparison_op(
const ITensor *in1,
const ITensor *in2, ITensor *out,
const Window &window);
170 #endif // defined(ARM_COMPUTE_ENABLE_SVE) ArithmeticOperation
Available element-wise operations.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
decltype(strategy::transforms) typedef type
Copyright (c) 2017-2021 Arm Limited.
Greater equal comparison ( )
ComparisonOperation
Supported comparison operations.
y*x if x < 0, x otherwise
Less equal comparison ( )