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