aboutsummaryrefslogtreecommitdiff
path: root/src/backends/aclCommon/test/MemCopyTests.cpp
blob: 7e503b1cdb75a2b75db03188e4cc9c13a60b28bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include <backends/aclCommon/ArmComputeTensorUtils.hpp>
#include <backends/cl/ClWorkloadFactory.hpp>
#include <backends/neon/NeonWorkloadFactory.hpp>

#if ARMCOMPUTECL_ENABLED && ARMCOMPUTENEON_ENABLED
#include <backends/aclCommon/test/MemCopyTestImpl.hpp>
#endif

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(MemCopyTestSuite)

BOOST_AUTO_TEST_CASE(AclTypeConversions)
{
    arm_compute::Strides strides(1, 2, 3, 4);
    armnn::TensorShape convertedStrides = armnn::armcomputetensorutils::GetStrides(strides);

    BOOST_TEST(convertedStrides[0] == 4);
    BOOST_TEST(convertedStrides[1] == 3);
    BOOST_TEST(convertedStrides[2] == 2);
    BOOST_TEST(convertedStrides[3] == 1);

    arm_compute::TensorShape shape(5, 6, 7, 8);
    armnn::TensorShape convertedshape = armnn::armcomputetensorutils::GetShape(shape);

    BOOST_TEST(convertedshape[0] == 8);
    BOOST_TEST(convertedshape[1] == 7);
    BOOST_TEST(convertedshape[2] == 6);
    BOOST_TEST(convertedshape[3] == 5);
}

#if ARMCOMPUTECL_ENABLED && ARMCOMPUTENEON_ENABLED

BOOST_AUTO_TEST_CASE(CopyBetweenNeonAndGpu)
{
    LayerTestResult<float, 4> result = MemCopyTest<armnn::NeonWorkloadFactory, armnn::ClWorkloadFactory>(false);
    BOOST_TEST(CompareTensors(result.output, result.outputExpected));
}

BOOST_AUTO_TEST_CASE(CopyBetweenGpuAndNeon)
{
    LayerTestResult<float, 4> result = MemCopyTest<armnn::ClWorkloadFactory, armnn::NeonWorkloadFactory>(false);
    BOOST_TEST(CompareTensors(result.output, result.outputExpected));
}

BOOST_AUTO_TEST_CASE(CopyBetweenNeonAndGpuWithSubtensors)
{
    LayerTestResult<float, 4> result = MemCopyTest<armnn::NeonWorkloadFactory, armnn::ClWorkloadFactory>(true);
    BOOST_TEST(CompareTensors(result.output, result.outputExpected));
}

BOOST_AUTO_TEST_CASE(CopyBetweenGpuAndNeonWithSubtensors)
{
    LayerTestResult<float, 4> result = MemCopyTest<armnn::ClWorkloadFactory, armnn::NeonWorkloadFactory>(true);
    BOOST_TEST(CompareTensors(result.output, result.outputExpected));
}

#endif

BOOST_AUTO_TEST_SUITE_END()