diff --git a/paddle/fluid/operators/activation_op_npu.cc b/paddle/fluid/operators/activation_op_npu.cc index 24ebc00c4841c9364959b112ab3490884efe88e4..02ebdefc38cec2802d083d254c3f179f13a3ae03 100644 --- a/paddle/fluid/operators/activation_op_npu.cc +++ b/paddle/fluid/operators/activation_op_npu.cc @@ -73,24 +73,19 @@ class PowGradNPUKernel : public framework::OpKernel { runner_pow.Run(stream); // Step 2: Construct a broadcast factor, which has the same shape with x. - // 2.1 Get the shape of x - Tensor x_shape(framework::proto::VarType::INT32); - x_shape.mutable_data({x_dims.size()}, place); - TensorFromVector(framework::vectorize(x_dims), - ctx.device_context(), &x_shape); - // 2.2 Get a factor tensor with shape [1]. + // 2.1 Get a factor tensor with shape [1]. Tensor factor_tensor(framework::proto::VarType::FP32); factor_tensor.mutable_data({1}, place); TensorFromVector(std::vector{factor}, ctx.device_context(), &factor_tensor); - // 2.3 Get the factor which has the shape with x and the same value with + // 2.2 Get the factor which has the shape with x and the same value with // factor. Tensor factor_bc_tensor(framework::proto::VarType::FP32); factor_bc_tensor.mutable_data(x_dims, place); auto runner_bc = NpuOpRunner("FillD", {factor_tensor}, {factor_bc_tensor}, - {{"dims", x_dims}}); + {{"dims", framework::vectorize(x_dims)}}); runner_bc.Run(stream); // Step 3: Compute x_power_mul_factor = factor * x.pow(factor-1)