19 #include <valgrind/memcheck.h> 22 #include <boost/test/unit_test.hpp> 31 runtime->m_LoadedNetworks.reserve(1);
47 mockNetwork1->AddInputLayer(0,
"test layer");
49 runtime->LoadNetwork(networkIdentifier1,
Optimize(*mockNetwork1, backends, runtime->GetDeviceSpec()));
54 mockNetwork2->AddInputLayer(0,
"test layer");
55 runtime->LoadNetwork(networkIdentifier2,
Optimize(*mockNetwork2, backends, runtime->GetDeviceSpec()));
68 #ifdef ARMNN_LEAK_CHECKING_ENABLED 70 struct DisableGlobalLeakChecking
72 DisableGlobalLeakChecking()
88 std::unique_ptr<char[]> dummyAllocation(
new char[1000]);
90 "A leak of 1000 bytes is expected here. " 91 "Please make sure environment variable: HEAPCHECK=draconian is set!");
101 #endif // ARMNN_LEAK_CHECKING_ENABLED 113 unsigned long leakedBefore = 0;
114 unsigned long leakedAfter = 0;
119 unsigned long reachableBefore = 0;
120 unsigned long reachableAfter = 0;
123 unsigned long dubious = 0;
124 unsigned long suppressed = 0;
137 std::unique_ptr<armnn::Network> mockNetwork1 = std::make_unique<armnn::Network>();
138 mockNetwork1->AddInputLayer(0,
"test layer");
145 VALGRIND_DO_QUICK_LEAK_CHECK;
146 VALGRIND_COUNT_LEAKS(leakedBefore, dubious, reachableBefore, suppressed);
152 VALGRIND_DO_ADDED_LEAK_CHECK;
153 VALGRIND_COUNT_LEAKS(leakedAfter, dubious, reachableAfter, suppressed);
157 BOOST_TEST(leakedBefore == leakedAfter);
158 BOOST_TEST(reachableBefore == reachableAfter);
165 #endif // WITH_VALGRIND 169 using namespace armnn;
198 BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) ==
Status::Success);
203 using namespace armnn;
233 BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) ==
Status::Success);
239 using namespace armnn;
263 std::vector<std::string> errMessages;
266 runtime->GetDeviceSpec(),
270 BOOST_TEST(errMessages.size() == 1);
271 BOOST_TEST(errMessages[0] ==
272 "ERROR: output 0 of layer Softmax (softmax) is of type " 273 "Quantized 8 bit but its scale parameter has not been set");
279 using namespace armnn;
293 options1.
AddOption({
"Option3",
"some_value" });
296 backendOptions.push_back(options1);
305 BOOST_TEST(backendOptions[0].
GetBackendId().Get() ==
"FakeBackend1");
306 BOOST_TEST(backendOptions[0].GetOption(0).GetName() ==
"Option1");
307 BOOST_TEST(backendOptions[0].GetOption(0).GetValue().IsFloat() ==
true);
308 BOOST_TEST(backendOptions[0].GetOption(0).GetValue().AsFloat() == 1.3f);
310 BOOST_TEST(backendOptions[0].GetOption(1).GetName() ==
"Option2");
311 BOOST_TEST(backendOptions[0].GetOption(1).GetValue().IsBool() ==
true);
312 BOOST_TEST(backendOptions[0].GetOption(1).GetValue().AsBool() ==
true);
314 BOOST_TEST(backendOptions[0].GetOption(2).GetName() ==
"Option3");
315 BOOST_TEST(backendOptions[0].GetOption(2).GetValue().IsString() ==
true);
316 BOOST_TEST(backendOptions[0].GetOption(2).GetValue().AsString() ==
"some_value");
319 BOOST_TEST(backendOptions[1].
GetBackendId().Get() ==
"FakeBackend1");
320 BOOST_TEST(backendOptions[1].GetOption(0).GetName() ==
"Option4");
321 BOOST_TEST(backendOptions[1].GetOption(0).GetValue().IsInt() ==
true);
322 BOOST_TEST(backendOptions[1].GetOption(0).GetValue().AsInt() == 42);
327 using namespace armnn;
363 BOOST_TEST(!readableBuffer);
368 using namespace armnn;
390 IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor,
"normalization");
416 unsigned int size = readableBuffer->GetSize();
419 const unsigned char* readableData = readableBuffer->GetReadableData();
422 unsigned int offset = 0;
684 bufferManager.MarkRead(readableBuffer);
687 std::vector<float> inputData(16);
688 std::vector<float> outputData(16);
703 auto inputReadableBuffer = bufferManager.GetReadableBuffer();
707 auto outputReadableBuffer = bufferManager.GetReadableBuffer();
711 auto inferenceReadableBuffer = bufferManager.GetReadableBuffer();
715 size = inputReadableBuffer->GetSize();
718 readableData = inputReadableBuffer->GetReadableData();
773 bufferManager.MarkRead(inputReadableBuffer);
776 size = outputReadableBuffer->GetSize();
779 readableData = outputReadableBuffer->GetReadableData();
834 bufferManager.MarkRead(outputReadableBuffer);
837 size = inferenceReadableBuffer->GetSize();
840 readableData = inferenceReadableBuffer->GetReadableData();
1145 bufferManager.MarkRead(inferenceReadableBuffer);
#define ARMNN_SCOPED_LEAK_CHECKER(TAG)
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
static ARMNN_DLLEXPORT ProfilingStaticGuid INFERENCE_GUID
virtual TensorInfo GetOutputTensorInfo(NetworkId networkId, LayerBindingId layerId) const override
#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
void ForceTransitionToState(ProfilingState newState)
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.
profiling::ProfilingService & GetProfilingService(armnn::Runtime *runtime)
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
void ResetExternalProfilingOptions(const ExternalProfilingOptions &options, bool resetProfilingService=false)
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
IPacketBufferPtr GetReadableBuffer() override
constexpr unsigned int ThreadIdSize
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.
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.
BufferManager & GetProfilingBufferManager()
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
virtual Status EnqueueWorkload(NetworkId networkId, const InputTensors &inputTensors, const OutputTensors &outputTensors) override
Evaluates a network using input in inputTensors and outputs filled into outputTensors.
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)
virtual TensorInfo GetInputTensorInfo(NetworkId networkId, LayerBindingId layerId) const override
BOOST_GLOBAL_FIXTURE(ConfigureLoggingFixture)