Compute Library
 23.11
ClGemmLowpOutputStage.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2021 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
25 
27 #include "arm_compute/core/Types.h"
29 
30 #include "src/common/utils/Log.h"
34 
35 namespace arm_compute
36 {
37 namespace opencl
38 {
40  const ITensorInfo *src,
41  const ITensorInfo *bias,
44 {
47 
48  switch (info.type)
49  {
51  {
52  auto k = std::make_unique<opencl::kernels::ClGemmLowpQuantizeDownInt32ScaleByFixedPointKernel>();
53  k->configure(compile_context, src, bias, dst, &info);
54  _kernel = std::move(k);
55  break;
56  }
58  {
59  auto k = std::make_unique<opencl::kernels::ClGemmLowpQuantizeDownInt32ScaleKernel>();
60  k->configure(compile_context, src, bias, dst, &info);
61  _kernel = std::move(k);
62  break;
63  }
65  {
66  auto k = std::make_unique<opencl::kernels::ClGemmLowpQuantizeDownInt32ScaleByFloatKernel>();
67  k->configure(compile_context, src, bias, dst, &info);
68  _kernel = std::move(k);
69  break;
70  }
71  default:
72  ARM_COMPUTE_ERROR("Unsupported GEMMLowpOutputStage type.");
73  }
74 }
75 
77  const ITensorInfo *bias,
78  const ITensorInfo *dst,
80 {
84 
85  switch (info.type)
86  {
93  default:
94  return ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Unsupported GEMMLowpOutputStage type.");
95  }
96 }
97 
99 {
100  const ITensor *src = tensors.get_const_tensor(ACL_SRC);
101  const ITensor *bias = tensors.get_const_tensor(ACL_BIAS);
102  ITensor *dst = tensors.get_tensor(ACL_DST);
103 
105  CLScheduler::get().enqueue_op(*_kernel, pack, true);
106 }
107 } // namespace opencl
108 } // namespace arm_compute
ClGemmLowpQuantizeDownInt32ScaleByFloatKernel.h
arm_compute::test::validation::src
SimpleTensor< float > src
Definition: DFT.cpp:155
ICLTensor.h
arm_compute::GEMMLowpOutputStageType::QUANTIZE_DOWN_FLOAT
@ QUANTIZE_DOWN_FLOAT
Quantize using a floating point multiplication.
arm_compute::GEMMLowpOutputStageInfo
GEMMLowp output stage info.
Definition: GEMMInfo.h:45
arm_compute::DataType::QASYMM8
@ QASYMM8
quantized, asymmetric fixed-point 8-bit number unsigned
arm_compute::test::validation::dst
auto dst
Definition: DFT.cpp:170
Types.h
ARM_COMPUTE_ERROR
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:354
arm_compute::opencl::kernels::ClGemmLowpQuantizeDownInt32ScaleByFloatKernel::validate
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.
Definition: ClGemmLowpQuantizeDownInt32ScaleByFloatKernel.cpp:88
arm_compute::ITensor
Interface for CPU tensor.
Definition: ITensor.h:36
ClGemmLowpQuantizeDownInt32ScaleKernel.h
arm_compute::opencl::ClGemmLowpOutputStage::run
void run(ITensorPack &tensors) override
Run the kernels contained in the function.
Definition: ClGemmLowpOutputStage.cpp:98
arm_compute::ITensorPack::get_tensor
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
Definition: ITensorPack.cpp:63
ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:952
arm_compute::DataType::QSYMM16
@ QSYMM16
quantized, symmetric fixed-point 16-bit number
ClGemmLowpOutputStage.h
arm_compute::GEMMLowpOutputStageType::QUANTIZE_DOWN
@ QUANTIZE_DOWN
Quantize using an integer multiplication.
arm_compute::ErrorCode::RUNTIME_ERROR
@ RUNTIME_ERROR
Generic runtime error.
ARM_COMPUTE_ERROR_ON_NULLPTR
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:159
arm_compute::ITensorPack::get_const_tensor
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
Definition: ITensorPack.cpp:53
arm_compute::ITensorPack
Tensor packing service.
Definition: ITensorPack.h:39
arm_compute::CLCompileContext
CLCompileContext class.
Definition: CLCompileContext.h:204
arm_compute::ACL_DST
@ ACL_DST
Definition: Types.h:55
arm_compute::Status
Status class.
Definition: Error.h:52
arm_compute::DataType::QASYMM8_SIGNED
@ QASYMM8_SIGNED
quantized, asymmetric fixed-point 8-bit number signed
CLScheduler.h
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
arm_compute::opencl::kernels::ClGemmLowpQuantizeDownInt32ScaleKernel::validate
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.
Definition: ClGemmLowpQuantizeDownInt32ScaleKernel.cpp:88
bias
const int32_t * bias
Definition: working_space.hpp:322
arm_compute::test::validation::pack
ITensorPack pack
Definition: Im2Col.cpp:188
arm_compute::CLScheduler::get
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:112
arm_compute::opencl::ClGemmLowpOutputStage::configure
void configure(const CLCompileContext &compile_context, const ITensorInfo *src, const ITensorInfo *bias, ITensorInfo *dst, const GEMMLowpOutputStageInfo &info)
Initialise the kernel's inputs, output.
Definition: ClGemmLowpOutputStage.cpp:39
arm_compute::ACL_BIAS
@ ACL_BIAS
Definition: Types.h:74
arm_compute
Copyright (c) 2017-2023 Arm Limited.
Definition: introduction.dox:24
arm_compute::opencl::kernels::ClGemmLowpQuantizeDownInt32ScaleByFixedPointKernel::validate
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.
Definition: ClGemmLowpQuantizeDownInt32ScaleByFixedPointKernel.cpp:80
Log.h
ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
arm_compute::CLScheduler::enqueue_op
void enqueue_op(ICLKernel &kernel, ITensorPack &tensors, bool flush=true)
Schedule the execution of the passed kernel if possible.
Definition: CLScheduler.cpp:238
arm_compute::ACL_SRC
@ ACL_SRC
Definition: Types.h:44
arm_compute::ITensorInfo
Store the tensor's metadata.
Definition: ITensorInfo.h:44
ARM_COMPUTE_CREATE_ERROR
#define ARM_COMPUTE_CREATE_ERROR(error_code, msg)
Creates an error with a given message.
Definition: Error.h:158
arm_compute::test::validation::info
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
arm_compute::opencl::ClGemmLowpOutputStage::validate
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.
Definition: ClGemmLowpOutputStage.cpp:76
ClGemmLowpQuantizeDownInt32ScaleByFixedPointKernel.h
ARM_COMPUTE_LOG_PARAMS
#define ARM_COMPUTE_LOG_PARAMS(...)
Definition: Log.h:35
arm_compute::GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT
@ QUANTIZE_DOWN_FIXEDPOINT
Quantize using a fixed point multiplication.