1 #ifndef CAFFE2_CONTRIB_OBSERVERS_TIME_OBSERVER_H_ 2 #define CAFFE2_CONTRIB_OBSERVERS_TIME_OBSERVER_H_ 4 #include <unordered_map> 6 #include "caffe2/core/common.h" 7 #include "caffe2/core/net.h" 8 #include "caffe2/core/observer.h" 9 #include "caffe2/core/operator.h" 10 #include "caffe2/core/timer.h" 11 #include "caffe2/observers/operator_attaching_net_observer.h" 20 inline float average_time()
const {
21 return total_time_ / iterations_;
26 float start_time_ = 0.0f;
27 float total_time_ = 0.0f;
39 std::unique_ptr<ObserverBase<OperatorBase>> rnnCopy(
41 int rnn_order)
const override;
44 void Start()
override;
57 float average_time_children()
const {
59 for (
const auto* observer : operator_observers_) {
60 sum += observer->average_time();
62 return sum / subject_->GetOperators().size();
66 void Start()
override;
72 #endif // CAFFE2_CONTRIB_OBSERVERS_TIME_OBSERVER_H_ Use this to implement a Observer using the Observer Pattern template.
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
A simple timer object for measuring time.