David Beck | 279f872 | 2018-09-12 13:50:03 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include <armnn/Types.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 9 | #include <backendsCommon/Workload.hpp> |
| 10 | #include <backendsCommon/WorkloadData.hpp> |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 11 | #include "BaseIterator.hpp" |
| 12 | #include "ElementwiseFunction.hpp" |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 13 | #include "Maximum.hpp" |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 14 | #include "Minimum.hpp" |
ruoyan01 | f9426b3 | 2019-01-03 15:10:00 +0000 | [diff] [blame] | 15 | #include "StringMapping.hpp" |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 16 | |
David Beck | 279f872 | 2018-09-12 13:50:03 +0100 | [diff] [blame] | 17 | namespace armnn |
| 18 | { |
| 19 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 20 | template <typename Functor, typename ParentDescriptor, typename armnn::StringMapping::Id DebugString> |
| 21 | class RefElementwiseWorkload : public BaseWorkload<ParentDescriptor> |
David Beck | 279f872 | 2018-09-12 13:50:03 +0100 | [diff] [blame] | 22 | { |
| 23 | public: |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 24 | using InType = typename ElementwiseFunction<Functor>::InType; |
| 25 | using OutType = typename ElementwiseFunction<Functor>::OutType; |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 26 | using BaseWorkload<ParentDescriptor>::m_Data; |
David Beck | 279f872 | 2018-09-12 13:50:03 +0100 | [diff] [blame] | 27 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 28 | RefElementwiseWorkload(const ParentDescriptor& descriptor, const WorkloadInfo& info); |
| 29 | void PostAllocationConfigure() override; |
Sadik Armagan | ef38d5d | 2019-03-25 09:03:35 +0000 | [diff] [blame] | 30 | void Execute() const override; |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 31 | |
| 32 | private: |
| 33 | std::unique_ptr<Decoder<InType>> m_Input0; |
| 34 | std::unique_ptr<Decoder<InType>> m_Input1; |
| 35 | std::unique_ptr<Encoder<OutType>> m_Output; |
David Beck | 279f872 | 2018-09-12 13:50:03 +0100 | [diff] [blame] | 36 | }; |
| 37 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 38 | using RefAdditionWorkload = |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 39 | RefElementwiseWorkload<std::plus<float>, |
David Beck | 279f872 | 2018-09-12 13:50:03 +0100 | [diff] [blame] | 40 | AdditionQueueDescriptor, |
| 41 | StringMapping::RefAdditionWorkload_Execute>; |
| 42 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 43 | using RefSubtractionWorkload = |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 44 | RefElementwiseWorkload<std::minus<float>, |
David Beck | 279f872 | 2018-09-12 13:50:03 +0100 | [diff] [blame] | 45 | SubtractionQueueDescriptor, |
| 46 | StringMapping::RefSubtractionWorkload_Execute>; |
| 47 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 48 | using RefMultiplicationWorkload = |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 49 | RefElementwiseWorkload<std::multiplies<float>, |
David Beck | 279f872 | 2018-09-12 13:50:03 +0100 | [diff] [blame] | 50 | MultiplicationQueueDescriptor, |
| 51 | StringMapping::RefMultiplicationWorkload_Execute>; |
| 52 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 53 | using RefDivisionWorkload = |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 54 | RefElementwiseWorkload<std::divides<float>, |
David Beck | 279f872 | 2018-09-12 13:50:03 +0100 | [diff] [blame] | 55 | DivisionQueueDescriptor, |
| 56 | StringMapping::RefDivisionWorkload_Execute>; |
| 57 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 58 | using RefMaximumWorkload = |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 59 | RefElementwiseWorkload<armnn::maximum<float>, |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 60 | MaximumQueueDescriptor, |
| 61 | StringMapping::RefMaximumWorkload_Execute>; |
| 62 | |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 63 | using RefMinimumWorkload = |
| 64 | RefElementwiseWorkload<armnn::minimum<float>, |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 65 | MinimumQueueDescriptor, |
| 66 | StringMapping::RefMinimumWorkload_Execute>; |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 67 | |
David Beck | 279f872 | 2018-09-12 13:50:03 +0100 | [diff] [blame] | 68 | } // armnn |