1 #ifndef PROF_DAG_COUNTERS_H 2 #define PROF_DAG_COUNTERS_H 4 #include "caffe2/core/common.h" 5 #include "caffe2/core/logging.h" 6 #include "caffe2/core/timer.h" 7 #include "caffe2/proto/caffe2_pb.h" 8 #include "caffe2/proto/prof_dag.pb.h" 10 #include <unordered_map> 18 : sum_(time_ms), sqrsum_(time_ms * time_ms), cnt_(1) {}
22 sqrsum_ += rhs.sqrsum_;
27 std::pair<float, float> computeMoments()
const {
28 CAFFE_ENFORCE_GT(cnt_, 0);
29 float mean = sum_ / cnt_;
30 float stddev = std::sqrt(std::abs(sqrsum_ / cnt_ - mean * mean));
31 return {mean, stddev};
38 float sqrsum()
const {
56 ProfDAGProtos GetOperatorStats()
const;
60 ProfDAGProtos GetPerOperatorCost()
const;
67 ProfDAGProto statsProto(
68 const std::string& name,
70 const std::vector<std::string>& op_extra_info)
const;
72 bool hasStats()
const;
74 std::vector<std::string> op_types_;
75 std::vector<std::vector<std::string>> op_extra_info_;
77 std::string net_name_;
81 std::vector<ProfDAGStats> time_per_op_total_;
84 CaffeMap<std::string, ProfDAGStats> time_per_op_type_total_;
86 CaffeMap<std::string, ProfDAGStats> times_per_run_per_type_total_;
100 void ReportRunStart();
103 void AddPerOpStartTime(
size_t op_id);
104 void AddPerOpEndTime(
size_t op_id);
105 void AddPerOpAsyncEndTime(
size_t op_id);
111 std::vector<float> op_start_times_run_;
112 std::vector<float> op_end_times_run_;
113 std::vector<float> op_async_end_times_run_;
A simple wrapper around prof_dag's counters.
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
A simple timer object for measuring time.