24.02.1
|
Basic function to compute a SoftmaxLayer. More...
#include <CLSoftmaxLayer.h>
Public Member Functions | |
CLSoftmaxLayerGeneric (std::shared_ptr< IMemoryManager > memory_manager=nullptr) | |
Constructor. 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}}) \]
Definition at line 48 of file CLSoftmaxLayer.h.
CLSoftmaxLayerGeneric | ( | std::shared_ptr< IMemoryManager > | memory_manager = nullptr | ) |
Constructor.
Definition at line 54 of file CLSoftmaxLayer.cpp.
|
default |
Default destructor.
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 70 of file CLSoftmaxLayer.cpp.
References arm_compute::ACL_DST, arm_compute::ACL_SRC, ITensor::info(), and arm_compute::test::validation::input.
Set the input and output tensors.
Valid data layouts:
Valid data type configurations:
src | dst |
---|---|
QASYMM8 | QASYMM8 |
QASYMM8_SIGNED | QASYMM8_SIGNED |
F16 | F16 |
F32 | F32 |
[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 64 of file CLSoftmaxLayer.cpp.
References arm_compute::test::validation::configure(), CLKernelLibrary::get(), and arm_compute::test::validation::input.
Referenced by arm_compute::test::validation::TEST_CASE().
|
overridevirtual |
Run the kernels contained in the function.
For CPU kernels:
For OpenCL kernels:
Implements IFunction.
Definition at line 93 of file CLSoftmaxLayer.cpp.
References ARM_COMPUTE_ERROR_ON_NULLPTR.
Referenced by arm_compute::test::validation::TEST_CASE().
|
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 86 of file CLSoftmaxLayer.cpp.
References arm_compute::test::validation::input, and ClGemm::validate().