Narumol Prangnawarat | 1a26896 | 2020-07-27 15:52:13 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #include <neon/NeonTensorHandle.hpp> |
| 6 | #include <neon/NeonTensorHandleFactory.hpp> |
| 7 | |
| 8 | #include <boost/test/unit_test.hpp> |
| 9 | |
| 10 | BOOST_AUTO_TEST_SUITE(NeonTensorHandleTests) |
| 11 | using namespace armnn; |
| 12 | |
| 13 | BOOST_AUTO_TEST_CASE(NeonTensorHandleGetCapabilitiesNoPadding) |
| 14 | { |
| 15 | std::shared_ptr<NeonMemoryManager> memoryManager = std::make_shared<NeonMemoryManager>(); |
| 16 | NeonTensorHandleFactory handleFactory(memoryManager); |
| 17 | |
| 18 | INetworkPtr network(INetwork::Create()); |
| 19 | |
| 20 | // Add the layers |
| 21 | IConnectableLayer* input = network->AddInputLayer(0); |
| 22 | SoftmaxDescriptor descriptor; |
| 23 | descriptor.m_Beta = 1.0f; |
| 24 | IConnectableLayer* softmax = network->AddSoftmaxLayer(descriptor); |
| 25 | IConnectableLayer* output = network->AddOutputLayer(2); |
| 26 | |
| 27 | // Establish connections |
| 28 | input->GetOutputSlot(0).Connect(softmax->GetInputSlot(0)); |
| 29 | softmax->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 30 | |
| 31 | // No padding required for input |
| 32 | std::vector<Capability> capabilities = handleFactory.GetCapabilities(input, |
| 33 | softmax, |
| 34 | CapabilityClass::PaddingRequired); |
| 35 | BOOST_TEST(capabilities.empty()); |
| 36 | |
| 37 | // No padding required for Softmax |
| 38 | capabilities = handleFactory.GetCapabilities(softmax, output, CapabilityClass::PaddingRequired); |
| 39 | BOOST_TEST(capabilities.empty()); |
| 40 | |
| 41 | // No padding required for output |
| 42 | capabilities = handleFactory.GetCapabilities(output, nullptr, CapabilityClass::PaddingRequired); |
| 43 | BOOST_TEST(capabilities.empty()); |
| 44 | } |
| 45 | |
| 46 | BOOST_AUTO_TEST_CASE(NeonTensorHandleGetCapabilitiesPadding) |
| 47 | { |
| 48 | std::shared_ptr<NeonMemoryManager> memoryManager = std::make_shared<NeonMemoryManager>(); |
| 49 | NeonTensorHandleFactory handleFactory(memoryManager); |
| 50 | |
| 51 | INetworkPtr network(INetwork::Create()); |
| 52 | |
| 53 | // Add the layers |
| 54 | IConnectableLayer* input = network->AddInputLayer(0); |
| 55 | Pooling2dDescriptor descriptor; |
| 56 | IConnectableLayer* pooling = network->AddPooling2dLayer(descriptor); |
| 57 | IConnectableLayer* output = network->AddOutputLayer(2); |
| 58 | |
| 59 | // Establish connections |
| 60 | input->GetOutputSlot(0).Connect(pooling->GetInputSlot(0)); |
| 61 | pooling->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 62 | |
| 63 | // No padding required for input |
| 64 | std::vector<Capability> capabilities = handleFactory.GetCapabilities(input, |
| 65 | pooling, |
| 66 | CapabilityClass::PaddingRequired); |
| 67 | BOOST_TEST(capabilities.empty()); |
| 68 | |
| 69 | // No padding required for output |
| 70 | capabilities = handleFactory.GetCapabilities(output, nullptr, CapabilityClass::PaddingRequired); |
| 71 | BOOST_TEST(capabilities.empty()); |
| 72 | |
| 73 | // Padding required for Pooling2d |
| 74 | capabilities = handleFactory.GetCapabilities(pooling, output, CapabilityClass::PaddingRequired); |
| 75 | BOOST_TEST(capabilities.size() == 1); |
| 76 | BOOST_TEST((capabilities[0].m_CapabilityClass == CapabilityClass::PaddingRequired)); |
| 77 | BOOST_TEST(capabilities[0].m_Value); |
| 78 | } |
| 79 | |
| 80 | BOOST_AUTO_TEST_SUITE_END() |