ArmNN
 21.02
MemCopyTests.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
8 
9 #if defined(ARMCOMPUTECL_ENABLED) && defined(ARMCOMPUTENEON_ENABLED)
10 #include <cl/ClWorkloadFactory.hpp>
13 
16 #endif
17 
18 #include <boost/test/unit_test.hpp>
19 
20 BOOST_AUTO_TEST_SUITE(MemCopyCommon)
21 
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 
42 
43 #if defined(ARMCOMPUTECL_ENABLED) && defined(ARMCOMPUTENEON_ENABLED)
44 
45 BOOST_FIXTURE_TEST_SUITE(MemCopyClNeon, ClContextControlFixture)
46 
47 BOOST_AUTO_TEST_CASE(CopyBetweenNeonAndGpu)
48 {
50  MemCopyTest<armnn::NeonWorkloadFactory, armnn::ClWorkloadFactory, armnn::DataType::Float32>(false);
51  BOOST_TEST(CompareTensors(result.output, result.outputExpected));
52 }
53 
54 BOOST_AUTO_TEST_CASE(CopyBetweenGpuAndNeon)
55 {
57  MemCopyTest<armnn::ClWorkloadFactory, armnn::NeonWorkloadFactory, armnn::DataType::Float32>(false);
58  BOOST_TEST(CompareTensors(result.output, result.outputExpected));
59 }
60 
61 BOOST_AUTO_TEST_CASE(CopyBetweenNeonAndGpuWithSubtensors)
62 {
64  MemCopyTest<armnn::NeonWorkloadFactory, armnn::ClWorkloadFactory, armnn::DataType::Float32>(true);
65  BOOST_TEST(CompareTensors(result.output, result.outputExpected));
66 }
67 
68 BOOST_AUTO_TEST_CASE(CopyBetweenGpuAndNeonWithSubtensors)
69 {
71  MemCopyTest<armnn::ClWorkloadFactory, armnn::NeonWorkloadFactory, armnn::DataType::Float32>(true);
72  BOOST_TEST(CompareTensors(result.output, result.outputExpected));
73 }
74 
76 
77 #endif
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
boost::test_tools::predicate_result CompareTensors(const boost::multi_array< T, n > &a, const boost::multi_array< T, n > &b, bool compareBoolean=false, bool isDynamic=false)
boost::multi_array< T, n > outputExpected
boost::multi_array< T, n > output
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(AclTypeConversions)