19 #include <valgrind/memcheck.h> 22 #include <boost/test/unit_test.hpp> 30 runtime->m_LoadedNetworks.reserve(1);
46 mockNetwork1->AddInputLayer(0,
"test layer");
48 runtime->LoadNetwork(networkIdentifier1,
Optimize(*mockNetwork1, backends, runtime->GetDeviceSpec()));
53 mockNetwork2->AddInputLayer(0,
"test layer");
54 runtime->LoadNetwork(networkIdentifier2,
Optimize(*mockNetwork2, backends, runtime->GetDeviceSpec()));
67 #ifdef ARMNN_LEAK_CHECKING_ENABLED 69 struct DisableGlobalLeakChecking
71 DisableGlobalLeakChecking()
87 std::unique_ptr<char[]> dummyAllocation(
new char[1000]);
89 "A leak of 1000 bytes is expected here. " 90 "Please make sure environment variable: HEAPCHECK=draconian is set!");
100 #endif // ARMNN_LEAK_CHECKING_ENABLED 112 unsigned long leakedBefore = 0;
113 unsigned long leakedAfter = 0;
118 unsigned long reachableBefore = 0;
119 unsigned long reachableAfter = 0;
122 unsigned long dubious = 0;
123 unsigned long suppressed = 0;
136 std::unique_ptr<armnn::Network> mockNetwork1 = std::make_unique<armnn::Network>();
137 mockNetwork1->AddInputLayer(0,
"test layer");
144 VALGRIND_DO_QUICK_LEAK_CHECK;
145 VALGRIND_COUNT_LEAKS(leakedBefore, dubious, reachableBefore, suppressed);
151 VALGRIND_DO_ADDED_LEAK_CHECK;
152 VALGRIND_COUNT_LEAKS(leakedAfter, dubious, reachableAfter, suppressed);
156 BOOST_TEST(leakedBefore == leakedAfter);
157 BOOST_TEST(reachableBefore == reachableAfter);
164 #endif // WITH_VALGRIND 168 using namespace armnn;
197 BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) ==
Status::Success);
202 using namespace armnn;
232 BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) ==
Status::Success);
238 using namespace armnn;
262 std::vector<std::string> errMessages;
265 runtime->GetDeviceSpec(),
269 BOOST_TEST(errMessages.size() == 1);
270 BOOST_TEST(errMessages[0] ==
271 "ERROR: output 0 of layer Softmax (softmax) is of type " 272 "Quantized 8 bit but its scale parameter has not been set");
278 using namespace armnn;
292 options1.
AddOption({
"Option3",
"some_value" });
295 backendOptions.push_back(options1);
304 BOOST_TEST(backendOptions[0].
GetBackendId().Get() ==
"FakeBackend1");
305 BOOST_TEST(backendOptions[0].GetOption(0).GetName() ==
"Option1");
306 BOOST_TEST(backendOptions[0].GetOption(0).GetValue().IsFloat() ==
true);
307 BOOST_TEST(backendOptions[0].GetOption(0).GetValue().AsFloat() == 1.3f);
309 BOOST_TEST(backendOptions[0].GetOption(1).GetName() ==
"Option2");
310 BOOST_TEST(backendOptions[0].GetOption(1).GetValue().IsBool() ==
true);
311 BOOST_TEST(backendOptions[0].GetOption(1).GetValue().AsBool() ==
true);
313 BOOST_TEST(backendOptions[0].GetOption(2).GetName() ==
"Option3");
314 BOOST_TEST(backendOptions[0].GetOption(2).GetValue().IsString() ==
true);
315 BOOST_TEST(backendOptions[0].GetOption(2).GetValue().AsString() ==
"some_value");
318 BOOST_TEST(backendOptions[1].
GetBackendId().Get() ==
"FakeBackend1");
319 BOOST_TEST(backendOptions[1].GetOption(0).GetName() ==
"Option4");
320 BOOST_TEST(backendOptions[1].GetOption(0).GetValue().IsInt() ==
true);
321 BOOST_TEST(backendOptions[1].GetOption(0).GetValue().AsInt() == 42);
326 using namespace armnn;
355 BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) ==
Status::Success);
362 BOOST_TEST(!readableBuffer);
367 using namespace armnn;
381 IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor,
"normalization");
399 BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) ==
Status::Success);
408 unsigned int size = readableBuffer->GetSize();
411 const unsigned char* readableData = readableBuffer->GetReadableData();
414 unsigned int offset = 0;
676 bufferManager.
MarkRead(readableBuffer);
679 std::vector<float> inputData(16);
680 std::vector<float> outputData(16);
684 { 0,
ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data()) }
688 { 0,
Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data()) }
692 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
707 size = inputReadableBuffer->GetSize();
710 readableData = inputReadableBuffer->GetReadableData();
765 bufferManager.
MarkRead(inputReadableBuffer);
768 size = outputReadableBuffer->GetSize();
771 readableData = outputReadableBuffer->GetReadableData();
826 bufferManager.
MarkRead(outputReadableBuffer);
829 size = inferenceReadableBuffer->GetSize();
832 readableData = inferenceReadableBuffer->GetReadableData();
1137 bufferManager.
MarkRead(inferenceReadableBuffer);
#define ARMNN_SCOPED_LEAK_CHECKER(TAG)
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
static ARMNN_DLLEXPORT ProfilingStaticGuid INFERENCE_GUID
#define ARMNN_LOCAL_LEAK_CHECKING_ONLY()
static IRuntimePtr Create(const CreationOptions &options)
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
void VerifyTimelineEntityBinaryPacketData(Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
CPU Execution: Reference C++ kernels.
virtual const IDeviceSpec & GetDeviceSpec() const override
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
Head retains(parents) Tail.
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
void VerifyTimelineLabelBinaryPacketData(Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
Copyright (c) 2020 ARM Limited.
Head execution start depends on Tail execution completion.
void IgnoreUnused(Ts &&...)
static ARMNN_DLLEXPORT ProfilingStaticGuid CONNECTION_GUID
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
static ARMNN_DLLEXPORT ProfilingStaticGuid WORKLOAD_EXECUTION_GUID
static ARMNN_DLLEXPORT ProfilingStaticGuid ARMNN_PROFILING_EOL_EVENT_CLASS
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
#define ARMNN_LEAK_CHECKER_IS_ACTIVE()
static ARMNN_DLLEXPORT ProfilingStaticGuid NAME_GUID
static ARMNN_DLLEXPORT ProfilingStaticGuid ARMNN_PROFILING_SOL_EVENT_CLASS
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
#define ARMNN_OBJECTS_LEAKED_IN_SCOPE()
std::vector< BackendOptions > m_BackendOptions
Pass backend specific options.
const char * GetBackendId()
void AddOption(BackendOption &&option)
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.
virtual LayerGuid GetGuid() const =0
Returns the unique id of the layer.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
IPacketBufferPtr GetReadableBuffer() override
void VerifyTimelineHeaderBinary(const unsigned char *readableData, unsigned int &offset, uint32_t packetDataLength)
static ARMNN_DLLEXPORT ProfilingStaticGuid NETWORK_GUID
Struct for the users to pass backend specific options.
void MarkRead(IPacketBufferPtr &packetBuffer) override
BOOST_AUTO_TEST_SUITE_END()
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, const unsigned char *readableData, unsigned int &offset)
static ARMNN_DLLEXPORT ProfilingStaticGuid TYPE_GUID
virtual Status LoadNetwork(NetworkId &networkIdOut, IOptimizedNetworkPtr network) override
Loads a complete network into the Runtime.
void VerifyTimelineEventBinaryPacket(Optional< uint64_t > timestamp, Optional< std::thread::id > threadId, Optional< ProfilingGuid > eventGuid, const unsigned char *readableData, unsigned int &offset)
CPU Execution: NEON: ArmCompute.
#define ARMNN_NO_LEAKS_IN_SCOPE()
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.
virtual Status UnloadNetwork(NetworkId networkId) override
Unloads a network from the Runtime.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
virtual int Connect(IInputSlot &destination)=0
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
A NormalizationDescriptor for the NormalizationLayer.
ExternalProfilingOptions m_ProfilingOptions
A SoftmaxDescriptor for the SoftmaxLayer.
#define ARMNN_BYTES_LEAKED_IN_SCOPE()
static ARMNN_DLLEXPORT ProfilingStaticGuid BACKENDID_GUID
static INetworkPtr Create()
void RuntimeLoadedNetworksReserve(armnn::Runtime *runtime)
BOOST_GLOBAL_FIXTURE(ConfigureLoggingFixture)