6 #include "../ProfilingConnectionDumpToFileDecorator.hpp" 12 #include <boost/core/ignore_unused.hpp> 13 #include <boost/filesystem.hpp> 14 #include <boost/numeric/conversion/cast.hpp> 15 #include <boost/test/unit_test.hpp> 22 const std::vector<char> g_Data = {
'd',
'u',
'm',
'm',
'y' };
23 const uint32_t g_DataLength = boost::numeric_cast<uint32_t>(g_Data.size());
24 const unsigned char* g_DataPtr =
reinterpret_cast<const unsigned char*
>(g_Data.data());
29 DummyProfilingConnection()
31 , m_PacketData(
std::make_unique<unsigned char[]>(g_DataLength))
34 std::memcpy(m_PacketData.get(), g_DataPtr, g_DataLength);
35 m_Packet = std::make_unique<Packet>(0u, g_DataLength, m_PacketData);
38 ~DummyProfilingConnection() =
default;
40 bool IsOpen()
const override 50 bool WritePacket(
const unsigned char* buffer, uint32_t length)
override 52 boost::ignore_unused(buffer);
53 boost::ignore_unused(length);
57 Packet ReadPacket(uint32_t timeout)
override 59 boost::ignore_unused(timeout);
60 return std::move(*m_Packet);
65 std::unique_ptr<unsigned char[]> m_PacketData;
66 std::unique_ptr<Packet> m_Packet;
69 std::vector<char> ReadDumpFile(
const std::string& dumpFileName)
71 std::ifstream input(dumpFileName, std::ios::binary);
72 return std::vector<char>(std::istreambuf_iterator<char>(input), {});
81 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
82 options.m_IncomingCaptureFile =
"/";
83 options.m_OutgoingCaptureFile =
"";
90 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
91 options.m_IncomingCaptureFile =
"/";
92 options.m_OutgoingCaptureFile =
"";
99 boost::filesystem::path fileName =
100 boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
102 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
103 options.m_IncomingCaptureFile = fileName.string();
104 options.m_OutgoingCaptureFile =
"";
109 std::unique_ptr<Packet> packet;
110 BOOST_CHECK_NO_THROW(packet = std::make_unique<Packet>(decorator.
ReadPacket(0)));
114 std::vector<char> data = ReadDumpFile(options.m_IncomingCaptureFile);
115 const char* packetData =
reinterpret_cast<const char*
>(packet->GetData());
118 constexpr
unsigned int bytesToSkip = 2u *
sizeof(uint32_t);
119 int diff = std::strncmp(data.data() + bytesToSkip, packetData, g_DataLength);
125 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
126 options.m_IncomingCaptureFile =
"";
127 options.m_OutgoingCaptureFile =
"/";
134 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
135 options.m_IncomingCaptureFile =
"";
136 options.m_OutgoingCaptureFile =
"/";
139 BOOST_CHECK_NO_THROW(decorator.
WritePacket(g_DataPtr, g_DataLength));
141 bool success = decorator.
WritePacket(g_DataPtr, g_DataLength);
147 boost::filesystem::path fileName =
148 boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
150 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
151 options.m_IncomingCaptureFile =
"";
152 options.m_OutgoingCaptureFile = fileName.string();
156 bool success =
false;
157 BOOST_CHECK_NO_THROW(success = decorator.
WritePacket(g_DataPtr, g_DataLength));
162 std::vector<char> data = ReadDumpFile(options.m_OutgoingCaptureFile);
165 int diff = std::strncmp(data.data(), g_Data.data(), g_DataLength);
bool WritePacket(const unsigned char *buffer, uint32_t length) override
Packet ReadPacket(uint32_t timeout) override
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
DataLayout::NCHW DataLayout::NCHW DataLayout::NHWC DataLayout::NHWC true
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options