| 983 | |
| 984 | #ifdef PPLNN_ENABLE_KERNEL_PROFILING |
| 985 | static void PrintProfilingStatistics(const ProfilingStatistics& stat, double run_dur, int32_t run_count) { |
| 986 | std::map<std::string, std::pair<double, double>> type_stat; |
| 987 | std::map<std::string, int> type_count; |
| 988 | char float_buf_0[128]; |
| 989 | char float_buf_1[128]; |
| 990 | LOG(INFO) << "----- OP statistics by Node -----"; |
| 991 | for (auto x = stat.prof_info.begin(); x != stat.prof_info.end(); ++x) { |
| 992 | auto ext_type = (x->domain == "" ? "" : x->domain + ".") + x->type; |
| 993 | double time = (double)x->exec_microseconds / 1000; |
| 994 | double avg_time = time / x->exec_count; |
| 995 | if (type_stat.find(ext_type) == type_stat.end()) { |
| 996 | type_stat[ext_type] = std::make_pair(avg_time, time); |
| 997 | type_count[ext_type] = 1; |
| 998 | } else { |
| 999 | std::pair<double, double>& time_pair = type_stat[ext_type]; |
| 1000 | time_pair.first += avg_time; |
| 1001 | time_pair.second += time; |
| 1002 | type_count[ext_type]++; |
| 1003 | } |
| 1004 | sprintf(float_buf_0, "%8.4f", avg_time); |
| 1005 | string temp = x->name; |
| 1006 | temp.insert(temp.length(), temp.length() > 50 ? 0 : 50 - temp.length(), ' '); |
| 1007 | LOG(INFO) << "NAME: [" << temp << "], " |
| 1008 | << "AVG_TIME: [" << float_buf_0 << "], " |
| 1009 | << "EXEC_COUNT: [" << x->exec_count << "]"; |
| 1010 | } |
| 1011 | LOG(INFO) << "----- OP statistics by OpType -----"; |
| 1012 | double tot_kernel_time = 0; |
| 1013 | for (auto it = type_stat.begin(); it != type_stat.end(); ++it) { |
| 1014 | tot_kernel_time += it->second.second; |
| 1015 | } |
| 1016 | for (auto it = type_stat.begin(); it != type_stat.end(); ++it) { |
| 1017 | sprintf(float_buf_0, "%8.4f", it->second.first); |
| 1018 | sprintf(float_buf_1, "%8.4f", it->second.second / tot_kernel_time * 100); |
| 1019 | string temp = it->first; |
| 1020 | temp.insert(temp.length(), temp.length() > 20 ? 0 : 20 - temp.length(), ' '); |
| 1021 | LOG(INFO) << "TYPE: [" << temp << "], AVG_TIME: [" << float_buf_0 << "], Percentage: [" << float_buf_1 |
| 1022 | << "], excute times [" << type_count[it->first] << "]"; |
| 1023 | } |
| 1024 | |
| 1025 | LOG(INFO) << "----- TOTAL statistics -----"; |
| 1026 | sprintf(float_buf_0, "%8.4f", tot_kernel_time / run_count); |
| 1027 | sprintf(float_buf_1, "%8.4f", run_dur / run_count); |
| 1028 | LOG(INFO) << "RUN_COUNT: [" << run_count << "]"; |
| 1029 | LOG(INFO) << "AVG_KERNEL_TIME: [" << float_buf_0 << "]"; |
| 1030 | LOG(INFO) << "AVG_RUN_TIME: [" << float_buf_1 << "]"; |
| 1031 | sprintf(float_buf_0, "%8.4f", tot_kernel_time); |
| 1032 | sprintf(float_buf_1, "%8.4f", run_dur); |
| 1033 | LOG(INFO) << "TOT_KERNEL_TIME: [" << float_buf_0 << "]"; |
| 1034 | LOG(INFO) << "TOT_RUN_TIME: [" << float_buf_1 << "]"; |
| 1035 | sprintf(float_buf_0, "%8.4f%%", (run_dur - tot_kernel_time) / run_dur * 100); |
| 1036 | LOG(INFO) << "SCHED_LOST: [" << float_buf_0 << "]"; |
| 1037 | } |
| 1038 | #endif |
| 1039 | |
| 1040 | static bool SetInputs(const vector<string>& input_data, Runtime* runtime) { |
no test coverage detected