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);
161 boost::ignore_unused(dubious);
162 boost::ignore_unused(suppressed);
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;
275 std::vector<std::string> errMessages;
279 runtime->GetDeviceSpec(),
284 BOOST_TEST(errMessages.size() == 1);
285 BOOST_TEST(errMessages[0] ==
286 "ERROR: output 0 of layer Softmax (softmax) is of type " 287 "Quantized 8 bit but its scale parameter has not been set");
293 using namespace armnn;
307 options1.
AddOption({
"Option3",
"some_value"});
310 backendOptions.push_back(options1);
313 backendOptions.emplace_back(
320 BOOST_TEST(backendOptions[0].
GetBackendId().Get() ==
"FakeBackend1");
321 BOOST_TEST(backendOptions[0].GetOption(0).GetName() ==
"Option1");
322 BOOST_TEST(backendOptions[0].GetOption(0).GetValue().IsFloat() ==
true);
323 BOOST_TEST(backendOptions[0].GetOption(0).GetValue().AsFloat() == 1.3f);
325 BOOST_TEST(backendOptions[0].GetOption(1).GetName() ==
"Option2");
326 BOOST_TEST(backendOptions[0].GetOption(1).GetValue().IsBool() ==
true);
327 BOOST_TEST(backendOptions[0].GetOption(1).GetValue().AsBool() ==
true);
329 BOOST_TEST(backendOptions[0].GetOption(2).GetName() ==
"Option3");
330 BOOST_TEST(backendOptions[0].GetOption(2).GetValue().IsString() ==
true);
331 BOOST_TEST(backendOptions[0].GetOption(2).GetValue().AsString() ==
"some_value");
334 BOOST_TEST(backendOptions[1].
GetBackendId().Get() ==
"FakeBackend1");
335 BOOST_TEST(backendOptions[1].GetOption(0).GetName() ==
"Option4");
336 BOOST_TEST(backendOptions[1].GetOption(0).GetValue().IsInt() ==
true);
337 BOOST_TEST(backendOptions[1].GetOption(0).GetValue().AsInt() == 42);
342 using namespace armnn;
371 BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) ==
Status::Success);
378 BOOST_TEST(!readableBuffer);
383 using namespace armnn;
397 IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor,
"normalization");
415 BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) ==
Status::Success);
424 unsigned int size = readableBuffer->GetSize();
427 const unsigned char* readableData = readableBuffer->GetReadableData();
430 unsigned int offset = 0;
688 bufferManager.
MarkRead(readableBuffer);
691 std::vector<float> inputData(16);
692 std::vector<float> outputData(16);
696 {0,
ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data())}
700 {0,
Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data())}
704 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
719 size = inputReadableBuffer->GetSize();
722 readableData = inputReadableBuffer->GetReadableData();
774 bufferManager.
MarkRead(inputReadableBuffer);
777 size = outputReadableBuffer->GetSize();
780 readableData = outputReadableBuffer->GetReadableData();
832 bufferManager.
MarkRead(outputReadableBuffer);
835 size = inferenceReadableBuffer->GetSize();
838 readableData = inferenceReadableBuffer->GetReadableData();
1140 bufferManager.
MarkRead(inferenceReadableBuffer);
virtual LayerGuid GetGuid() const =0
Head retains(parents) Tail.
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
A NormalizationDescriptor for the NormalizationLayer.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
static ARMNN_DLLEXPORT ProfilingStaticGuid WORKLOAD_EXECUTION_GUID
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
void VerifyTimelineLabelBinaryPacket(Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
static ARMNN_DLLEXPORT ProfilingStaticGuid ARMNN_PROFILING_EOL_EVENT_CLASS
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
virtual Status UnloadNetwork(NetworkId networkId) override
virtual const IDeviceSpec & GetDeviceSpec() const override
#define ARMNN_LEAK_CHECKER_IS_ACTIVE()
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
#define ARMNN_OBJECTS_LEAKED_IN_SCOPE()
static ARMNN_DLLEXPORT ProfilingStaticGuid CONNECTION_GUID
#define ARMNN_NO_LEAKS_IN_SCOPE()
ExternalProfilingOptions m_ProfilingOptions
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
static ARMNN_DLLEXPORT ProfilingStaticGuid INFERENCE_GUID
static ARMNN_DLLEXPORT ProfilingStaticGuid TYPE_GUID
void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
IPacketBufferPtr GetReadableBuffer() override
void VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, const unsigned char *readableData, unsigned int &offset)
void VerifyTimelineEventBinaryPacket(Optional< uint64_t > timestamp, Optional< std::thread::id > threadId, Optional< ProfilingGuid > eventGuid, const unsigned char *readableData, unsigned int &offset)
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
static ARMNN_DLLEXPORT ProfilingStaticGuid BACKENDID_GUID
Head execution start depends on Tail execution completion.
static ARMNN_DLLEXPORT ProfilingStaticGuid NETWORK_GUID
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
#define ARMNN_BYTES_LEAKED_IN_SCOPE()
static INetworkPtr Create()
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
CPU Execution: Reference C++ kernels.
static IRuntimePtr Create(const CreationOptions &options)
BOOST_AUTO_TEST_SUITE_END()
void RuntimeLoadedNetworksReserve(armnn::Runtime *runtime)
void AddOption(BackendOption &&option)
A SoftmaxDescriptor for the SoftmaxLayer.
#define ARMNN_SCOPED_LEAK_CHECKER(TAG)
CPU Execution: NEON: ArmCompute.
Struct for the users to pass backend specific options.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
void MarkRead(IPacketBufferPtr &packetBuffer) override
static ARMNN_DLLEXPORT ProfilingStaticGuid ARMNN_PROFILING_SOL_EVENT_CLASS
virtual int Connect(IInputSlot &destination)=0
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
static ARMNN_DLLEXPORT ProfilingStaticGuid NAME_GUID
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
BOOST_GLOBAL_FIXTURE(ConfigureLoggingFixture)
virtual Status LoadNetwork(NetworkId &networkIdOut, IOptimizedNetworkPtr network) override
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
#define ARMNN_LOCAL_LEAK_CHECKING_ONLY()
void VerifyTimelineEntityBinaryPacket(Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
std::vector< BackendOptions > m_BackendOptions
const char * GetBackendId()