45 intermediate_type val =
static_cast<intermediate_type
>(src1) + static_cast<intermediate_type>(src2);
53 struct BroadcastUnroll
56 static void unroll(
const SimpleTensor<T> &src1,
const SimpleTensor<T> &src2, SimpleTensor<T> &
dst,
57 ConvertPolicy convert_policy, Coordinates &id_src1, Coordinates &id_src2, Coordinates &id_dst)
59 const bool src1_is_broadcast = (src1.shape()[dim - 1] != dst.shape()[dim - 1]);
60 const bool src2_is_broadcast = (src2.shape()[dim - 1] != dst.shape()[dim - 1]);
62 id_src1.set(dim - 1, 0);
63 id_src2.set(dim - 1, 0);
64 id_dst.set(dim - 1, 0);
66 for(
size_t i = 0; i < dst.shape()[dim - 1]; ++i, ++id_dst[dim - 1])
68 BroadcastUnroll < dim - 1 >::unroll(src1, src2, dst, convert_policy, id_src1, id_src2, id_dst);
70 id_src1[dim - 1] += !src1_is_broadcast;
71 id_src2[dim - 1] += !src2_is_broadcast;
77 struct BroadcastUnroll<0>
80 static void unroll(
const SimpleTensor<T> &src1,
const SimpleTensor<T> &src2, SimpleTensor<T> &dst,
81 ConvertPolicy convert_policy, Coordinates &id_src1, Coordinates &id_src2, Coordinates &id_dst)
95 BroadcastUnroll<Coordinates::num_max_dimensions>::unroll(src1, src2, dst, convert_policy, id_src1, id_src2, id_dst);
TensorShape shape() const override
Shape of the tensor.
This file contains all available output stages for GEMMLowp on OpenCL.
int coord2index(const TensorShape &shape, const Coordinates &coord)
Linearise the given coordinate.
fixed_point< T > add(fixed_point< T > x, fixed_point< T > y)
SimpleTensor< T > arithmetic_addition(const SimpleTensor< T > &src1, const SimpleTensor< T > &src2, DataType dst_data_type, ConvertPolicy convert_policy)
static TensorShape broadcast_shape(const Shapes &...shapes)
If shapes are broadcast compatible, return the broadcasted shape.
Simple tensor object that stores elements in a consecutive chunk of memory.
DataType
Available data types.
ConvertPolicy
Policy to handle overflow.