Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
Zha0q1 committed Jun 25, 2019
1 parent ba22dda commit 2db1243
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/profiler/custom_op_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ class CustomOpProfiler {
*/
void OnCustomBegin(const std::string& op_type) {
profiler::Profiler *profiler = profiler::Profiler::Get();
if (!profiler->IsProfiling(profiler::Profiler::kImperative)) {
return;
}
const Tid tid = std::this_thread::get_id();
const std::string task_name = MakePythonCodeName(op_type);
std::lock_guard<std::mutex> lock(mutex_);
tid_to_op_type_[tid] = op_type;
if (!profiler->IsProfiling(profiler::Profiler::kImperative)) {

This comment has been minimized.

Copy link
@anirudh2290

anirudh2290 Jun 25, 2019

Member

this causes get_id overhead for custom op even when not profiling

return;
}
tasks_[tid] = std::make_unique<ProfileTask>(task_name.c_str(), &custom_op_domain);
tasks_[tid]->start();
}
Expand All @@ -72,13 +72,13 @@ class CustomOpProfiler {
void OnCustomEnd() {
const Tid tid = std::this_thread::get_id();
std::lock_guard<std::mutex> lock(mutex_);
tid_to_op_type_.erase(tid);
// this can happen if we are not profiling
if (tasks_.find(tid) == tasks_.end()) {
return;
}
tasks_[tid]->stop();
tasks_.erase(tid);
tid_to_op_type_.erase(tid);
}

/*!
Expand Down
1 change: 0 additions & 1 deletion tests/python/unittest/test_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ def create_operator(self, ctx, shapes, dtypes):
mx.nd.waitall()
profiler.dump(False)
debug_str = profiler.dumps(format = 'json')
print(debug_str)
target_dict = json.loads(debug_str)
'''
We are calling _plus_scalar within MyAdd1 and MyAdd2 and outside both the custom
Expand Down

0 comments on commit 2db1243

Please sign in to comment.