Caffe2 - C++ API
A deep learning, cross platform ML framework
net_observer_reporter_print.cc
1 #include "caffe2/share/contrib/observers/net_observer_reporter_print.h"
2 
3 #include "caffe2/core/init.h"
4 #include "caffe2/share/contrib/observers/observer_config.h"
5 
6 namespace caffe2 {
7 
8 namespace {
9 bool registerGlobalPerfNetObserverReporter(int* /*pargc*/, char*** /*pargv*/) {
10  ObserverConfig::setReporter(make_unique<NetObserverReporterPrint>());
11  return true;
12 }
13 } // namespace
14 
15 REGISTER_CAFFE2_EARLY_INIT_FUNCTION(
16  registerGlobalPerfNetObserverReporter,
17  &registerGlobalPerfNetObserverReporter,
18  "Caffe2 print net observer reporter");
19 
20 const std::string NetObserverReporterPrint::IDENTIFIER = "Caffe2Observer ";
21 
22 void NetObserverReporterPrint::reportDelay(
23  NetBase* net,
24  std::map<std::string, double>& delays,
25  const char* unit) {
26  CAFFE_ENFORCE(unit != nullptr, "Unit is null");
27  LOG(INFO) << IDENTIFIER << "Net Name - " << net->Name();
28  LOG(INFO) << IDENTIFIER << "Delay Start";
29  for (auto& p : delays) {
30  LOG(INFO) << IDENTIFIER << p.first << " - " << p.second << "\t(" << *unit
31  << ")";
32  }
33  LOG(INFO) << IDENTIFIER << "Delay End";
34 }
35 }
Copyright (c) 2016-present, Facebook, Inc.