Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "MinimumTestImpl.hpp" |
| 7 | |
| 8 | #include "ElementwiseTestImpl.hpp" |
| 9 | |
| 10 | template<> |
| 11 | std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::MinimumQueueDescriptor>( |
| 12 | const armnn::IWorkloadFactory& workloadFactory, |
| 13 | const armnn::WorkloadInfo& info, |
| 14 | const armnn::MinimumQueueDescriptor& descriptor) |
| 15 | { |
| 16 | return workloadFactory.CreateMinimum(descriptor, info); |
| 17 | } |
| 18 | |
| 19 | LayerTestResult<float, 4> MinimumBroadcast1ElementTest1( |
| 20 | armnn::IWorkloadFactory& workloadFactory, |
| 21 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 22 | { |
| 23 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 24 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 25 | |
| 26 | std::vector<float> input0 = { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f }; |
| 27 | |
| 28 | std::vector<float> input1 = { 2.f }; |
| 29 | |
| 30 | std::vector<float> output = { 1.f, 2.f, 2.f, 2.f, 2.f, 2.f, 2.f, 2.f }; |
| 31 | |
| 32 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float32>( |
| 33 | workloadFactory, |
| 34 | memoryManager, |
| 35 | shape0, |
| 36 | input0, |
| 37 | shape1, |
| 38 | input1, |
| 39 | shape0, |
| 40 | output); |
| 41 | } |
| 42 | |
| 43 | LayerTestResult<float, 4> MinimumBroadcast1ElementTest2( |
| 44 | armnn::IWorkloadFactory& workloadFactory, |
| 45 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 46 | { |
| 47 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 48 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 49 | |
| 50 | std::vector<float> input0 = { 1.f, 6.f, 3.f, 2.f, 8.f, 9.f, 1.f, 10.f }; |
| 51 | |
| 52 | std::vector<float> input1 = { 5.f }; |
| 53 | |
| 54 | std::vector<float> output = { 1.f, 5.f, 3.f, 2.f, 5.f, 5.f, 1.f, 5.f }; |
| 55 | |
| 56 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float32>( |
| 57 | workloadFactory, |
| 58 | memoryManager, |
| 59 | shape0, |
| 60 | input0, |
| 61 | shape1, |
| 62 | input1, |
| 63 | shape0, |
| 64 | output); |
| 65 | } |
| 66 | |
| 67 | LayerTestResult<uint8_t, 4> MinimumBroadcast1DVectorUint8Test( |
| 68 | armnn::IWorkloadFactory & workloadFactory, |
| 69 | const armnn::IBackendInternal::IMemoryManagerSharedPtr & memoryManager) |
| 70 | { |
| 71 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 72 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 73 | |
| 74 | std::vector<uint8_t> input0 = |
| 75 | { |
| 76 | 1, 2, 3, 3, 2, 1, |
| 77 | 7, 1, 2, 3, 4, 5 |
| 78 | }; |
| 79 | |
| 80 | std::vector<uint8_t> input1 = { 1, 2, 3 }; |
| 81 | |
| 82 | std::vector<uint8_t> output = |
| 83 | { |
| 84 | 1, 2, 3, 1, 2, 1, |
| 85 | 1, 1, 2, 1, 2, 3 |
| 86 | }; |
| 87 | |
| 88 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QuantisedAsymm8>( |
| 89 | workloadFactory, |
| 90 | memoryManager, |
| 91 | shape0, |
| 92 | input0, |
| 93 | shape1, |
| 94 | input1, |
| 95 | shape0, |
| 96 | output); |
| 97 | } |
| 98 | |
| 99 | LayerTestResult<int16_t, 4> MinimumInt16Test( |
| 100 | armnn::IWorkloadFactory& workloadFactory, |
| 101 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 102 | { |
| 103 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 104 | |
| 105 | std::vector<int16_t> input0 = |
| 106 | { |
| 107 | 1, 1, 1, 1, 6, 6, 6, 6, |
| 108 | 3, 3, 3, 3, 4, 4, 4, 4 |
| 109 | }; |
| 110 | |
| 111 | std::vector<int16_t> input1 = |
| 112 | { |
| 113 | 2, 2, 2, 2, 3, 3, 3, 3, |
| 114 | 4, 4, 4, 4, 5, 5, 5, 5 |
| 115 | }; |
| 116 | |
| 117 | std::vector<int16_t> output |
| 118 | { |
| 119 | 1, 1, 1, 1, 3, 3, 3, 3, |
| 120 | 3, 3, 3, 3, 4, 4, 4, 4 |
| 121 | }; |
| 122 | |
| 123 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QuantisedSymm16>( |
| 124 | workloadFactory, |
| 125 | memoryManager, |
| 126 | shape, |
| 127 | input0, |
| 128 | shape, |
| 129 | input1, |
| 130 | shape, |
| 131 | output); |
| 132 | } |
| 133 | |
| 134 | LayerTestResult<int16_t, 4> MinimumBroadcast1ElementInt16Test( |
| 135 | armnn::IWorkloadFactory& workloadFactory, |
| 136 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 137 | { |
| 138 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 139 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 140 | |
| 141 | std::vector<int16_t> input0 = |
| 142 | { |
| 143 | 1, 2, 3, 4, 5, 6, |
| 144 | 7, 8, 9, 10, 11, 12 |
| 145 | }; |
| 146 | |
| 147 | std::vector<int16_t> input1 = { 2 }; |
| 148 | |
| 149 | std::vector<int16_t> output = |
| 150 | { |
| 151 | 1, 2, 2, 2, 2, 2, |
| 152 | 2, 2, 2, 2, 2, 2 |
| 153 | }; |
| 154 | |
| 155 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QuantisedSymm16>( |
| 156 | workloadFactory, |
| 157 | memoryManager, |
| 158 | shape0, |
| 159 | input0, |
| 160 | shape1, |
| 161 | input1, |
| 162 | shape0, |
| 163 | output); |
| 164 | } |
| 165 | |
| 166 | LayerTestResult<int16_t, 4> MinimumBroadcast1DVectorInt16Test( |
| 167 | armnn::IWorkloadFactory& workloadFactory, |
| 168 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 169 | { |
| 170 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 171 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 172 | |
| 173 | std::vector<int16_t> input0 = |
| 174 | { |
| 175 | 1, 2, 3, 4, 5, 6, |
| 176 | 7, 8, 9, 10, 11, 12 |
| 177 | }; |
| 178 | |
| 179 | std::vector<int16_t> input1 = { 1, 10, 3 }; |
| 180 | |
| 181 | std::vector<int16_t> output = |
| 182 | { |
| 183 | 1, 2, 3, 1, 5, 3, |
| 184 | 1, 8, 3, 1, 10, 3 |
| 185 | }; |
| 186 | |
| 187 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QuantisedSymm16>( |
| 188 | workloadFactory, |
| 189 | memoryManager, |
| 190 | shape0, |
| 191 | input0, |
| 192 | shape1, |
| 193 | input1, |
| 194 | shape0, |
| 195 | output); |
| 196 | } |