Skip to content

Commit 5fe3d59

Browse files
authored
Fix pow, use fillD instead of broadcast (#31433)
1 parent ecc6e21 commit 5fe3d59

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

paddle/fluid/operators/activation_op_npu.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the Licnse. */
1414

15-
#ifdef PADDLE_WITH_ASCEND_CL
1615
#include <memory>
1716
#include <string>
1817

@@ -90,8 +89,8 @@ class PowGradNPUKernel : public framework::OpKernel<T> {
9089
// factor.
9190
Tensor factor_bc_tensor(framework::proto::VarType::FP32);
9291
factor_bc_tensor.mutable_data<float>(x_dims, place);
93-
auto runner_bc = NpuOpRunner("BroadcastTo", {factor_tensor, x_shape},
94-
{factor_bc_tensor}, {});
92+
auto runner_bc = NpuOpRunner("FillD", {factor_tensor}, {factor_bc_tensor},
93+
{{"dims", x_dims}});
9594
runner_bc.Run(stream);
9695

9796
// Step 3: Compute x_power_mul_factor = factor * x.pow(factor-1)
@@ -123,5 +122,3 @@ REGISTER_OP_NPU_KERNEL(
123122
pow_grad, ops::PowGradNPUKernel<paddle::platform::NPUDeviceContext, float>,
124123
ops::PowGradNPUKernel<paddle::platform::NPUDeviceContext,
125124
paddle::platform::float16>);
126-
127-
#endif

0 commit comments

Comments
 (0)