46 result =
static_cast<uint8_t
>(src1 == src2);
49 result =
static_cast<uint8_t
>(src1 != src2);
52 result =
static_cast<uint8_t
>(src1 >= src2);
55 result =
static_cast<uint8_t
>(src1 > src2);
58 result =
static_cast<uint8_t
>(src1 <= src2);
61 result =
static_cast<uint8_t
>(src1 < src2);
66 return (result != 0) ? 255 : 0;
70 struct BroadcastUnroll
74 const SimpleTensor<T> &src1,
const SimpleTensor<T> &src2, SimpleTensor<uint8_t> &
dst,
75 Coordinates &id_src1, Coordinates &id_src2, Coordinates &id_dst)
77 const bool src1_is_broadcast = (src1.shape()[dim - 1] != dst.shape()[dim - 1]);
78 const bool src2_is_broadcast = (src2.shape()[dim - 1] != dst.shape()[dim - 1]);
80 id_src1.set(dim - 1, 0);
81 id_src2.set(dim - 1, 0);
82 id_dst.set(dim - 1, 0);
84 #pragma omp parallel for 86 for(
size_t i = 0; i < dst.shape()[dim - 1]; ++i)
88 BroadcastUnroll < dim - 1 >::unroll(op, src1, src2, dst, id_src1, id_src2, id_dst);
90 id_src1[dim - 1] += !src1_is_broadcast;
91 id_src2[dim - 1] += !src2_is_broadcast;
98 struct BroadcastUnroll<0>
100 template <
typename T>
102 const SimpleTensor<T> &src1,
const SimpleTensor<T> &src2, SimpleTensor<uint8_t> &dst,
103 Coordinates &id_src1, Coordinates &id_src2, Coordinates &id_dst)
110 template <
typename T>
118 BroadcastUnroll<Coordinates::num_max_dimensions>::unroll(op, src1, src2, dst, id_src1, id_src2, id_dst);
135 BroadcastUnroll<Coordinates::num_max_dimensions>::unroll(op, src1_tmp, src2_tmp, dst, id_src1, id_src2, id_dst);
140 BroadcastUnroll<Coordinates::num_max_dimensions>::unroll(op, src1, src2, dst, id_src1, id_src2, id_dst);
158 BroadcastUnroll<Coordinates::num_max_dimensions>::unroll(op, src1_tmp, src2_tmp, dst, id_src1, id_src2, id_dst);
163 BroadcastUnroll<Coordinates::num_max_dimensions>::unroll(op, src1, src2, dst, id_src1, id_src2, id_dst);
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
1 channel, 1 U8 per channel
DataType data_type() const override
Data type of the tensor.
static TensorShape broadcast_shape(const Shapes &... shapes)
If shapes are broadcast compatible, return the broadcasted shape.
SimpleTensor< float > convert_from_asymmetric(const SimpleTensor< uint8_t > &src)
TensorShape shape() const override
Shape of the tensor.
Copyright (c) 2017-2021 Arm Limited.
SimpleTensor< uint8_t > compare(ComparisonOperation op, const SimpleTensor< T > &src1, const SimpleTensor< T > &src2)
int coord2index(const TensorShape &shape, const Coordinates &coord)
Linearise the given coordinate.
Greater equal comparison ( )
quantized, asymmetric fixed-point 8-bit number unsigned
ComparisonOperation
Supported comparison operations.
Less equal comparison ( )
quantized, asymmetric fixed-point 8-bit number signed