mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33957 lots of small preprocessor warning cleanup for windows Test Plan: CI green Reviewed By: malfet, albanD Differential Revision: D20153582 fbshipit-source-id: 18fd61c466fd1f55ededdae4448b3009a9cedc04
39 lines
1013 B
C++
39 lines
1013 B
C++
#include "runcnt_observer.h"
|
|
|
|
namespace caffe2 {
|
|
|
|
RunCountOperatorObserver::RunCountOperatorObserver(
|
|
OperatorBase* op,
|
|
RunCountNetObserver* netObserver)
|
|
: ObserverBase<OperatorBase>(op), netObserver_(netObserver) {
|
|
CAFFE_ENFORCE(netObserver_, "Observers can't operate outside of the net");
|
|
}
|
|
|
|
std::string RunCountNetObserver::debugInfo() {
|
|
#ifdef C10_ANDROID
|
|
// workaround
|
|
int foo = cnt_;
|
|
return "This operator runs " + c10::to_string(foo) + " times.";
|
|
#else
|
|
return "This operator runs " + c10::to_string(cnt_) + " times.";
|
|
#endif
|
|
}
|
|
|
|
void RunCountNetObserver::Start() {}
|
|
|
|
void RunCountNetObserver::Stop() {}
|
|
|
|
void RunCountOperatorObserver::Start() {
|
|
++netObserver_->cnt_;
|
|
}
|
|
void RunCountOperatorObserver::Stop() {}
|
|
|
|
std::unique_ptr<ObserverBase<OperatorBase>> RunCountOperatorObserver::rnnCopy(
|
|
OperatorBase* subject,
|
|
int rnn_order) const {
|
|
return std::unique_ptr<ObserverBase<OperatorBase>>(
|
|
new RunCountOperatorObserver(subject, netObserver_));
|
|
}
|
|
|
|
} // namespace caffe2
|