提交 904a762c 编写于 作者: Y yukavio

fix generate_proposals and affine grid error info

上级 af1568e6
...@@ -26,11 +26,12 @@ template <typename T> ...@@ -26,11 +26,12 @@ template <typename T>
class CUDNNAffineGridOpKernel : public framework::OpKernel<T> { class CUDNNAffineGridOpKernel : public framework::OpKernel<T> {
public: public:
void Compute(const framework::ExecutionContext& ctx) const override { void Compute(const framework::ExecutionContext& ctx) const override {
PADDLE_ENFORCE_EQ(platform::is_gpu_place(ctx.GetPlace()), true, PADDLE_ENFORCE_EQ(
platform::errors::InvalidArgument("Only " platform::is_gpu_place(ctx.GetPlace()), true,
"support for CUDAPlace.Please switch " platform::errors::InvalidArgument("Only "
"your context from CPUPlace to " "support for CUDAPlace.Please switch "
"CUDAPlace or update your cudnn."); "your context from CPUPlace to "
"CUDAPlace or update your cudnn."));
auto& dev_ctx = ctx.template device_context<platform::CUDADeviceContext>(); auto& dev_ctx = ctx.template device_context<platform::CUDADeviceContext>();
auto handle = dev_ctx.cudnn_handle(); auto handle = dev_ctx.cudnn_handle();
auto* theta = ctx.Input<Tensor>("Theta"); auto* theta = ctx.Input<Tensor>("Theta");
...@@ -59,10 +60,11 @@ class CUDNNAffineGridOpKernel : public framework::OpKernel<T> { ...@@ -59,10 +60,11 @@ class CUDNNAffineGridOpKernel : public framework::OpKernel<T> {
cudnnSpatialTransformerDescriptor_t cudnn_st_desc = cudnnSpatialTransformerDescriptor_t cudnn_st_desc =
st_desc.descriptor<T>(4, h_size_data); st_desc.descriptor<T>(4, h_size_data);
PADDLE_ENFORCE_EQ(platform::dynload::cudnnSpatialTfGridGeneratorForward( PADDLE_ENFORCE_EQ(
handle, cudnn_st_desc, theta_data, output_data), platform::dynload::cudnnSpatialTfGridGeneratorForward(
handle, cudnn_st_desc, theta_data, output_data),
true, platform::errors::Fatal("Some errors has occurred " true, platform::errors::Fatal("Some errors has occurred "
"during forward computation in cudnn.")); "during forward computation in cudnn."));
} }
}; };
...@@ -71,10 +73,11 @@ class CUDNNAffineGridGradOpKernel : public framework::OpKernel<T> { ...@@ -71,10 +73,11 @@ class CUDNNAffineGridGradOpKernel : public framework::OpKernel<T> {
public: public:
void Compute(const framework::ExecutionContext& ctx) const override { void Compute(const framework::ExecutionContext& ctx) const override {
PADDLE_ENFORCE_EQ(platform::is_gpu_place(ctx.GetPlace()), true, PADDLE_ENFORCE_EQ(platform::is_gpu_place(ctx.GetPlace()), true,
platform::errors::InvalidArgument("Only " platform::errors::InvalidArgument(
"support for CUDAPlace. Please switch " "Only "
"your context from CPUPlace to " "support for CUDAPlace. Please switch "
"CUDAPlace or update your cudnn."); "your context from CPUPlace to "
"CUDAPlace or update your cudnn."));
auto& dev_ctx = ctx.template device_context<platform::CUDADeviceContext>(); auto& dev_ctx = ctx.template device_context<platform::CUDADeviceContext>();
auto handle = dev_ctx.cudnn_handle(); auto handle = dev_ctx.cudnn_handle();
auto output_grad = ctx.Input<Tensor>(framework::GradVarName("Output")); auto output_grad = ctx.Input<Tensor>(framework::GradVarName("Output"));
...@@ -103,9 +106,11 @@ class CUDNNAffineGridGradOpKernel : public framework::OpKernel<T> { ...@@ -103,9 +106,11 @@ class CUDNNAffineGridGradOpKernel : public framework::OpKernel<T> {
const T* output_grad_data = output_grad->data<T>(); const T* output_grad_data = output_grad->data<T>();
T* theta_grad_data = theta_grad->mutable_data<T>(ctx.GetPlace()); T* theta_grad_data = theta_grad->mutable_data<T>(ctx.GetPlace());
PADDLE_ENFORCE_EQ(platform::dynload::cudnnSpatialTfGridGeneratorBackward( PADDLE_ENFORCE_EQ(
handle, cudnn_st_desc, output_grad_data, theta_grad_data), platform::dynload::cudnnSpatialTfGridGeneratorBackward(
true, "Some errors " handle, cudnn_st_desc, output_grad_data, theta_grad_data),
true,
"Some errors "
"has occurred during forward computation in cudnn;"); "has occurred during forward computation in cudnn;");
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册