From ce3e84a8d449cbf31cee57e30f0eef6a96c0ce94 Mon Sep 17 00:00:00 2001 From: telsoa01 Date: Fri, 31 Aug 2018 09:31:35 +0100 Subject: Release 18.08 --- Utils.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'Utils.cpp') diff --git a/Utils.cpp b/Utils.cpp index 99912201..38a8cd31 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -18,6 +18,7 @@ #include using namespace android; +using namespace android::hardware; using namespace android::hidl::memory::V1_0; namespace armnn_driver @@ -111,7 +112,7 @@ std::string GetOperandSummary(const Operand& operand) toString(operand.type); } -std::string GetModelSummary(const V1_0::Model& model) +std::string GetModelSummary(const neuralnetworks::V1_0::Model& model) { std::stringstream result; @@ -280,9 +281,48 @@ void DumpTensor(const std::string& dumpDir, } } +void DumpJsonProfilingIfRequired(bool gpuProfilingEnabled, + const std::string& dumpDir, + armnn::NetworkId networkId, + const armnn::IProfiler* profiler) +{ + // Check if profiling is required. + if (!gpuProfilingEnabled) + { + return; + } + + // The dump directory must exist in advance. + if (dumpDir.empty()) + { + return; + } + + BOOST_ASSERT(profiler); + + // Set the name of the output profiling file. + const std::string fileName = boost::str(boost::format("%1%/%2%_%3%.json") + % dumpDir + % std::to_string(networkId) + % "profiling"); + + // Open the ouput file for writing. + std::ofstream fileStream; + fileStream.open(fileName, std::ofstream::out | std::ofstream::trunc); + + if (!fileStream.good()) + { + ALOGW("Could not open file %s for writing", fileName.c_str()); + return; + } + + // Write the profiling info to a JSON file. + profiler->Print(fileStream); +} + void ExportNetworkGraphToDotFile(const armnn::IOptimizedNetwork& optimizedNetwork, const std::string& dumpDir, - const V1_0::Model& model) + const neuralnetworks::V1_0::Model& model) { // The dump directory must exist in advance. if (dumpDir.empty()) @@ -318,4 +358,5 @@ void ExportNetworkGraphToDotFile(const armnn::IOptimizedNetwork& optimizedNetwor ALOGW("An error occurred when writing to file %s", fileName.c_str()); } } + } // namespace armnn_driver -- cgit v1.2.1