24.02.1
|
Go to the documentation of this file.
38 template <typename T, typename std::enable_if<is_floating_point<T>::value,
int>
::type>
44 const int32_t n_dims =
static_cast<int32_t
>(
src.shape().num_dimensions());
47 const unsigned int actual_axis =
static_cast<unsigned int>(
wrap_around(axis, n_dims));
50 const unsigned int axis_dimension =
src.shape()[actual_axis];
57 offset.set(actual_axis, 0);
58 T max = *
reinterpret_cast<const T *
>(
src(
offset));
59 for(
unsigned int axis_id = 1; axis_id < axis_dimension; ++axis_id)
61 offset.set(actual_axis, axis_id);
62 const T val = *
reinterpret_cast<const T *
>(
src(
offset));
71 for(
unsigned int axis_id = 0; axis_id < axis_dimension; ++axis_id)
73 offset.set(actual_axis, axis_id);
74 const T val = *
reinterpret_cast<const T *
>(
src(
offset));
75 T res{ (val - max) *beta };
85 *
reinterpret_cast<T *
>(
dst(
offset)) = res;
89 for(
unsigned int axis_id = 0; axis_id < axis_dimension; ++axis_id)
91 offset.set(actual_axis, axis_id);
92 const T val = *
reinterpret_cast<const T *
>(
dst(
offset));
95 *
reinterpret_cast<T *
>(
dst(
offset)) = val -
static_cast<T
>(std::log(sum));
99 *
reinterpret_cast<T *
>(
dst(
offset)) = val / sum;
109 template <typename T, typename std::enable_if<is_floating_point<T>::value,
int>
::type>
112 return softmax_layer_generic<T>(
src, beta, axis, is_log);
115 template < typename T, typename std::enable_if < std::is_same<T, uint8_t>::value || std::is_same<T, int8_t>::value,
int >
::type >
SimpleTensor< float > src
decltype(strategy::transforms) typedef type
Quantization information.
SimpleTensor< float > convert_from_asymmetric(const SimpleTensor< uint8_t > &src)
void use_tensor_dimensions(const TensorShape &shape, size_t first_dimension=Window::DimX)
Use the tensor's dimensions to fill the window dimensions.
T wrap_around(T x, T m)
Wrap-around a number within the range 0 <= x < m.
SimpleTensor< T > softmax_layer(const SimpleTensor< T > &src, float beta, int32_t axis, bool is_log)
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
QuantizationInfo get_softmax_output_quantization_info(DataType input_type, bool is_log)
Returns output quantization information for softmax layer.
SimpleTensor< T > softmax_layer_generic(const SimpleTensor< T > &src, float beta, int32_t axis, bool is_log)
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&...iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Describe one of the image's dimensions with a start, end and step.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Simple tensor object that stores elements in a consecutive chunk of memory.
Describe a multidimensional execution window.
Copyright (c) 2017-2024 Arm Limited.