diff options
author | Ferran Balaguer <ferran.balaguer@arm.com> | 2019-08-07 15:14:56 +0100 |
---|---|---|
committer | Ferran Balaguer Arm <ferran.balaguer@arm.com> | 2019-08-20 14:31:07 +0000 |
commit | bfeb2711da172b26931c58af7b15d434ef49e24e (patch) | |
tree | 3516b24857effe4c98737f48026dabf75d1f360a /src/backends/reference/test/RefEndToEndTests.cpp | |
parent | aec942c3f258db46e0fb8054d39c0e7c3c411728 (diff) | |
download | armnn-bfeb2711da172b26931c58af7b15d434ef49e24e.tar.gz |
IVGCVSW-3606 Support memory import for Reference backend
Signed-off-by: Ferran Balaguer <ferran.balaguer@arm.com>
Change-Id: I94bd191f88e0911ad4e4727610e81cd7afa95512
Diffstat (limited to 'src/backends/reference/test/RefEndToEndTests.cpp')
-rw-r--r-- | src/backends/reference/test/RefEndToEndTests.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/backends/reference/test/RefEndToEndTests.cpp b/src/backends/reference/test/RefEndToEndTests.cpp index f81f1a708f..31e9b339ec 100644 --- a/src/backends/reference/test/RefEndToEndTests.cpp +++ b/src/backends/reference/test/RefEndToEndTests.cpp @@ -322,6 +322,78 @@ BOOST_AUTO_TEST_CASE(TrivialMin) BOOST_TEST(outputData[3] == 2); } +BOOST_AUTO_TEST_CASE(RefNoCopyWorkloads) +{ + using namespace armnn; + + // Create runtime in which test will run + IRuntime::CreationOptions options; + IRuntimePtr runtime(armnn::IRuntime::Create(options)); + + // build up the structure of the network + INetworkPtr net(INetwork::Create()); + + IConnectableLayer* input = net->AddInputLayer(0); + + NormalizationDescriptor descriptor; + IConnectableLayer* norm = net->AddNormalizationLayer(descriptor); + + IConnectableLayer* output = net->AddOutputLayer(0); + + input->GetOutputSlot(0).Connect(norm->GetInputSlot(0)); + norm->GetOutputSlot(0).Connect(output->GetInputSlot(0)); + + input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 1 }, DataType::Float32)); + norm->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 1 }, DataType::Float32)); + + // Optimize the network + IOptimizedNetworkPtr optNet = Optimize(*net, defaultBackends, runtime->GetDeviceSpec()); + + // Loads it into the runtime. + NetworkId netId; + runtime->LoadNetwork(netId, std::move(optNet)); + + // Creates structures for input & output + std::vector<float> inputData + { + 1.0f, 2.0f, 3.0f, 4.0f + }; + + std::vector<float> outputData(4); + + InputTensors inputTensors + { + {0,armnn::ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data())}, + }; + OutputTensors outputTensors + { + {0,armnn::Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data())} + }; + + // The result of the inference is not important, just the fact that there + // should not be CopyMemGeneric workloads. + runtime->GetProfiler(netId)->EnableProfiling(true); + + // Do the inference + runtime->EnqueueWorkload(netId, inputTensors, outputTensors); + + // Retrieve the Profiler.Print() output to get the workload execution + ProfilerManager& profilerManager = armnn::ProfilerManager::GetInstance(); + std::stringstream ss; + profilerManager.GetProfiler()->Print(ss);; + std::string dump = ss.str(); + + // Contains RefNormalizationWorkload + std::size_t found = dump.find("RefNormalizationWorkload"); + BOOST_TEST(found != std::string::npos); + // Contains SyncMemGeneric + found = dump.find("SyncMemGeneric"); + BOOST_TEST(found != std::string::npos); + // No contains CopyMemGeneric + found = dump.find("CopyMemGeneric"); + BOOST_TEST(found == std::string::npos); +} + BOOST_AUTO_TEST_CASE(RefEqualSimpleEndToEndTest) { const std::vector<uint8_t> expectedOutput({ 1, 1, 1, 1, 0, 0, 0, 0, |