Compute Library
 22.11
ClGemmLowpOutputStage Class Reference

Basic function to execute GEMMLowpQuantizeDown kernels on CL. More...

#include <ClGemmLowpOutputStage.h>

Collaboration diagram for ClGemmLowpOutputStage:
[legend]

Public Member Functions

 ClGemmLowpOutputStage ()=default
 Constructor. More...
 
void configure (const CLCompileContext &compile_context, const ITensorInfo *src, const ITensorInfo *bias, ITensorInfo *dst, const GEMMLowpOutputStageInfo &info)
 Initialise the kernel's inputs, output. More...
 
void run (ITensorPack &tensors) override
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from ICLOperator
 ICLOperator (IRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 ICLOperator (const ICLOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 ICLOperator (ICLOperator &&)=default
 Default move constructor. More...
 
ICLOperatoroperator= (const ICLOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
ICLOperatoroperator= (ICLOperator &&)=default
 Default move assignment operator. More...
 
void prepare (ITensorPack &constants) override
 Prepare the function for executing. More...
 
MemoryRequirements workspace () const override
 Return the memory requirements required by the workspace. More...
 
- Public Member Functions inherited from IOperator
virtual ~IOperator ()=default
 Destructor. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *src, const ITensorInfo *bias, const ITensorInfo *dst, const GEMMLowpOutputStageInfo &info)
 Static function to check if given info will lead to a valid configuration. More...
 

Detailed Description

Basic function to execute GEMMLowpQuantizeDown kernels on CL.

This function calls the following CL kernels:

  1. opencl::kernels::ClGemmLowpQuantizeDownInt32ScaleKernel
  2. opencl::kernels::ClGemmLowpQuantizeDownInt32ScaleByFloatKernel
  3. opencl::kernels::ClGemmLowpQuantizeDownInt32ScaleByFixedPointKernel

Definition at line 50 of file ClGemmLowpOutputStage.h.

Constructor & Destructor Documentation

◆ ClGemmLowpOutputStage()

ClGemmLowpOutputStage ( )
default

Constructor.

Member Function Documentation

◆ configure()

void configure ( const CLCompileContext compile_context,
const ITensorInfo src,
const ITensorInfo bias,
ITensorInfo dst,
const GEMMLowpOutputStageInfo info 
)

Initialise the kernel's inputs, output.

Valid data layouts:

  • All

Valid data type configurations:

src0 src1 dst
S32 S32 QASYMM8
S32 S32 QASYMM8_SIGNED
S32 S32 QSYMM16
Parameters
[in]compile_contextThe compile context to be used.
[in]srcSource tensor. Data type supported: S32
[in]biasBiases tensor. Only shared biases supported and it can be a nullptr if the biases addition is not required. Biases are 1D tensor with dimensions [OFM]. Data type supported: Same as src.
[out]dstDestination tensor. Data type supported: QASYMM8/QASYMM8_SIGNED
[in]infoGEMMLowp output stage metadata.

Definition at line 40 of file ClGemmLowpOutputStage.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_LOG_PARAMS, arm_compute::test::validation::k, arm_compute::QUANTIZE_DOWN, arm_compute::QUANTIZE_DOWN_FIXEDPOINT, arm_compute::QUANTIZE_DOWN_FLOAT, and GEMMLowpOutputStageInfo::type.

41 {
44 
45  switch(info.type)
46  {
48  {
49  auto k = std::make_unique<opencl::kernels::ClGemmLowpQuantizeDownInt32ScaleByFixedPointKernel>();
50  k->configure(compile_context, src, bias, dst, &info);
51  _kernel = std::move(k);
52  break;
53  }
55  {
56  auto k = std::make_unique<opencl::kernels::ClGemmLowpQuantizeDownInt32ScaleKernel>();
57  k->configure(compile_context, src, bias, dst, &info);
58  _kernel = std::move(k);
59  break;
60  }
62  {
63  auto k = std::make_unique<opencl::kernels::ClGemmLowpQuantizeDownInt32ScaleByFloatKernel>();
64  k->configure(compile_context, src, bias, dst, &info);
65  _kernel = std::move(k);
66  break;
67  }
68  default:
69  ARM_COMPUTE_ERROR("Unsupported GEMMLowpOutputStage type.");
70  }
71 }
Quantize using a fixed point multiplication.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
SimpleTensor< float > src
Definition: DFT.cpp:155
Quantize using a floating point multiplication.
Quantize using an integer multiplication.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_LOG_PARAMS(...)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157
const int32_t * bias

◆ run()

void run ( ITensorPack tensors)
overridevirtual

Run the kernels contained in the function.

Parameters
[in]tensorsVector that contains the tensors to operate on.

Reimplemented from ICLOperator.

Definition at line 91 of file ClGemmLowpOutputStage.cpp.

References arm_compute::ACL_BIAS, arm_compute::ACL_DST, arm_compute::ACL_SRC, bias, arm_compute::test::validation::dst, CLScheduler::enqueue_op(), CLScheduler::get(), ITensorPack::get_const_tensor(), ITensorPack::get_tensor(), arm_compute::test::validation::pack, and arm_compute::test::validation::src.

92 {
93  const ITensor *src = tensors.get_const_tensor(ACL_SRC);
94  const ITensor *bias = tensors.get_const_tensor(ACL_BIAS);
95  ITensor *dst = tensors.get_tensor(ACL_DST);
96 
97  ITensorPack pack{ { ACL_SRC, src }, { ACL_BIAS, bias }, { ACL_DST, dst } };
98  CLScheduler::get().enqueue_op(*_kernel, pack, true);
99 }
static CLScheduler & get()
Access the scheduler singleton.
SimpleTensor< float > src
Definition: DFT.cpp:155
void enqueue_op(ICLKernel &kernel, ITensorPack &tensors, bool flush=true)
Schedule the execution of the passed kernel if possible.
const int32_t * bias

◆ validate()

Status validate ( const ITensorInfo src,
const ITensorInfo bias,
const ITensorInfo dst,
const GEMMLowpOutputStageInfo info 
)
static

Static function to check if given info will lead to a valid configuration.

Similar to ClGemmLowpOutputStage::configure()

Returns
a status

Definition at line 73 of file ClGemmLowpOutputStage.cpp.

References ARM_COMPUTE_CREATE_ERROR, ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, arm_compute::QSYMM16, arm_compute::QUANTIZE_DOWN, arm_compute::QUANTIZE_DOWN_FIXEDPOINT, arm_compute::QUANTIZE_DOWN_FLOAT, arm_compute::RUNTIME_ERROR, GEMMLowpOutputStageInfo::type, ClGemmLowpQuantizeDownInt32ScaleByFixedPointKernel::validate(), ClGemmLowpQuantizeDownInt32ScaleByFloatKernel::validate(), and ClGemmLowpQuantizeDownInt32ScaleKernel::validate().

Referenced by CLGEMMLowpOutputStage::validate().

74 {
77 
78  switch(info.type)
79  {
86  default:
87  return ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Unsupported GEMMLowpOutputStage type.");
88  }
89 }
Quantize using a fixed point multiplication.
quantized, symmetric fixed-point 16-bit number
SimpleTensor< float > src
Definition: DFT.cpp:155
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:159
static Status validate(const ITensorInfo *src, const ITensorInfo *bias, const ITensorInfo *dst, const GEMMLowpOutputStageInfo *info)
Static function to check if given info will lead to a valid configuration.
quantized, asymmetric fixed-point 8-bit number unsigned
static Status validate(const ITensorInfo *src, const ITensorInfo *bias, const ITensorInfo *dst, const GEMMLowpOutputStageInfo *output_stage)
Static function to check if given info will lead to a valid configuration.
Quantize using a floating point multiplication.
Quantize using an integer multiplication.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_CREATE_ERROR(error_code, msg)
Creates an error with a given message.
Definition: Error.h:159
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:788
static Status validate(const ITensorInfo *src, const ITensorInfo *bias, const ITensorInfo *dst, const GEMMLowpOutputStageInfo *info)
Static function to check if given info will lead to a valid configuration.
quantized, asymmetric fixed-point 8-bit number signed
const int32_t * bias

The documentation for this class was generated from the following files: