Compute Library
 22.08
CpuGemmLowpOutputStage Class Reference

Basic function to execute GEMMLowpQuantizeDown kernels. More...

#include <CpuGemmLowpOutputStage.h>

Collaboration diagram for CpuGemmLowpOutputStage:
[legend]

Public Member Functions

void configure (ITensorInfo *src, 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 INEOperator
 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...
 
INEOperatoroperator= (const INEOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
INEOperatoroperator= (INEOperator &&)=default
 Default move assignment operator. More...
 
 ~INEOperator ()
 Default destructor. 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

Member Function Documentation

◆ configure()

void configure ( ITensorInfo src,
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]srcInput tensor info. Data type supported: S32
[in]biasBiases tensor info. 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 input.
[out]dstOutput tensor info. Data type supported: Data type supported: QASYMM8/QASYMM8_SIGNED/QSYMM16
[in]infoGEMMLowp output stage metadata.

Definition at line 39 of file CpuGemmLowpOutputStage.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_THROW_ON, ARM_COMPUTE_LOG_PARAMS, GEMMLowpOutputStageInfo::gemmlowp_max_bound, GEMMLowpOutputStageInfo::gemmlowp_min_bound, GEMMLowpOutputStageInfo::gemmlowp_multiplier, GEMMLowpOutputStageInfo::gemmlowp_offset, GEMMLowpOutputStageInfo::gemmlowp_shift, arm_compute::test::validation::k, GEMMLowpOutputStageInfo::output_data_type, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, arm_compute::QSYMM16, arm_compute::QUANTIZE_DOWN, arm_compute::QUANTIZE_DOWN_FIXEDPOINT, GEMMLowpOutputStageInfo::type, and CpuGemmLowpOutputStage::validate().

40 {
41  // Perform validate step
44 
45  switch(info.type)
46  {
48  {
49  switch(info.output_data_type)
50  {
51  case DataType::QASYMM8:
52  {
53  auto k = std::make_unique<kernels::CpuGemmLowpQuantizeDownInt32ToUint8ScaleByFixedPointKernel>();
54  k->configure(src, bias, dst, info.gemmlowp_multiplier, info.gemmlowp_shift, info.gemmlowp_offset, info.gemmlowp_min_bound, info.gemmlowp_max_bound);
55  _kernel = std::move(k);
56  break;
57  }
59  {
60  auto k = std::make_unique<kernels::CpuGemmLowpQuantizeDownInt32ToInt8ScaleByFixedPointKernel>();
61  k->configure(src, bias, dst, info.gemmlowp_multiplier, info.gemmlowp_shift, info.gemmlowp_offset, info.gemmlowp_min_bound, info.gemmlowp_max_bound);
62  _kernel = std::move(k);
63  break;
64  }
65  case DataType::QSYMM16:
66  {
67  auto k = std::make_unique<kernels::CpuGemmLowpQuantizeDownInt32ToInt16ScaleByFixedPointKernel>();
68  k->configure(src, bias, dst, info.gemmlowp_multiplier, info.gemmlowp_shift, info.gemmlowp_min_bound, info.gemmlowp_max_bound);
69  _kernel = std::move(k);
70  break;
71  }
72  default:
73  {
74  ARM_COMPUTE_ERROR("Unsupported output data type.");
75  break;
76  }
77  }
78  break;
79  }
81  {
82  switch(info.output_data_type)
83  {
84  case DataType::QASYMM8:
86  {
87  auto k = std::make_unique<kernels::CpuGemmLowpQuantizeDownInt32ScaleKernel>();
88  k->configure(src, bias, dst, &info);
89  _kernel = std::move(k);
90  break;
91  }
92  default:
93  {
94  ARM_COMPUTE_ERROR("Unsupported output data type.");
95  break;
96  }
97  }
98  break;
99  }
100  default:
101  ARM_COMPUTE_ERROR("Unsupported GEMMLowpOutputStage type.");
102  }
103 }
Quantize using a fixed point multiplication.
quantized, symmetric fixed-point 16-bit number
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
SimpleTensor< float > src
Definition: DFT.cpp:155
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
Quantize using an integer multiplication.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_LOG_PARAMS(...)
quantized, asymmetric fixed-point 8-bit number signed
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 INEOperator.

Definition at line 144 of file CpuGemmLowpOutputStage.cpp.

References Window::DimY, Scheduler::get(), and IScheduler::schedule_op().

145 {
146  NEScheduler::get().schedule_op(_kernel.get(), Window::DimY, _kernel->window(), tensors);
147 }
virtual void schedule_op(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors)=0
Runs the kernel in the same thread as the caller synchronously.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94

◆ 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 CpuGemmLowpOutputStage::configure()

Returns
a status

Definition at line 105 of file CpuGemmLowpOutputStage.cpp.

References ARM_COMPUTE_CREATE_ERROR, ARM_COMPUTE_RETURN_ERROR_ON, ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_RETURN_ERROR_ON_MSG, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ITensorInfo::data_type(), GEMMLowpOutputStageInfo::gemmlowp_max_bound, GEMMLowpOutputStageInfo::gemmlowp_min_bound, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, arm_compute::QSYMM16, arm_compute::QUANTIZE_DOWN, arm_compute::QUANTIZE_DOWN_FIXEDPOINT, arm_compute::RUNTIME_ERROR, GEMMLowpOutputStageInfo::type, arm_compute::UNKNOWN, CpuGemmLowpQuantizeDownInt32ScaleKernel::validate(), CpuGemmLowpQuantizeDownInt32ToInt16ScaleByFixedPointKernel::validate(), CpuGemmLowpQuantizeDownInt32ToUint8ScaleByFixedPointKernel::validate(), and CpuGemmLowpQuantizeDownInt32ToInt8ScaleByFixedPointKernel::validate().

Referenced by CpuGemmLowpOutputStage::configure(), and NEGEMMLowpOutputStage::validate().

106 {
108  ARM_COMPUTE_RETURN_ERROR_ON_MSG(dst->data_type() == DataType::UNKNOWN, "CpuGemmLowpOutputStage cannot be used with UNKNOWN output data type.");
111 
112  switch(info.type)
113  {
115  {
116  switch(dst->data_type())
117  {
118  case DataType::QASYMM8:
121  return kernels::CpuGemmLowpQuantizeDownInt32ToInt8ScaleByFixedPointKernel::validate(src, bias, dst, info.gemmlowp_min_bound, info.gemmlowp_max_bound);
122  case DataType::QSYMM16:
124  default:
125  return ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Unsupported output data type.");
126  }
127  }
129  {
130  switch(dst->data_type())
131  {
132  case DataType::QASYMM8:
135  default:
136  return ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Unsupported output data type.");
137  }
138  }
139  default:
140  return ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Unsupported GEMMLowpOutputStage type.");
141  }
142 }
static Status validate(const ITensorInfo *src, const ITensorInfo *bias, const ITensorInfo *dst, int min=0, int max=0)
Static function to check if given info will lead to a valid configuration.
Quantize using a fixed point multiplication.
quantized, symmetric fixed-point 16-bit number
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:296
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, int min=0, int max=0)
Static function to check if given info will lead to a valid configuration.
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.
quantized, asymmetric fixed-point 8-bit number unsigned
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
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Definition: Error.h:244
static Status validate(const ITensorInfo *src, const ITensorInfo *bias, const ITensorInfo *dst, int min=0, int max=0)
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: