未验证 提交 5169197f 编写于 作者: Y Yuan Shuai 提交者: GitHub

[LITE][PROFILE] Fix unit test segfault when profiler on (#3744)


* [LITE][PROFILER] Fix unit test segfault when profiler on. test=develop
上级 b7064517
......@@ -70,6 +70,10 @@ class KernelBase {
ch->cl_event = event_;
#endif
}
virtual void SetIsKernelTest(bool is_kernel_test) {
is_kernel_test_ = is_kernel_test;
}
#endif
void Launch() {
......@@ -94,16 +98,23 @@ class KernelBase {
#if defined(LITE_WITH_MLU)
WorkSpace::Global_MLU().AllocReset();
#endif
#ifdef LITE_WITH_PROFILE
profiler_->StopTiming(profile::Type::kCreate, profile_id_, ctx_.get());
profiler_->StartTiming(profile::Type::kDispatch, profile_id_, ctx_.get());
if (!is_kernel_test_) {
profiler_->StopTiming(profile::Type::kCreate, profile_id_, ctx_.get());
profiler_->StartTiming(profile::Type::kDispatch, profile_id_, ctx_.get());
}
Run();
if (is_first_epoch_for_profiler_) {
if (is_first_epoch_for_profiler_ && (!is_kernel_test_)) {
SetProfileRuntimeKernelInfo(profiler_->GetOpCharacter(profile_id_));
is_first_epoch_for_profiler_ = false;
}
profiler_->StopTiming(profile::Type::kDispatch, profile_id_, ctx_.get());
if (!is_kernel_test_) {
profiler_->StopTiming(profile::Type::kDispatch, profile_id_, ctx_.get());
}
#else
Run();
......@@ -197,11 +208,11 @@ class KernelBase {
profile::Profiler* profiler_{nullptr};
int profile_id_{-1};
bool is_first_epoch_for_profiler_{true};
#endif
bool is_kernel_test_{true};
#ifdef LITE_WITH_OPENCL
cl::Event event_;
#endif
#endif
};
// Light-weight kernel implementation.
......
......@@ -302,6 +302,7 @@ void Instruction::Run() {
#ifdef LITE_WITH_PROFILE
if (first_epoch_for_profiler_) {
kernel_->SetIsKernelTest(false);
SetProfileRuntimeOpInfo(profiler_->GetOpCharacter(profile_id_));
first_epoch_for_profiler_ = false;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册