Compute Library
 23.05
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 
32 #include "arm_compute/core/Types.h"
33 
34 #include "src/core/CL/ICLKernel.h"
36 
37 #include <algorithm>
38 
39 namespace arm_compute
40 {
41 struct CLGEMMLowpOutputStage::Impl
42 {
43  const ICLTensor *src{ nullptr };
44  const ICLTensor *bias{ nullptr };
45  ICLTensor *dst{ nullptr };
46  std::unique_ptr<opencl::ClGemmLowpOutputStage> op{ nullptr };
47  ITensorPack run_pack{};
48 };
49 
51  : _impl(std::make_unique<Impl>())
52 {
53 }
57 
59 {
60  configure(CLKernelLibrary::get().get_compile_context(), input, bias, output, info);
61 }
62 
64 {
65  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
66 
67  _impl->src = input;
68  _impl->bias = bias;
69  _impl->dst = output;
70 
71  _impl->op = std::make_unique<opencl::ClGemmLowpOutputStage>();
72  _impl->op->configure(compile_context, input->info(), bias != nullptr ? bias->info() : nullptr, output->info(), info);
73  _impl->run_pack = { { ACL_SRC, _impl->src }, { ACL_BIAS, _impl->bias }, { ACL_DST, _impl->dst } };
74 }
75 
77 {
78  return opencl::ClGemmLowpOutputStage::validate(input, bias, output, info);
79 }
80 
82 {
83  _impl->op->run(_impl->run_pack);
84 }
85 } // namespace arm_compute
~CLGEMMLowpOutputStage()
Default destructor.
Basic function to execute GEMMLowpQuantizeDown kernels on CL.
void configure(const ICLTensor *input, const ICLTensor *bias, ICLTensor *output, const GEMMLowpOutputStageInfo &info)
Initialise the kernel&#39;s inputs, output.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:43
Manages all the OpenCL kernels compilation and caching, provides accessors for the OpenCL Context...
Status class.
Definition: Error.h:52
CLGEMMLowpOutputStage & operator=(const CLGEMMLowpOutputStage &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
SimpleTensor< float > src
Definition: DFT.cpp:155
Copyright (c) 2017-2023 Arm Limited.
static Status validate(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo &info)
Static function to check if given info will lead to a valid configuration of opencl::kernels::ClGemmL...
void run() override
Run the kernels contained in the function.
GEMMLowp output stage info.
Definition: Types.h:2307
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
CLCompileContext class.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157
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.
const int32_t * bias