Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame^] | 2 | * Copyright (c) 2016-2020 Arm Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 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 | */ |
| 24 | #include "arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h" |
| 25 | |
Michalis Spyrou | 861f0db | 2018-02-26 16:47:58 +0000 | [diff] [blame] | 26 | #include "arm_compute/core/ITensor.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/NEON/kernels/NEPixelWiseMultiplicationKernel.h" |
Matthew Bentham | 758b5ba | 2020-03-05 23:37:48 +0000 | [diff] [blame] | 28 | #include "support/MemorySupport.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 29 | |
| 30 | #include <utility> |
| 31 | |
giuros01 | 154bc1c | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 32 | namespace arm_compute |
| 33 | { |
Michalis Spyrou | 6eb7345 | 2020-07-02 17:39:25 +0100 | [diff] [blame] | 34 | namespace experimental |
| 35 | { |
| 36 | void NEPixelWiseMultiplication::configure(ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 37 | const ActivationLayerInfo &act_info) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 38 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 39 | ARM_COMPUTE_UNUSED(act_info); |
Moritz Pflanzer | d0ae8b8 | 2017-06-29 14:51:57 +0100 | [diff] [blame] | 40 | auto k = arm_compute::support::cpp14::make_unique<NEPixelWiseMultiplicationKernel>(); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 41 | k->configure(input1, input2, output, scale, overflow_policy, rounding_policy); |
| 42 | _kernel = std::move(k); |
| 43 | } |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 44 | Status NEPixelWiseMultiplication::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, |
| 45 | const ActivationLayerInfo &act_info) |
Ioan-Cristian Szabo | 754e952 | 2017-11-28 18:29:43 +0000 | [diff] [blame] | 46 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 47 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled()); |
Ioan-Cristian Szabo | 754e952 | 2017-11-28 18:29:43 +0000 | [diff] [blame] | 48 | return NEPixelWiseMultiplicationKernel::validate(input1, input2, output, scale, overflow_policy, rounding_policy); |
| 49 | } |
giuros01 | 154bc1c | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 50 | |
Michalis Spyrou | 6eb7345 | 2020-07-02 17:39:25 +0100 | [diff] [blame] | 51 | MemoryRequirements NEPixelWiseMultiplication::workspace() const |
| 52 | { |
| 53 | return MemoryRequirements{}; |
| 54 | } |
| 55 | |
| 56 | void NEComplexPixelWiseMultiplication::configure(ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info) |
giuros01 | 154bc1c | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 57 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 58 | ARM_COMPUTE_UNUSED(act_info); |
giuros01 | 154bc1c | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 59 | auto k = arm_compute::support::cpp14::make_unique<NEComplexPixelWiseMultiplicationKernel>(); |
| 60 | k->configure(input1, input2, output); |
| 61 | _kernel = std::move(k); |
giuros01 | 154bc1c | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 62 | } |
| 63 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 64 | Status NEComplexPixelWiseMultiplication::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
giuros01 | 154bc1c | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 65 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 66 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled()); |
giuros01 | 154bc1c | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 67 | return NEComplexPixelWiseMultiplicationKernel::validate(input1, input2, output); |
| 68 | } |
| 69 | |
Michalis Spyrou | 6eb7345 | 2020-07-02 17:39:25 +0100 | [diff] [blame] | 70 | MemoryRequirements NEComplexPixelWiseMultiplication::workspace() const |
| 71 | { |
| 72 | return MemoryRequirements{}; |
| 73 | } |
| 74 | } // namespace experimental |
| 75 | |
| 76 | struct NEPixelWiseMultiplication::Impl |
| 77 | { |
| 78 | const ITensor *src_0{ nullptr }; |
| 79 | const ITensor *src_1{ nullptr }; |
| 80 | ITensor *dst{ nullptr }; |
| 81 | std::unique_ptr<experimental::NEPixelWiseMultiplication> op{ nullptr }; |
| 82 | }; |
| 83 | |
| 84 | NEPixelWiseMultiplication::NEPixelWiseMultiplication() |
| 85 | : _impl(support::cpp14::make_unique<Impl>()) |
| 86 | { |
| 87 | } |
| 88 | NEPixelWiseMultiplication::NEPixelWiseMultiplication(NEPixelWiseMultiplication &&) = default; |
| 89 | NEPixelWiseMultiplication &NEPixelWiseMultiplication::operator=(NEPixelWiseMultiplication &&) = default; |
| 90 | NEPixelWiseMultiplication::~NEPixelWiseMultiplication() = default; |
| 91 | |
| 92 | Status NEPixelWiseMultiplication::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, |
| 93 | const ActivationLayerInfo &act_info) |
| 94 | { |
| 95 | return experimental::NEPixelWiseMultiplication::validate(input1, input2, output, scale, overflow_policy, rounding_policy, act_info); |
| 96 | } |
| 97 | |
| 98 | void NEPixelWiseMultiplication::configure(const ITensor *input1, const ITensor *input2, ITensor *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, |
| 99 | const ActivationLayerInfo &act_info) |
| 100 | { |
| 101 | _impl->src_0 = input1; |
| 102 | _impl->src_1 = input2; |
| 103 | _impl->dst = output; |
| 104 | _impl->op = arm_compute::support::cpp14::make_unique<experimental::NEPixelWiseMultiplication>(); |
| 105 | _impl->op->configure(input1->info(), input2->info(), output->info(), scale, overflow_policy, rounding_policy, act_info); |
| 106 | } |
| 107 | |
| 108 | void NEPixelWiseMultiplication::run() |
| 109 | { |
| 110 | const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; |
| 111 | const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; |
| 112 | _impl->op->run(src, dst, {}); |
| 113 | } |
| 114 | |
| 115 | struct NEComplexPixelWiseMultiplication::Impl |
| 116 | { |
| 117 | ITensor *src_0{ nullptr }; |
| 118 | ITensor *src_1{ nullptr }; |
| 119 | ITensor *dst{ nullptr }; |
| 120 | std::unique_ptr<experimental::NEComplexPixelWiseMultiplication> op{ nullptr }; |
| 121 | }; |
| 122 | |
| 123 | NEComplexPixelWiseMultiplication::NEComplexPixelWiseMultiplication() |
| 124 | : _impl(support::cpp14::make_unique<Impl>()) |
| 125 | { |
| 126 | } |
| 127 | NEComplexPixelWiseMultiplication::NEComplexPixelWiseMultiplication(NEComplexPixelWiseMultiplication &&) = default; |
| 128 | NEComplexPixelWiseMultiplication &NEComplexPixelWiseMultiplication::operator=(NEComplexPixelWiseMultiplication &&) = default; |
| 129 | NEComplexPixelWiseMultiplication::~NEComplexPixelWiseMultiplication() = default; |
| 130 | |
| 131 | Status NEComplexPixelWiseMultiplication::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 132 | { |
| 133 | return experimental::NEComplexPixelWiseMultiplication::validate(input1, input2, output, act_info); |
| 134 | } |
| 135 | |
| 136 | void NEComplexPixelWiseMultiplication::configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info) |
| 137 | { |
| 138 | _impl->src_0 = input1; |
| 139 | _impl->src_1 = input2; |
| 140 | _impl->dst = output; |
| 141 | _impl->op = arm_compute::support::cpp14::make_unique<experimental::NEComplexPixelWiseMultiplication>(); |
| 142 | _impl->op->configure(input1->info(), input2->info(), output->info(), act_info); |
| 143 | } |
| 144 | |
| 145 | void NEComplexPixelWiseMultiplication::run() |
| 146 | { |
| 147 | const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; |
| 148 | const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; |
| 149 | _impl->op->run(src, dst, {}); |
| 150 | } |
giuros01 | 154bc1c | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 151 | } // namespace arm_compute |