Add missing guards to profiling calls (#1374)

* guard remaining profiler calls

* enforce proper usage of profile class
This commit is contained in:
Maik Riechert 2019-10-31 04:28:49 +00:00 committed by Scott McKay
parent aa041026e3
commit ecfbb1bb99
2 changed files with 13 additions and 3 deletions

View file

@ -18,6 +18,7 @@ profiling::Profiler::~Profiler() {}
#endif
::onnxruntime::TimePoint profiling::Profiler::StartTime() const {
ORT_ENFORCE(enabled_);
return std::chrono::high_resolution_clock::now();
}

View file

@ -215,7 +215,10 @@ common::Status InferenceSession::RegisterCustomRegistry(std::shared_ptr<CustomRe
common::Status InferenceSession::Load(std::function<common::Status(std::shared_ptr<Model>&)> loader, const std::string& event_name) {
Status status = Status::OK();
auto tp = session_profiler_.StartTime();
TimePoint tp;
if (session_profiler_.IsEnabled()) {
tp = session_profiler_.StartTime();
}
try {
std::lock_guard<onnxruntime::OrtMutex> l(session_mutex_);
if (is_model_loaded_) { // already loaded
@ -539,7 +542,10 @@ common::Status InferenceSession::InitializeSubgraphSessions(Graph& graph, Sessio
common::Status InferenceSession::Initialize() {
Status status = Status::OK();
auto tp = session_profiler_.StartTime();
TimePoint tp;
if (session_profiler_.IsEnabled()) {
tp = session_profiler_.StartTime();
}
try {
LOGS(*session_logger_, INFO) << "Initializing session.";
@ -775,7 +781,10 @@ common::Status InferenceSession::ValidateOutputs(const std::vector<std::string>&
Status InferenceSession::Run(const RunOptions& run_options, const std::vector<std::string>& feed_names,
const std::vector<OrtValue>& feeds, const std::vector<std::string>& output_names,
std::vector<OrtValue>* p_fetches) {
auto tp = session_profiler_.StartTime();
TimePoint tp;
if (session_profiler_.IsEnabled()) {
tp = session_profiler_.StartTime();
}
Status retval = Status::OK();
try {