21.02
|
Basic function to compute a SoftmaxLayer. More...
#include <CLSoftmaxLayer.h>
Public Member Functions | |
CLSoftmaxLayerGeneric (std::shared_ptr< IMemoryManager > memory_manager=nullptr) | |
Constructor. More... | |
CLSoftmaxLayerGeneric (const CLSoftmaxLayerGeneric &)=delete | |
Prevent instances of this class from being copied. More... | |
CLSoftmaxLayerGeneric & | operator= (const CLSoftmaxLayerGeneric &)=delete |
Prevent instances of this class from being copied. More... | |
CLSoftmaxLayerGeneric (CLSoftmaxLayerGeneric &&)=delete | |
Prevent instances of this class to be moved. More... | |
CLSoftmaxLayerGeneric & | operator= (CLSoftmaxLayerGeneric &&)=delete |
Prevent instances of this class to be moved. More... | |
~CLSoftmaxLayerGeneric () | |
Default destructor. More... | |
void | configure (const ICLTensor *input, ICLTensor *output, float beta=1.0f, int32_t axis=0) |
Set the input and output tensors. More... | |
void | configure (const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, float beta=1.0f, int32_t axis=0) |
Set the input and output tensors. More... | |
void | run () override |
Run the kernels contained in the function. More... | |
Public Member Functions inherited from IFunction | |
virtual | ~IFunction ()=default |
Destructor. More... | |
virtual void | prepare () |
Prepare the function for executing. More... | |
Static Public Member Functions | |
static Status | validate (const ITensorInfo *input, const ITensorInfo *output, float beta=1.0f, int32_t axis=0) |
Static function to check if given info will lead to a valid configuration of CLSoftmaxLayer. More... | |
Basic function to compute a SoftmaxLayer.
Softmax is calculated by :
\[ out = exp((x - max(x)) * beta) / sum(exp((x - max(x)) * beta)) \]
Log Softmax is calculated by :
\[ out = (x - max(x) * beta) - log(\sum{e^{x - max(x) * beta}}) \]
This function runs the following kernels:
Definition at line 58 of file CLSoftmaxLayer.h.
CLSoftmaxLayerGeneric | ( | std::shared_ptr< IMemoryManager > | memory_manager = nullptr | ) |
Constructor.
Definition at line 40 of file CLSoftmaxLayer.cpp.
References CLSoftmaxLayerGeneric< IS_LOG >::~CLSoftmaxLayerGeneric().
|
delete |
Prevent instances of this class from being copied.
|
delete |
Prevent instances of this class to be moved.
|
default |
Default destructor.
Referenced by CLSoftmaxLayerGeneric< IS_LOG >::CLSoftmaxLayerGeneric().
Set the input and output tensors.
[in] | input | Source tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32 for Softmax and F16/F32 for Log Softmax |
[out] | output | Destination tensor. Data types supported: same as input |
[in] | beta | (Optional) A scaling factor for the exponent. Defaults to 1.f |
[in] | axis | (Optional) The dimension in which to apply the function. E.g. for input of shape 4x5x6 and axis=1, softmax will be applied to 4x6=24 vectors of size 5. Defaults to 0 |
Definition at line 59 of file CLSoftmaxLayer.cpp.
References CLKernelLibrary::get().
void configure | ( | const CLCompileContext & | compile_context, |
const ICLTensor * | input, | ||
ICLTensor * | output, | ||
float | beta = 1.0f , |
||
int32_t | axis = 0 |
||
) |
Set the input and output tensors.
[in] | compile_context | The compile context to be used. |
[in] | input | Source tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32 for Softmax and F16/F32 for Log Softmax |
[out] | output | Destination tensor. Data types supported: same as input |
[in] | beta | (Optional) A scaling factor for the exponent. Defaults to 1.f |
[in] | axis | (Optional) The dimension in which to apply the function. E.g. for input of shape 4x5x6 and axis=1, softmax will be applied to 4x6=24 vectors of size 5. Defaults to 0 |
Definition at line 65 of file CLSoftmaxLayer.cpp.
References CLTensorAllocator::allocate(), CLTensor::allocator(), ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, SoftmaxKernelInfo::beta, ICloneable< T >::clone(), CLPermute::configure(), ITensorInfo::data_type(), CLScheduler::get(), arm_compute::softmax_helpers::get_permutation_vector_from_softmax_axis(), ITensor::info(), ITensorAllocator::init(), arm_compute::test::validation::input, SoftmaxKernelInfo::input_data_type, arm_compute::is_data_type_quantized_asymmetric(), SoftmaxKernelInfo::is_log, MemoryGroup::manage(), ITensorInfo::num_dimensions(), arm_compute::S32, TensorShape::set(), ITensorInfo::tensor_shape(), and arm_compute::wrap_around().
|
delete |
Prevent instances of this class from being copied.
|
delete |
Prevent instances of this class to be moved.
|
overridevirtual |
Run the kernels contained in the function.
For Neon kernels:
For OpenCL kernels:
Implements IFunction.
Definition at line 163 of file CLSoftmaxLayer.cpp.
References CLScheduler::enqueue(), CLScheduler::get(), and CLPermute::run().
|
static |
Static function to check if given info will lead to a valid configuration of CLSoftmaxLayer.
[in] | input | Source tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32 for Softmax and F16/F32 for Log Softmax |
[in] | output | Destination tensor. Data types supported: same as input |
[in] | beta | (Optional) A scaling factor for the exponent. Defaults to 1.f |
[in] | axis | (Optional) The dimension in which to apply the function. E.g. for input of shape 4x5x6 and axis=1, softmax will be applied to 4x6=24 vectors of size 5. Defaults to 0 |
Definition at line 123 of file CLSoftmaxLayer.cpp.
References ARM_COMPUTE_RETURN_ERROR_ON, ARM_COMPUTE_RETURN_ERROR_ON_MSG, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, ARM_COMPUTE_UNUSED, SoftmaxKernelInfo::beta, ICloneable< T >::clone(), arm_compute::misc::shape_calculator::compute_permutation_output_shape(), ITensorInfo::data_type(), arm_compute::softmax_helpers::get_permutation_vector_from_softmax_axis(), arm_compute::is_data_type_quantized_asymmetric(), ITensorInfo::num_dimensions(), arm_compute::S32, TensorShape::set(), ITensorInfo::tensor_shape(), CLLogits1DMaxShiftExpSumKernel::validate(), CLPermute::validate(), CLLogits1DNormKernel::validate(), and arm_compute::wrap_around().
Referenced by arm_compute::test::validation::DATA_TEST_CASE().