15 #include <boost/test/unit_test.hpp> 22 template<armnn::DataType ArmnnTypeInput>
23 INetworkPtr CreateComparisonNetwork(
const std::vector<TensorShape>& inputShapes,
24 const TensorShape& outputShape,
26 const float qScale = 1.0f,
27 const int32_t qOffset = 0)
29 using namespace armnn;
34 IConnectableLayer* comparisonLayer = net->AddComparisonLayer(descriptor,
"comparison");
36 for (
unsigned int i = 0; i < inputShapes.size(); ++i)
38 TensorInfo inputTensorInfo(inputShapes[i], ArmnnTypeInput, qScale, qOffset);
39 IConnectableLayer* input = net->AddInputLayer(armnn::numeric_cast<LayerBindingId>(i));
40 Connect(input, comparisonLayer, inputTensorInfo, 0, i);
45 Connect(comparisonLayer, output, outputTensorInfo, 0, 0);
52 void ComparisonSimpleEndToEnd(
const std::vector<BackendId>& backends,
54 const std::vector<uint8_t> expectedOutput)
56 using namespace armnn;
58 const std::vector<TensorShape> inputShapes{{ 2, 2, 2, 2 }, { 2, 2, 2, 2 }};
62 INetworkPtr net = CreateComparisonNetwork<ArmnnInType>(inputShapes, outputShape, operation);
64 BOOST_TEST_CHECKPOINT(
"create a network");
66 const std::vector<TInput> input0({ 1, 1, 1, 1, 5, 5, 5, 5,
67 3, 3, 3, 3, 4, 4, 4, 4 });
69 const std::vector<TInput> input1({ 1, 1, 1, 1, 3, 3, 3, 3,
70 5, 5, 5, 5, 4, 4, 4, 4 });
72 std::map<int, std::vector<TInput>> inputTensorData = {{ 0, input0 }, { 1, input1 }};
73 std::map<int, std::vector<uint8_t>> expectedOutputData = {{ 0, expectedOutput }};
75 EndToEndLayerTestImpl<ArmnnInType, DataType::Boolean>(move(net), inputTensorData, expectedOutputData, backends);
80 void ComparisonBroadcastEndToEnd(
const std::vector<BackendId>& backends,
82 const std::vector<uint8_t> expectedOutput)
84 using namespace armnn;
86 const std::vector<TensorShape> inputShapes{{ 1, 2, 2, 3 }, { 1, 1, 1, 3 }};
90 INetworkPtr net = CreateComparisonNetwork<ArmnnInType>(inputShapes, outputShape, operation);
92 BOOST_TEST_CHECKPOINT(
"create a network");
94 const std::vector<TInput> input0({ 1, 2, 3, 1, 0, 6,
95 7, 8, 9, 10, 11, 12 });
97 const std::vector<TInput> input1({ 1, 1, 3 });
99 std::map<int, std::vector<TInput>> inputTensorData = {{ 0, input0 }, { 1, input1 }};
100 std::map<int, std::vector<uint8_t>> expectedOutputData = {{ 0, expectedOutput }};
102 EndToEndLayerTestImpl<ArmnnInType, DataType::Boolean>(move(net), inputTensorData, expectedOutputData, backends);
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
A ComparisonDescriptor for the ComparisonLayer.
typename ResolveTypeImpl< DT >::Type ResolveType
Copyright (c) 2020 ARM Limited.
void Connect(armnn::IConnectableLayer *from, armnn::IConnectableLayer *to, const armnn::TensorInfo &tensorInfo, unsigned int fromIndex, unsigned int toIndex)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
static INetworkPtr Create(NetworkOptions networkOptions={})