From f385228f059f77a450e4c7252359f973cc6d6321 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Tue, 27 Mar 2018 13:35:55 +0800 Subject: [PATCH] Add Paddle Enforce --- paddle/fluid/framework/details/op_handle_base.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/framework/details/op_handle_base.cc b/paddle/fluid/framework/details/op_handle_base.cc index ea97aa5fb2..63affb7054 100644 --- a/paddle/fluid/framework/details/op_handle_base.cc +++ b/paddle/fluid/framework/details/op_handle_base.cc @@ -34,7 +34,7 @@ std::string OpHandleBase::DebugString() const { OpHandleBase::~OpHandleBase() { #ifdef PADDLE_WITH_CUDA for (auto &ev : events_) { - cudaEventDestroy(ev.second); + PADDLE_ENFORCE(cudaEventDestroy(ev.second)); } #endif } @@ -44,8 +44,9 @@ void OpHandleBase::Run(bool use_event) { if (events_.empty() && use_event) { for (auto &p : dev_ctx_) { int dev_id = boost::get(p.first).device; - cudaSetDevice(dev_id); - cudaEventCreateWithFlags(&events_[dev_id], cudaEventDisableTiming); + PADDLE_ENFORCE(cudaSetDevice(dev_id)); + PADDLE_ENFORCE( + cudaEventCreateWithFlags(&events_[dev_id], cudaEventDisableTiming)); } } #else @@ -60,7 +61,7 @@ void OpHandleBase::Run(bool use_event) { int dev_id = boost::get(p.first).device; auto stream = static_cast(p.second)->stream(); - cudaEventRecord(events_.at(dev_id), stream); + PADDLE_ENFORCE(cudaEventRecord(events_.at(dev_id), stream)); } } #endif -- GitLab