diff --git a/paddle/fluid/operators/activation_op_mlu.cc b/paddle/fluid/operators/activation_op_mlu.cc index 72e0e9ceacf48e90919877c9f2667efef6d92fbf..6cfe4738d777b76792bfddba03a2f19e223ebc88 100644 --- a/paddle/fluid/operators/activation_op_mlu.cc +++ b/paddle/fluid/operators/activation_op_mlu.cc @@ -370,7 +370,7 @@ class HardSigmoidGradMLUKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { auto* dout = ctx.Input(framework::GradVarName("Out")); - auto* out = ctx.Input("Out"); + auto* x = ctx.Input("X"); auto* dx = ctx.Output(framework::GradVarName("X")); float slope = ctx.Attr("slope"); float offset = ctx.Attr("offset"); @@ -381,7 +381,7 @@ class HardSigmoidGradMLUKernel : public framework::OpKernel { 1.0f /*sliced_dim useless*/, slope, offset); - MLUCnnlTensorDesc out_desc(*out); + MLUCnnlTensorDesc x_desc(*x); MLUCnnlTensorDesc dout_desc(*dout); MLUCnnlTensorDesc dx_desc(*dx); MLUCnnl::ActiveGrad(ctx, @@ -392,8 +392,8 @@ class HardSigmoidGradMLUKernel : public framework::OpKernel { nullptr, dout_desc.get(), GetBasePtr(dout), - out_desc.get(), - GetBasePtr(out), + x_desc.get(), + GetBasePtr(x), dx_desc.get(), GetBasePtr(dx)); } diff --git a/paddle/fluid/operators/batch_norm_op_mlu.cc b/paddle/fluid/operators/batch_norm_op_mlu.cc index 199a9b95ec3cbc43326e7332d2f02520185c8820..1aa445bda37170c67f402e5b86c81444133a6478 100644 --- a/paddle/fluid/operators/batch_norm_op_mlu.cc +++ b/paddle/fluid/operators/batch_norm_op_mlu.cc @@ -273,7 +273,7 @@ class MLUBatchNormGradOpKernel : public framework::OpKernel { const auto *running_mean = ctx.Input("Mean"); const auto *running_variance = ctx.Input("Variance"); MLUCnnl::FusedBatchNormGrad(ctx, - true /*is_training*/, + false /*is_training*/, transformed_desc.get(), GetBasePtr(&transformed_d_y), transformed_desc.get(), diff --git a/paddle/fluid/operators/conv_transpose_op_mlu.cc b/paddle/fluid/operators/conv_transpose_op_mlu.cc index 322328b1c2e724e07cf2416ef1dee2811dcfda99..f757898886e1fbec9fc1d0756b44bc64d0a0ba20 100644 --- a/paddle/fluid/operators/conv_transpose_op_mlu.cc +++ b/paddle/fluid/operators/conv_transpose_op_mlu.cc @@ -271,26 +271,18 @@ class Conv2DTransposeGradMLUKernel : public framework::OpKernel { data_layout_mlu, ToCnnlDataType(input_grad_tensor.dtype())); - cnnlDataType_t tensor_dtype = ToCnnlDataType(); - cnnlDataType_t dt_onchip = ToCnnlDataType(); - MLUCnnl::Conv2D(ctx, - conv_desc.get(), - tensor_dtype, - dt_onchip, - nullptr /* input_position */, - nullptr /* input_scale */, - nullptr /* input_offset */, - nullptr /* filter_position */, - nullptr /* filter_scale */, - nullptr /* filter_offset */, - output_grad_desc.get(), - GetBasePtr(&output_grad_tensor), - trans_filter_desc.get(), - GetBasePtr(&trans_filter), - nullptr /* bias_desc*/, - nullptr /* bias */, - input_grad_desc.get(), - GetBasePtr(&input_grad_tensor)); + MLUCnnl::ConvolutionForward(ctx, + conv_desc.get(), + nullptr /*alpha*/, + nullptr /*beta*/, + nullptr /*bias_desc*/, + nullptr /*bias_ptr*/, + output_grad_desc.get(), + GetBasePtr(&output_grad_tensor), + trans_filter_desc.get(), + GetBasePtr(&trans_filter), + input_grad_desc.get(), + GetBasePtr(&input_grad_tensor)); if (!channel_last) { // transpose output from NHWC to NCHW const std::vector perm_to_nchw = {0, 3, 1, 2}; diff --git a/paddle/phi/kernels/funcs/activation_functor.h b/paddle/phi/kernels/funcs/activation_functor.h index 542c59bec1b453963f27a73cb0b43d5a7b70b60e..318f2e8b6b3cffa44b913164ff56f85235f1f834 100644 --- a/paddle/phi/kernels/funcs/activation_functor.h +++ b/paddle/phi/kernels/funcs/activation_functor.h @@ -1604,7 +1604,11 @@ struct HardSigmoidGradFunctor : public BaseActivationFunctor { } static constexpr ActBwdOpFwdDeps FwdDeps() { +#ifdef PADDLE_WITH_MLU + return ActBwdOpFwdDeps::kDepX; +#else return ActBwdOpFwdDeps::kDepOut; +#endif } };