blob: 8351cc66d0482ad34f668dd861e0dacce5592f72 [file] [log] [blame]
Gian Marcoe75a02b2017-11-08 12:24:09 +00001/*
Manuel Bottiniae58bdf2021-06-17 17:18:45 +01002 * Copyright (c) 2017-2021 Arm Limited.
Gian Marcoe75a02b2017-11-08 12:24:09 +00003 *
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 */
24#include "arm_compute/runtime/NEON/functions/NEGEMMLowpOutputStage.h"
25
26#include "arm_compute/core/ITensor.h"
Michele Di Giorgio9c700372020-01-08 11:33:44 +000027#include "arm_compute/core/Validate.h"
Manuel Bottiniae58bdf2021-06-17 17:18:45 +010028#include "src/runtime/cpu/operators/CpuGemmLowpOutputStage.h"
Gian Marcoe75a02b2017-11-08 12:24:09 +000029
Gian Marco Iodicebc415af2019-06-13 15:58:32 +010030namespace arm_compute
31{
Manuel Bottiniae58bdf2021-06-17 17:18:45 +010032struct NEGEMMLowpOutputStage::Impl
Gian Marco58c57942017-11-28 09:10:03 +000033{
Manuel Bottiniae58bdf2021-06-17 17:18:45 +010034 const ITensor *src{ nullptr };
35 const ITensor *bias{ nullptr };
36 ITensor *dst{ nullptr };
37 ITensorPack run_pack{};
38 std::unique_ptr<cpu::CpuGemmLowpOutputStage> op{ nullptr };
39};
Gian Marco58c57942017-11-28 09:10:03 +000040
Manuel Bottiniae58bdf2021-06-17 17:18:45 +010041NEGEMMLowpOutputStage::NEGEMMLowpOutputStage()
42 : _impl(std::make_unique<Impl>())
Gian Marco58c57942017-11-28 09:10:03 +000043{
Gian Marco Iodicebc415af2019-06-13 15:58:32 +010044}
Michalis Spyrouebcebf12020-10-21 00:04:14 +010045NEGEMMLowpOutputStage::~NEGEMMLowpOutputStage() = default;
46
Michele Di Giorgio9c700372020-01-08 11:33:44 +000047void NEGEMMLowpOutputStage::configure(const ITensor *input, const ITensor *bias, ITensor *output, const GEMMLowpOutputStageInfo &info)
48{
49 // Perform validate step
50 ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
51 ARM_COMPUTE_ERROR_THROW_ON(NEGEMMLowpOutputStage::validate(input->info(), bias != nullptr ? bias->info() : nullptr, output->info(), info));
Manuel Bottiniae58bdf2021-06-17 17:18:45 +010052 _impl->src = input;
53 _impl->bias = bias;
54 _impl->dst = output;
55 _impl->op = std::make_unique<cpu::CpuGemmLowpOutputStage>();
56 _impl->op->configure(input->info(), (bias == nullptr) ? nullptr : bias->info(), output->info(), info);
Michele Di Giorgio9c700372020-01-08 11:33:44 +000057
Manuel Bottiniae58bdf2021-06-17 17:18:45 +010058 _impl->run_pack =
Michele Di Giorgio9c700372020-01-08 11:33:44 +000059 {
Manuel Bottiniae58bdf2021-06-17 17:18:45 +010060 { TensorType::ACL_SRC, _impl->src },
61 { TensorType::ACL_BIAS, _impl->bias },
62 { TensorType::ACL_DST, _impl->dst }
63 };
Michele Di Giorgio9c700372020-01-08 11:33:44 +000064}
65
66Status NEGEMMLowpOutputStage::validate(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo &info)
67{
Manuel Bottiniae58bdf2021-06-17 17:18:45 +010068 return cpu::CpuGemmLowpOutputStage::validate(input, bias, output, info);
69}
Michele Di Giorgio9c700372020-01-08 11:33:44 +000070
Manuel Bottiniae58bdf2021-06-17 17:18:45 +010071void NEGEMMLowpOutputStage::run()
72{
73 _impl->op->run(_impl->run_pack);
Michele Di Giorgio9c700372020-01-08 11:33:44 +000074}
Gian Marco Iodicebc415af2019-06-13 15:58:32 +010075} // namespace arm_compute