1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
5 #include <vpu/utils/perf_report.hpp>
13 std::map<std::string, ie::InferenceEngineProfileInfo> parsePerformanceReport(
14 const std::vector<StageMetaInfo>& stagesMeta,
15 const float* deviceTimings,
16 int deviceTimingsCount,
17 PerfReport perfReport,
18 bool printReceiveTensorTime) {
19 IE_ASSERT(deviceTimings != nullptr);
20 IE_ASSERT(deviceTimingsCount > 0);
22 std::map<std::string, ie::InferenceEngineProfileInfo> outPerfMap;
27 for (const auto& stageMeta : stagesMeta) {
29 if (stageMeta.status == ie::InferenceEngineProfileInfo::EXECUTED &&
30 timeIndex < deviceTimingsCount) {
31 timeMS = deviceTimings[timeIndex];
35 if (stageMeta.stageType == "<Receive-Tensor>" &&
36 !printReceiveTensorTime) {
40 ie::InferenceEngineProfileInfo profInfo = {};
42 profInfo.status = stageMeta.status;
44 profInfo.cpu_uSec = 0;
45 profInfo.realTime_uSec = static_cast<long long int>(timeMS * 1000);
47 stageMeta.layerType.copy(profInfo.layer_type, sizeof(profInfo.layer_type) / sizeof(profInfo.layer_type[0]), 0);
48 stageMeta.stageType.copy(profInfo.exec_type, sizeof(profInfo.exec_type) / sizeof(profInfo.exec_type[0]), 0);
50 if (stageMeta.stageType == "<Receive-Tensor>") {
51 profInfo.execution_index = 0;
52 } else if (stageMeta.status == ie::InferenceEngineProfileInfo::EXECUTED) {
53 profInfo.execution_index = execIndex;
57 if (perfReport == PerfReport::PerStage) {
58 outPerfMap[stageMeta.stageName] = profInfo;
59 } else if (perfReport == PerfReport::PerLayer) {
60 auto it = outPerfMap.find(stageMeta.layerName);
61 if (it == outPerfMap.end()) {
62 outPerfMap[stageMeta.layerName] = profInfo;
64 auto& prevProfInfo = it->second;
66 if (profInfo.status == ie::InferenceEngineProfileInfo::EXECUTED) {
67 prevProfInfo.status = ie::InferenceEngineProfileInfo::EXECUTED;
70 prevProfInfo.cpu_uSec += profInfo.cpu_uSec;
71 prevProfInfo.realTime_uSec += profInfo.realTime_uSec;