42 template <
bool IS_LOG>
52 _needs_permute(false),
53 _aux_mem(InternalTensorIdx::COUNT)
57 template <
bool IS_LOG>
64 const unsigned int actual_axis =
static_cast<unsigned int>(
wrap_around(axis, static_cast<int32_t>(src->
num_dimensions())));
66 _needs_permute = actual_axis > 0;
75 const ITensorInfo *tmp_input = (_needs_permute ? &_input_permuted :
src);
79 max_sum_shape.
set(0, 1);
82 TensorInfo tensor_info_tmp(input_info.
clone()->set_data_type(tmp_data_type));
83 TensorInfo max_info(tmp_input->
clone()->set_tensor_shape(max_sum_shape));
90 auto mk = std::make_unique<kernels::CpuLogits1DMaxKernel>();
91 mk->configure(tmp_input, &_max);
92 _max_kernel = std::move(mk);
94 auto sm = std::make_unique<kernels::CpuLogits1DSoftmaxKernel<IS_LOG>>();
98 sm->configure(tmp_input, &_max, &_output_permuted, beta, &_tmp);
106 sm->configure(tmp_input, &_max, dst, beta, &_tmp);
108 _softmax_kernel = std::move(sm);
117 template <
bool IS_LOG>
128 const TensorInfo tensor_info_tmp(src->
clone()->set_data_type(tmp_data_type).set_is_resizable(
true));
131 max_sum_shape.
set(0, 1);
132 const TensorInfo tensor_info_max_sum(src->
clone()->set_tensor_shape(max_sum_shape).set_data_type(tmp_data_type).set_quantization_info(src->
quantization_info()).set_is_resizable(
true));
135 const unsigned int actual_axis =
static_cast<unsigned int>(
wrap_around(axis, static_cast<int32_t>(src->
num_dimensions())));
137 const bool needs_permute = actual_axis > 0;
143 TensorInfo input_permuted(src->
clone()->set_tensor_shape(permuted_shape));
145 TensorInfo output_permuted(dst->
clone()->set_tensor_shape(permuted_shape));
155 template <
bool IS_LOG>
175 _permute_input.
run(permute_in_pack);
208 _permute_output.
run(permute_out_pack);
212 template <
bool IS_LOG>
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration.
TensorShape compute_permutation_output_shape(const ITensorInfo &input, const PermutationVector &perm)
Calculate the permuted shape of an input given a permutation vector.
std::unique_ptr< ITensorInfo > clone() const override
Provide a clone of the current object of class T.
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...
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, float beta=1.0f, int32_t axis=0)
Static function to check if given info will lead to a valid configuration.
bool empty() const
Checks if pack is empty.
#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.
virtual void schedule_op(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors)=0
Runs the kernel in the same thread as the caller synchronously.
1 channel, 1 F32 per channel
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Interface for softmax computation for QASYMM8 with pre-computed max.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
SimpleTensor< float > src
Copyright (c) 2017-2021 Arm Limited.
std::vector< MemoryInfo > MemoryRequirements
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
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.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
void configure(const ITensorInfo *src, ITensorInfo *dst, float beta=1.0f, int32_t axis=0)
Set the input and output tensors.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
size_t total_size() const override
Returns the total size of the tensor in bytes.
void run(ITensorPack &tensors) override
Run the kernels contained in the function.
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
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.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
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.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
void run(ITensorPack &tensors) override
Run the kernels contained in the function.
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
experimental::MemoryRequirements workspace() const override
Return the memory requirements required by the workspace.
void configure(const ITensorInfo *src, ITensorInfo *dst, const PermutationVector &perm)
Configure operator for a given list of arguments.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Store the tensor's metadata.
int offset_int_vec(int offset)
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.
Basic function to compute a SoftmaxLayer and a Log SoftmaxLayer.
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
static IScheduler & get()
Access the scheduler singleton.