37 template <typename T, typename std::enable_if<is_floating_point<T>::value,
int>::type>
44 const int cols = src.
shape()[0];
47 for(
int r = 0; r < upper_dims; ++r)
49 const T *src_row_ptr = src.
data() + r * cols;
50 T *dst_row_ptr =
dst.data() + r * cols;
53 const T
max = *std::max_element(src_row_ptr, src_row_ptr + cols);
57 std::transform(src_row_ptr, src_row_ptr + cols, dst_row_ptr, [&sum, max, beta](T val)
59 const T res(
std::exp((val - max) * beta));
65 std::transform(dst_row_ptr, dst_row_ptr + cols, dst_row_ptr, [sum](T val)
74 template <typename T, typename std::enable_if<std::is_integral<T>::value,
int>::type>
79 using namespace fixed_point_arithmetic;
85 const int cols = src.
shape()[0];
88 for(
int r = 0; r < upper_dims; ++r)
90 const T *src_row_ptr = src.
data() + r * cols;
91 T *dst_row_ptr =
dst.data() + r * cols;
99 std::transform(src_row_ptr, src_row_ptr + cols, dst_row_ptr, [&](T val)
107 fixed_point<T> saturated_sum(
sum);
108 std::transform(dst_row_ptr, dst_row_ptr + cols, dst_row_ptr, [&](T val)
SimpleTensor< uint8_t > softmax_layer< uint8_t >(const SimpleTensor< uint8_t > &src, float beta)
fixed_point< T > exp(fixed_point< T > x)
DATA_TYPE sum(__global const DATA_TYPE *input)
Calculate sum of a vector.
typename promote< T >::type promote_t
Get promoted type.
DataType data_type() const override
Data type of the tensor.
TensorShape shape() const override
Shape of the tensor.
This file contains all available output stages for GEMMLowp on OpenCL.
fixed_point< T > add(fixed_point< T > x, fixed_point< T > y)
SimpleTensor< uint8_t > convert_to_asymmetric(const SimpleTensor< float > &src, const QuantizationInfo &quantization_info)
Convert float simple tensor into quantized using specified quantization information.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
const T * data() const
Constant pointer to the underlying buffer.
Simple tensor object that stores elements in a consecutive chunk of memory.
SimpleTensor< float > convert_from_asymmetric(const SimpleTensor< uint8_t > &src)
Convert quantized simple tensor into float using tensor quantization information. ...
int num_elements() const override
Number of elements of the tensor.
fixed_point< T > div(fixed_point< T > x, fixed_point< T > y)
fixed_point< T > max(fixed_point< T > x, fixed_point< T > y)
Quantization settings (used for QASYMM8 data type)
int fixed_point_position() const override
Number of bits for the fractional part.
convolution configure & src
SimpleTensor< T > softmax_layer(const SimpleTensor< T > &src, float beta)