aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/test/TestLayerVisitor.cpp
blob: 932aef6deb806b44b6ad7171b131e491ed862f6c (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
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include <boost/test/unit_test.hpp>
#include "TestLayerVisitor.hpp"

namespace armnn
{

void TestLayerVisitor::CheckLayerName(const char* name)
{
    if (name == nullptr)
    {
        BOOST_CHECK(m_LayerName == nullptr);
    }
    else if (m_LayerName == nullptr)
    {
        BOOST_CHECK(name == nullptr);
    }
    else
    {
        BOOST_CHECK_EQUAL(m_LayerName, name);
    }
};

void TestLayerVisitor::CheckLayerPointer(const IConnectableLayer* layer)
{
    BOOST_CHECK(layer != nullptr);
}

void TestLayerVisitor::CheckConstTensors(const ConstTensor& expected, const ConstTensor& actual)
{
    BOOST_CHECK(expected.GetInfo() == actual.GetInfo());
    BOOST_CHECK(expected.GetNumDimensions() == actual.GetNumDimensions());
    BOOST_CHECK(expected.GetNumElements() == actual.GetNumElements());
    BOOST_CHECK(expected.GetNumBytes() == actual.GetNumBytes());
    if (expected.GetNumBytes() == actual.GetNumBytes())
    {
        //check data is the same byte by byte
        const unsigned char* expectedPtr = static_cast<const unsigned char*>(expected.GetMemoryArea());
        const unsigned char* actualPtr = static_cast<const unsigned char*>(actual.GetMemoryArea());
        for (unsigned int i = 0; i < expected.GetNumBytes(); i++)
        {
            BOOST_CHECK(*(expectedPtr + i) == *(actualPtr + i));
        }
    }
}

} //namespace armnn