• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include <aclCommon/ArmComputeTensorUtils.hpp>
7 #include <aclCommon/test/MemCopyTestImpl.hpp>
8 
9 #if defined(ARMCOMPUTECL_ENABLED) && defined(ARMCOMPUTENEON_ENABLED)
10 #include <cl/ClWorkloadFactory.hpp>
11 #include <cl/test/ClContextControlFixture.hpp>
12 #include <cl/test/ClWorkloadFactoryHelper.hpp>
13 
14 #include <neon/NeonWorkloadFactory.hpp>
15 #include <neon/test/NeonWorkloadFactoryHelper.hpp>
16 #endif
17 
18 #include <boost/test/unit_test.hpp>
19 
20 BOOST_AUTO_TEST_SUITE(MemCopyCommon)
21 
BOOST_AUTO_TEST_CASE(AclTypeConversions)22 BOOST_AUTO_TEST_CASE(AclTypeConversions)
23 {
24     arm_compute::Strides strides(1, 2, 3, 4);
25     armnn::TensorShape convertedStrides = armnn::armcomputetensorutils::GetStrides(strides);
26 
27     BOOST_TEST(convertedStrides[0] == 4);
28     BOOST_TEST(convertedStrides[1] == 3);
29     BOOST_TEST(convertedStrides[2] == 2);
30     BOOST_TEST(convertedStrides[3] == 1);
31 
32     arm_compute::TensorShape shape(5, 6, 7, 8);
33     armnn::TensorShape convertedshape = armnn::armcomputetensorutils::GetShape(shape);
34 
35     BOOST_TEST(convertedshape[0] == 8);
36     BOOST_TEST(convertedshape[1] == 7);
37     BOOST_TEST(convertedshape[2] == 6);
38     BOOST_TEST(convertedshape[3] == 5);
39 }
40 
41 BOOST_AUTO_TEST_SUITE_END()
42 
43 #if defined(ARMCOMPUTECL_ENABLED) && defined(ARMCOMPUTENEON_ENABLED)
44 
BOOST_FIXTURE_TEST_SUITE(MemCopyClNeon,ClContextControlFixture)45 BOOST_FIXTURE_TEST_SUITE(MemCopyClNeon, ClContextControlFixture)
46 
47 BOOST_AUTO_TEST_CASE(CopyBetweenNeonAndGpu)
48 {
49     LayerTestResult<float, 4> result =
50         MemCopyTest<armnn::NeonWorkloadFactory, armnn::ClWorkloadFactory, armnn::DataType::Float32>(false);
51     BOOST_TEST(CompareTensors(result.output, result.outputExpected));
52 }
53 
BOOST_AUTO_TEST_CASE(CopyBetweenGpuAndNeon)54 BOOST_AUTO_TEST_CASE(CopyBetweenGpuAndNeon)
55 {
56     LayerTestResult<float, 4> result =
57         MemCopyTest<armnn::ClWorkloadFactory, armnn::NeonWorkloadFactory, armnn::DataType::Float32>(false);
58     BOOST_TEST(CompareTensors(result.output, result.outputExpected));
59 }
60 
BOOST_AUTO_TEST_CASE(CopyBetweenNeonAndGpuWithSubtensors)61 BOOST_AUTO_TEST_CASE(CopyBetweenNeonAndGpuWithSubtensors)
62 {
63     LayerTestResult<float, 4> result =
64         MemCopyTest<armnn::NeonWorkloadFactory, armnn::ClWorkloadFactory, armnn::DataType::Float32>(true);
65     BOOST_TEST(CompareTensors(result.output, result.outputExpected));
66 }
67 
BOOST_AUTO_TEST_CASE(CopyBetweenGpuAndNeonWithSubtensors)68 BOOST_AUTO_TEST_CASE(CopyBetweenGpuAndNeonWithSubtensors)
69 {
70     LayerTestResult<float, 4> result =
71         MemCopyTest<armnn::ClWorkloadFactory, armnn::NeonWorkloadFactory, armnn::DataType::Float32>(true);
72     BOOST_TEST(CompareTensors(result.output, result.outputExpected));
73 }
74 
75 BOOST_AUTO_TEST_SUITE_END()
76 
77 #endif
78