39 ClSoftmax::ClSoftmax()
49 _aux_mem(InternalTensorIdx::COUNT)
59 _needs_permute = actual_axis != 0;
61 const ITensorInfo &tmp_input_info = _needs_permute ? _permuted_src_info :
src;
62 ITensorInfo &tmp_output_info = _needs_permute ? _permuted_dst_info :
dst;
67 _permute_input->configure(compile_context, &src, &_permuted_src_info, perm_info);
71 _tmp_info = tmp_input_info.
clone()->set_data_type(tmp_data_type);
74 _max_info = tmp_input_info.
clone()->set_tensor_shape(max_sum_shape);
75 _sum_info = tmp_input_info.
clone()->set_tensor_shape(max_sum_shape).set_data_type(tmp_data_type);
80 _max_shift_exp_sum_kernel->configure(compile_context, tmp_input_info, _max_info, _tmp_info, _sum_info, info);
81 _norm_kernel->configure(compile_context, _tmp_info, _sum_info, tmp_output_info, info);
86 _permute_output->configure(compile_context, &_permuted_dst_info, &dst, perm_info);
104 const bool needs_permute = actual_axis != 0;
109 TensorInfo input_permuted(src.
clone()->set_tensor_shape(permuted_shape));
111 TensorInfo output_permuted(dst.
clone()->set_tensor_shape(permuted_shape));
117 TensorInfo tensor_info_tmp(src.
clone()->set_data_type(tmp_data_type).set_is_resizable(
true));
120 max_sum_shape.
set(0, 1);
121 TensorInfo tensor_info_max(src.
clone()->set_tensor_shape(max_sum_shape).set_is_resizable(
true));
122 TensorInfo tensor_info_sum(src.
clone()->set_tensor_shape(max_sum_shape).set_data_type(tmp_data_type).set_quantization_info(
QuantizationInfo()).set_is_resizable(
true));
147 _permute_input.get()->run(pack);
177 _permute_output.get()->run(pack);
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
TensorShape compute_permutation_output_shape(const ITensorInfo &input, const PermutationVector &perm)
Calculate the permuted shape of an input given a permutation vector.
static Status validate(const ITensorInfo &src, const ITensorInfo &sum, const ITensorInfo &dst, const SoftmaxKernelInfo &info)
Static function to check if given info will lead to a valid configuration.
PermutationVector get_permutation_vector_from_softmax_axis(size_t axis)
Given a softmax axis, this function returns the permutation vector required to put the axis to the fr...
void add_const_tensor(int id, const ITensor *tensor)
Add const tensor to the pack.
static CLScheduler & get()
Access the scheduler singleton.
void configure(const CLCompileContext &compile_context, const ITensorInfo &src, ITensorInfo &dst, const SoftmaxKernelInfo &info)
Configure the operator.
static Status validate(const ITensorInfo &src, const ITensorInfo &dst, const SoftmaxKernelInfo &info)
Static function to check if given info will lead to a valid configuration.
float beta
A scaling factor for the exponent with default value 1.0.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
void run(ITensorPack &tensors) override
Run the kernels contained in the function.
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Interface for max, shifting, exponentiating and summing the logits.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Interface for calculating the final step of the Softmax Layer where each logit value is multiplied by...
SimpleTensor< float > src
Copyright (c) 2017-2021 Arm Limited.
std::vector< MemoryInfo > MemoryRequirements
static Status validate(const ITensorInfo &src, const ITensorInfo &max, const ITensorInfo &dst, const ITensorInfo &sum)
Static function to check if given info will lead to a valid configuration.
1 channel, 1 S32 per channel
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
T wrap_around(T x, T m)
Wrap-around a number within the range 0 <= x < m.
Quantization information.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
size_t total_size() const override
Returns the total size of the tensor in bytes.
void enqueue_op(ICLKernel &kernel, ITensorPack &tensors, bool flush=true)
Schedule the execution of the passed kernel if possible.
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
experimental::MemoryRequirements workspace() const override
Return the memory requirements required by the workspace.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Strides of an item in bytes.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Store the tensor's metadata.
int offset_int_vec(int offset)
int32_t axis
The dimension in which to apply softmax.
Descriptor used by the softmax kernels.
Basic function to run kernels::ClPermuteKernel.
DataType
Available data types.
TensorShape & set(size_t dimension, size_t value, bool apply_dim_correction=true, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const PermutationVector &perm)
Static function to check if given info will lead to a valid configuration.