Fix pow, use fillD instead of broadcast (#31433)

revert-31562-mean
Leo Chen 5 years ago committed by GitHub
parent ecc6e213d7
commit 5fe3d596e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,7 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the Licnse. */
#ifdef PADDLE_WITH_ASCEND_CL
#include <memory>
#include <string>
@ -90,8 +89,8 @@ class PowGradNPUKernel : public framework::OpKernel<T> {
// factor.
Tensor factor_bc_tensor(framework::proto::VarType::FP32);
factor_bc_tensor.mutable_data<float>(x_dims, place);
auto runner_bc = NpuOpRunner("BroadcastTo", {factor_tensor, x_shape},
{factor_bc_tensor}, {});
auto runner_bc = NpuOpRunner("FillD", {factor_tensor}, {factor_bc_tensor},
{{"dims", x_dims}});
runner_bc.Run(stream);
// Step 3: Compute x_power_mul_factor = factor * x.pow(factor-1)
@ -123,5 +122,3 @@ REGISTER_OP_NPU_KERNEL(
pow_grad, ops::PowGradNPUKernel<paddle::platform::NPUDeviceContext, float>,
ops::PowGradNPUKernel<paddle::platform::NPUDeviceContext,
paddle::platform::float16>);
#endif

Loading…
Cancel
Save