1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include <armnn/Descriptors.hpp>
7 #include <armnn/IRuntime.hpp>
8 #include <armnn/INetwork.hpp>
9 #include <armnn/utility/IgnoreUnused.hpp>
10
11 #include <boost/test/unit_test.hpp>
12
13 #include <set>
14
15 BOOST_AUTO_TEST_SUITE(EndToEnd)
16
BOOST_AUTO_TEST_CASE(ErrorOnLoadNetwork)17 BOOST_AUTO_TEST_CASE(ErrorOnLoadNetwork)
18 {
19 using namespace armnn;
20
21 // Create runtime in which test will run
22 // Note we don't allow falling back to CpuRef if an operation (excluding inputs, outputs, etc.) isn't supported
23 IRuntime::CreationOptions options;
24 IRuntimePtr runtime(IRuntime::Create(options));
25
26 // build up the structure of the network
27 INetworkPtr net(INetwork::Create());
28
29 IConnectableLayer* input = net->AddInputLayer(0);
30
31 // This layer configuration isn't supported by CpuAcc and isn't allowed to fall back, so Optimize will return null.
32 NormalizationDescriptor descriptor;
33 IConnectableLayer* pooling = net->AddNormalizationLayer(descriptor);
34
35 IConnectableLayer* output = net->AddOutputLayer(0);
36
37 input->GetOutputSlot(0).Connect(pooling->GetInputSlot(0));
38 pooling->GetOutputSlot(0).Connect(output->GetInputSlot(0));
39
40 input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32));
41 pooling->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32));
42
43 // optimize the network
44 std::vector<BackendId> backends = {Compute::CpuAcc};
45 std::vector<std::string> errMessages;
46
47 try
48 {
49 Optimize(*net, backends, runtime->GetDeviceSpec(), OptimizerOptions(), errMessages);
50 BOOST_FAIL("Should have thrown an exception.");
51 }
52 catch (const InvalidArgumentException& e)
53 {
54 // Different exceptions are thrown on different backends
55 }
56 BOOST_CHECK(errMessages.size() > 0);
57 }
58
59 BOOST_AUTO_TEST_SUITE_END()
60