From 4ac2729c87cb6d270eb399cac5ac2d548752d827 Mon Sep 17 00:00:00 2001 From: Yibing Liu Date: Sun, 8 Mar 2020 23:24:04 +0800 Subject: [PATCH] Fix the get of attr pad_value under dtype float16 in pad2d op (#22909) test=release/1.7 --- paddle/fluid/operators/pad2d_op.cc | 2 +- paddle/fluid/operators/pad2d_op.cu | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/pad2d_op.cc b/paddle/fluid/operators/pad2d_op.cc index 9495e70758..3ae006a60c 100644 --- a/paddle/fluid/operators/pad2d_op.cc +++ b/paddle/fluid/operators/pad2d_op.cc @@ -345,7 +345,7 @@ class Pad2dCPUKernel : public framework::OpKernel { GetPaddings(pads, context); auto mode = context.Attr("mode"); auto data_format = context.Attr("data_format"); - T value = context.Attr("pad_value"); + T value = static_cast(context.Attr("pad_value")); auto* x = context.Input("X"); auto in_dims = x->dims(); diff --git a/paddle/fluid/operators/pad2d_op.cu b/paddle/fluid/operators/pad2d_op.cu index f88b195b64..c05d778fb2 100644 --- a/paddle/fluid/operators/pad2d_op.cu +++ b/paddle/fluid/operators/pad2d_op.cu @@ -314,7 +314,7 @@ class Pad2dCUDAKernel : public framework::OpKernel { GetPaddings(pads, context); auto mode = context.Attr("mode"); auto data_format = context.Attr("data_format"); - T value = context.Attr("pad_value"); + T value = static_cast(context.Attr("pad_value")); auto* x = context.Input("X"); auto in_dims = x->dims(); -- GitLab