10 #include <boost/test/unit_test.hpp> 16 using namespace armnn;
80 std::string ignoredErrorMessage;
82 runtime->LoadNetwork(netId, std::move(optNet), ignoredErrorMessage, networkProperties);
85 std::vector<float> inputValue0
87 1.0f, 1.0f, 2.0f, 2.0f, 2.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 6.0f, 1.0f, 1.0f, 2.0f, 2.0f
89 std::vector<float> inputValue1
91 0.0f, 1.0f, 1.0f, 2.0f, 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 0.0f, 1.0f, 1.0f, 2.0f
93 std::vector<float> inputData2
95 12.0f, 11.0f, 10.0f, 9.0f, 8.0f, 7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f, 12.0f, 11.0f, 10.0f, 9.0f
98 std::vector<float> outputData(16);
100 std::vector<float> expectedOutput
102 11.0f, 9.0f, 7.0f, 5.0f, 3.0f, 1.0f, -1.0f, -3.0f, -5.0f, -7.0f, -9.0f, -11.0f, 11.0f, 9.0f, 7.0f, 5.0f
107 size_t totalBytes = numElements *
sizeof(float);
108 const size_t alignment = 64;
109 size_t space = totalBytes + alignment + alignment;
110 auto inputData0 = std::make_unique<uint8_t[]>(space);
111 void* alignedInputPtr0 = inputData0.get();
112 BOOST_CHECK(std::align(alignment, totalBytes, alignedInputPtr0, space));
114 auto* intputPtr0 =
reinterpret_cast<float*
>(alignedInputPtr0);
115 std::copy(inputValue0.begin(), inputValue0.end(), intputPtr0);
117 auto inputData1 = std::make_unique<uint8_t[]>(space);
118 void* alignedInputPtr1 = inputData1.get();
119 BOOST_CHECK(std::align(alignment, totalBytes, alignedInputPtr1, space));
121 auto* intputPtr1 =
reinterpret_cast<float*
>(alignedInputPtr1);
122 std::copy(inputValue1.begin(), inputValue1.end(), intputPtr1);
132 { 0,
armnn::Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data()) }
135 runtime->GetProfiler(netId)->EnableProfiling(
true);
138 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
142 std::stringstream ss;
144 std::string dump = ss.str();
147 std::size_t found = dump.find(
"NeonSubtractionWorkload_Execute");
148 BOOST_TEST(found != std::string::npos);
151 found = dump.find(
"CopyMemGeneric");
152 BOOST_TEST(found != std::string::npos);
155 BOOST_TEST(outputData == expectedOutput);
157 runtime->UnloadNetwork(netId);
162 using namespace armnn;
210 BOOST_TEST(
CheckOrder(graph, layer0, layer1));
211 BOOST_TEST(
CheckOrder(graph, layer1, layer2));
212 BOOST_TEST(
CheckOrder(graph, layer2, layer3));
213 BOOST_TEST(
CheckOrder(graph, layer3, layer4));
214 BOOST_TEST(
CheckOrder(graph, layer4, layer5));
215 BOOST_TEST(
CheckOrder(graph, layer5, layer6));
225 runtime->LoadNetwork(netId, std::move(optNet));
228 std::vector<float> inputData0
230 1.0f, 1.0f, 2.0f, 2.0f, 2.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 6.0f
232 std::vector<float> inputData1
234 0.0f, 1.0f, 1.0f, 2.0f, 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f
236 std::vector<float> inputData2
238 12.0f, 11.0f, 10.0f, 9.0f, 8.0f, 7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f
241 std::vector<float> outputData(12);
243 std::vector<float> expectedOutput
245 11.0f, 9.0f, 7.0f, 5.0f, 3.0f, 1.0f, -1.0f, -3.0f, -5.0f, -7.0f, -9.0f, -11.0f
256 { 0,
armnn::Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data()) }
259 runtime->GetProfiler(netId)->EnableProfiling(
true);
262 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
266 std::stringstream ss;
268 std::string dump = ss.str();
271 std::size_t found = dump.find(
"NeonSubtractionWorkload_Execute");
272 BOOST_TEST(found != std::string::npos);
275 found = dump.find(
"CopyMemGeneric");
276 BOOST_TEST(found != std::string::npos);
279 BOOST_TEST(outputData == expectedOutput);
284 using namespace armnn;
345 BOOST_TEST(
CheckOrder(graph, layer0, layer1));
346 BOOST_TEST(
CheckOrder(graph, layer1, layer2));
347 BOOST_TEST(
CheckOrder(graph, layer2, layer3));
348 BOOST_TEST(
CheckOrder(graph, layer3, layer4));
349 BOOST_TEST(
CheckOrder(graph, layer4, layer5));
350 BOOST_TEST(
CheckOrder(graph, layer5, layer6));
351 BOOST_TEST(
CheckOrder(graph, layer6, layer7));
352 BOOST_TEST(
CheckOrder(graph, layer7, layer8));
363 std::string ignoredErrorMessage;
365 runtime->LoadNetwork(netId, std::move(optNet), ignoredErrorMessage, networkProperties);
368 std::vector<float> inputValue0
370 1.0f, 1.0f, 2.0f, 2.0f, 2.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 6.0f, 1.0f, 1.0f, 2.0f, 2.0f
372 std::vector<float> inputValue1
374 0.0f, 1.0f, 1.0f, 2.0f, 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 0.0f, 1.0f, 1.0f, 2.0f
376 std::vector<float> inputData2
378 12.0f, 11.0f, 10.0f, 9.0f, 8.0f, 7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f, 12.0f, 11.0f, 10.0f, 9.0f
381 std::vector<float> outputData(4);
383 std::vector<float> expectedOutput{ 11.0f, 3.0f, -5.0f, 11.0f };
386 size_t totalBytes = numElements *
sizeof(float);
387 const size_t alignment = 64;
388 size_t space = totalBytes + alignment + alignment;
389 auto inputData0 = std::make_unique<uint8_t[]>(space);
390 void* alignedInputPtr0 = inputData0.get();
391 BOOST_CHECK(std::align(alignment, totalBytes, alignedInputPtr0, space));
393 auto* intputPtr0 =
reinterpret_cast<float*
>(alignedInputPtr0);
394 std::copy(inputValue0.begin(), inputValue0.end(), intputPtr0);
396 auto inputData1 = std::make_unique<uint8_t[]>(space);
397 void* alignedInputPtr1 = inputData1.get();
398 BOOST_CHECK(std::align(alignment, totalBytes, alignedInputPtr1, space));
400 auto* intputPtr1 =
reinterpret_cast<float*
>(alignedInputPtr1);
401 std::copy(inputValue1.begin(), inputValue1.end(), intputPtr1);
411 { 0,
armnn::Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data()) }
414 runtime->GetProfiler(netId)->EnableProfiling(
true);
417 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
421 std::stringstream ss;
423 std::string dump = ss.str();
426 std::size_t found = dump.find(
"NeonSubtractionWorkload_Execute");
427 BOOST_TEST(found != std::string::npos);
430 found = dump.find(
"ClPooling2dWorkload_Execute");
431 BOOST_TEST(found != std::string::npos);
434 found = dump.find(
"CopyMemGeneric");
435 BOOST_TEST(found != std::string::npos);
438 BOOST_TEST(outputData == expectedOutput);
440 runtime->UnloadNetwork(netId);
445 using namespace armnn;
501 BOOST_TEST(
CheckOrder(graph, layer0, layer1));
502 BOOST_TEST(
CheckOrder(graph, layer1, layer2));
503 BOOST_TEST(
CheckOrder(graph, layer2, layer3));
504 BOOST_TEST(
CheckOrder(graph, layer3, layer4));
505 BOOST_TEST(
CheckOrder(graph, layer4, layer5));
506 BOOST_TEST(
CheckOrder(graph, layer5, layer6));
507 BOOST_TEST(
CheckOrder(graph, layer6, layer7));
508 BOOST_TEST(
CheckOrder(graph, layer7, layer8));
519 runtime->LoadNetwork(netId, std::move(optNet));
522 std::vector<float> inputData0
524 1.0f, 1.0f, 2.0f, 2.0f, 2.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 6.0f
526 std::vector<float> inputData1
528 0.0f, 1.0f, 1.0f, 2.0f, 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f
530 std::vector<float> inputData2
532 12.0f, 11.0f, 10.0f, 9.0f, 8.0f, 7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f
535 std::vector<float> outputData(2);
537 std::vector<float> expectedOutput{ 11.0f, -1.0f };
547 { 0,
armnn::Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data()) }
550 runtime->GetProfiler(netId)->EnableProfiling(
true);
553 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
557 std::stringstream ss;
559 std::string dump = ss.str();
562 std::size_t found = dump.find(
"NeonSubtractionWorkload_Execute");
563 BOOST_TEST(found != std::string::npos);
566 found = dump.find(
"ClPooling2dWorkload_Execute");
567 BOOST_TEST(found != std::string::npos);
570 found = dump.find(
"CopyMemGeneric");
571 BOOST_TEST(found != std::string::npos);
574 BOOST_TEST(outputData == expectedOutput);
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
static IRuntimePtr Create(const CreationOptions &options)
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
armnn::Layer * GetFirstLayerWithName(armnn::Graph &graph, const std::string &name)
static ProfilerManager & GetInstance()
bool CheckOrder(const armnn::Graph &graph, const armnn::Layer *first, const armnn::Layer *second)
Checks that first comes before second in the order.
virtual void BackendSelectionHint(Optional< BackendId > backend)=0
Provide a hint for the optimizer as to which backend to prefer for this layer.
uint32_t m_PoolWidth
Pooling width value.
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
void Print(std::ostream &outStream) const
Print stats for events in JSON Format to the given output stream.
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
Copyright (c) 2021 ARM Limited and Contributors.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
IProfiler * GetProfiler()
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
uint32_t m_PoolHeight
Pooling height value.
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
Create an optimized version of the network.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
BOOST_AUTO_TEST_CASE(ClImportEnabledFallbackToNeon)
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
GPU Execution: OpenCL: ArmCompute.
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
const BackendId & GetBackendId() const
Graph & GetGraphForTesting(IOptimizedNetwork *optNet)
BOOST_AUTO_TEST_SUITE_END()
CPU Execution: NEON: ArmCompute.
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
virtual int Connect(IInputSlot &destination)=0
A Pooling2dDescriptor for the Pooling2dLayer.
static INetworkPtr Create(NetworkOptions networkOptions={})
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
unsigned int GetNumElements() const