23.08
|
Basic function to compute a SoftmaxLayer and a Log SoftmaxLayer. More...
#include <CpuSoftmax.h>
Public Member Functions | |
CpuSoftmaxGeneric () | |
void | configure (const ITensorInfo *src, ITensorInfo *dst, float beta=1.0f, int32_t axis=0) |
Set the input and output tensors. More... | |
void | run (ITensorPack &tensors) override |
Run the kernels contained in the function. More... | |
experimental::MemoryRequirements | workspace () const override |
Return the memory requirements required by the workspace. More... | |
![]() | |
INEOperator (IRuntimeContext *ctx=nullptr) | |
Constructor. More... | |
INEOperator (const INEOperator &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
INEOperator (INEOperator &&)=default | |
Default move constructor. More... | |
INEOperator & | operator= (const INEOperator &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
INEOperator & | operator= (INEOperator &&)=default |
Default move assignment operator. More... | |
~INEOperator () | |
Default destructor. More... | |
void | prepare (ITensorPack &constants) override |
Prepare the function for executing. More... | |
![]() | |
virtual | ~IOperator ()=default |
Destructor. More... | |
Static Public Member Functions | |
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. More... | |
Basic function to compute a SoftmaxLayer and a Log 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 function/kernels:
Definition at line 57 of file CpuSoftmax.h.
Definition at line 44 of file CpuSoftmax.cpp.
void configure | ( | const ITensorInfo * | src, |
ITensorInfo * | dst, | ||
float | beta = 1.0f , |
||
int32_t | axis = 0 |
||
) |
Set the input and output tensors.
[in,out] | src | Source tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32. last value of each row to the nearest multiple. |
[out] | dst | Destination tensor ifo. Data types supported: same as input . |
[in] | beta | (Optional) A scaling factor for the exponent. |
[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 CpuSoftmax.cpp.
References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, ARM_COMPUTE_LOG_PARAMS, ICloneable< T >::clone(), ITensorInfo::data_type(), arm_compute::test::validation::dst, arm_compute::F32, arm_compute::softmax_helpers::get_permutation_vector_from_softmax_axis(), arm_compute::test::validation::input_info, arm_compute::is_data_type_quantized_asymmetric(), TensorShape::set(), arm_compute::test::validation::src, ITensorInfo::tensor_shape(), CpuSoftmaxGeneric< IS_LOG >::validate(), and arm_compute::wrap_around().
|
overridevirtual |
Run the kernels contained in the function.
[in] | tensors | Vector that contains the tensors to operate on. |
Reimplemented from INEOperator.
Definition at line 158 of file CpuSoftmax.cpp.
References arm_compute::ACL_DST, arm_compute::ACL_DST_0, arm_compute::ACL_DST_1, arm_compute::ACL_SRC, arm_compute::ACL_SRC_0, arm_compute::ACL_SRC_1, ITensorPack::add_tensor(), ARM_COMPUTE_ERROR_ON_MSG, Window::DimY, arm_compute::test::validation::dst, ITensorPack::empty(), Scheduler::get(), CpuAuxTensorHandler::get(), ITensorPack::get_const_tensor(), ITensorPack::get_tensor(), MAX, arm_compute::offset_int_vec(), IScheduler::schedule_op(), and arm_compute::test::validation::src.
|
static |
Static function to check if given info will lead to a valid configuration.
Similar to CpuSoftmaxGeneric::configure()
Definition at line 120 of file CpuSoftmax.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, arm_compute::misc::shape_calculator::compute_permutation_output_shape(), arm_compute::test::validation::dst, arm_compute::softmax_helpers::get_permutation_vector_from_softmax_axis(), TensorShape::set(), arm_compute::test::validation::src, CpuPermute::validate(), CpuLogits1DMaxKernel::validate(), and arm_compute::wrap_around().
Referenced by CpuSoftmaxGeneric< IS_LOG >::configure().
|
overridevirtual |
Return the memory requirements required by the workspace.
Reimplemented from INEOperator.
Definition at line 215 of file CpuSoftmax.cpp.