• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "../NeonWorkloadFactory.hpp"
7 #include <neon/NeonBackend.hpp>
8 #include <armnnTestUtils/LayerTestResult.hpp>
9 #include <armnnTestUtils/MemCopyTestImpl.hpp>
10 #include <armnnTestUtils/MockBackend.hpp>
11 #include <doctest/doctest.h>
12 
13 namespace
14 {
15 
16 template <>
17 struct MemCopyTestHelper<armnn::NeonWorkloadFactory>
18 {
GetMemoryManager__anon9af2ca7e0111::MemCopyTestHelper19     static armnn::IBackendInternal::IMemoryManagerSharedPtr GetMemoryManager()
20     {
21         armnn::NeonBackend backend;
22         return backend.CreateMemoryManager();
23     }
24 
GetFactory__anon9af2ca7e0111::MemCopyTestHelper25     static armnn::NeonWorkloadFactory GetFactory(
26         const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
27         const armnn::ModelOptions& modelOptions = {})
28     {
29         armnn::NeonBackend backend;
30         return armnn::NeonWorkloadFactory(armnn::PolymorphicPointerDowncast<armnn::NeonMemoryManager>(memoryManager),
31                                           backend.CreateBackendSpecificModelContext(modelOptions));
32     }
33 };
34 }    // namespace
35 
36 
37 TEST_SUITE("NeonMemCopy")
38 {
39 TEST_CASE("CopyBetweenCpuAndNeon")
40 {
41     LayerTestResult<float, 4> result =
42         MemCopyTest<armnn::MockWorkloadFactory, armnn::NeonWorkloadFactory, armnn::DataType::Float32>(false);
43     auto predResult = CompareTensors(result.m_ActualData,  result.m_ExpectedData,
44                                      result.m_ActualShape, result.m_ExpectedShape);
45     CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str());
46 }
47 
48 TEST_CASE("CopyBetweenNeonAndCpu")
49 {
50     LayerTestResult<float, 4> result =
51         MemCopyTest<armnn::NeonWorkloadFactory, armnn::MockWorkloadFactory, armnn::DataType::Float32>(false);
52     auto predResult = CompareTensors(result.m_ActualData,  result.m_ExpectedData,
53                                      result.m_ActualShape, result.m_ExpectedShape);
54     CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str());
55 }
56 
57 TEST_CASE("CopyBetweenCpuAndNeonWithSubtensors")
58 {
59     LayerTestResult<float, 4> result =
60         MemCopyTest<armnn::MockWorkloadFactory, armnn::NeonWorkloadFactory, armnn::DataType::Float32>(true);
61     auto predResult = CompareTensors(result.m_ActualData,  result.m_ExpectedData,
62                                      result.m_ActualShape, result.m_ExpectedShape);
63     CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str());
64 }
65 
66 TEST_CASE("CopyBetweenNeonAndCpuWithSubtensors")
67 {
68     LayerTestResult<float, 4> result =
69         MemCopyTest<armnn::NeonWorkloadFactory, armnn::MockWorkloadFactory, armnn::DataType::Float32>(true);
70     auto predResult = CompareTensors(result.m_ActualData,  result.m_ExpectedData,
71                                      result.m_ActualShape, result.m_ExpectedShape);
72     CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str());
73 }
74 
75 }
76