aboutsummaryrefslogtreecommitdiff
path: root/src/core/cpu/kernels/CpuSoftmaxKernel.h
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2021-06-25 05:42:57 +0100
committerGeorgios Pinitas <georgios.pinitas@arm.com>2021-06-29 12:38:33 +0000
commit5fdde99f4271891a40c02cd1e89f1344aa84583a (patch)
tree35944b8bb0eee6aa9bbca08c38325f10cf66370c /src/core/cpu/kernels/CpuSoftmaxKernel.h
parent4a95bba6ca61ce99995ece6fd237b5498c9f322c (diff)
downloadComputeLibrary-5fdde99f4271891a40c02cd1e89f1344aa84583a.tar.gz
Improve selection speed of CPU implementations
CPU micro-kernel to be used was picked during kernel execution. Move selection during configuration to reduce runtime overhead. Standardize kernel names as follows: <simd_tech>_<data_type>_<data_layout>_<kernel_name> e.g. sve_fp32_nhwc_scale Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Change-Id: I544f1c08c8fef0f130a3bde61882ccb9a1f47f21 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5855 Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/cpu/kernels/CpuSoftmaxKernel.h')
-rw-r--r--src/core/cpu/kernels/CpuSoftmaxKernel.h32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/core/cpu/kernels/CpuSoftmaxKernel.h b/src/core/cpu/kernels/CpuSoftmaxKernel.h
index aa10467965..2912098c30 100644
--- a/src/core/cpu/kernels/CpuSoftmaxKernel.h
+++ b/src/core/cpu/kernels/CpuSoftmaxKernel.h
@@ -38,7 +38,7 @@ class CpuLogits1DMaxKernel : public ICpuKernel
{
public:
/** Constructor */
- CpuLogits1DMaxKernel();
+ CpuLogits1DMaxKernel() = default;
ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(CpuLogits1DMaxKernel);
/** Set the input and output tensors.
*
@@ -46,10 +46,9 @@ public:
* @param[out] dst Destination tensor info. Data types supported: same as @p input
*/
void configure(const ITensorInfo *src, ITensorInfo *dst);
- /** Static function to check if given info will lead to a valid configuration of @ref CpuLogits1DMaxKernel
+ /** Static function to check if given info will lead to a valid configuration
*
- * @param[in] src Source tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
- * @param[in] dst Destination tensor info. Data types supported: same as @p input
+ * Similar to CpuLogits1DMaxKernel::configure()
*
* @return a status
*/
@@ -58,6 +57,13 @@ public:
// Inherited methods overridden:
void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) override;
const char *name() const override;
+
+private:
+ using SoftmaxLogits1DMaxKernelPtr = std::add_pointer<void(const ITensor *, ITensor *, const Window &)>::type;
+
+private:
+ SoftmaxLogits1DMaxKernelPtr _run_method{ nullptr };
+ std::string _name{};
};
/** Interface for softmax computation for QASYMM8 with pre-computed max. */
@@ -66,7 +72,7 @@ class CpuLogits1DSoftmaxKernel : public ICpuKernel
{
public:
/** Default constructor */
- CpuLogits1DSoftmaxKernel();
+ CpuLogits1DSoftmaxKernel() = default;
ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(CpuLogits1DSoftmaxKernel);
/** Set the input and output tensors.
@@ -80,14 +86,9 @@ public:
* @param tmp Auxiliary tensor info. Must be type F32 and same shape as the input.
*/
void configure(const ITensorInfo *src, const ITensorInfo *max, ITensorInfo *dst, const float beta, ITensorInfo *tmp);
- /** Static function to check if given info will lead to a valid configuration of @ref CpuLogits1DSoftmaxKernel
+ /** Static function to check if given info will lead to a valid configuration
*
- * @param[in] src Source tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
- * @param[in] max Max values tensor info. Same shape as input with dimension 0 set to 1.
- * Data types supported: same as @p input.
- * @param[in] dst Destination tensor info. Data types supported: same as @p input.
- * @param[in] beta A scaling factor for the exponent.
- * @param[in] tmp Tensor info of auxiliary. Must be type F32 and same shape as the input.
+ * Similar to CpuLogits1DSoftmaxKernel::configure()
*
* @return a status
*/
@@ -99,7 +100,12 @@ public:
const char *name() const override;
private:
- float _beta;
+ using SoftmaxLogits1DKernelPtr = std::add_pointer<void(const ITensor *, const ITensor *, void *const, ITensor *, float, bool, const Window &)>::type;
+
+private:
+ float _beta{ 1.0f };
+ SoftmaxLogits1DKernelPtr _run_method{ nullptr };
+ std::string _name{};
};
} // namespace kernels
} // namespace cpu