From 493825a5d3ce7b820744dfdd6df2f2acb958bebb Mon Sep 17 00:00:00 2001 From: Piotr Paturej <48731682+piotrekobi@users.noreply.github.com> Date: Fri, 2 Dec 2022 10:48:52 +0100 Subject: [PATCH] [PHI] Migrate elementwise_sub kernel (#48611) * Add migrations * Fix build errors * Remove elementwise_mul from migration --- .../mkldnn/elementwise_sub_mkldnn_op.cc | 27 ------------------- paddle/phi/kernels/elementwise_kernel.cc | 9 +++++++ .../phi/kernels/onednn/elementwise_kernel.cc | 10 +++++++ 3 files changed, 19 insertions(+), 27 deletions(-) delete mode 100644 paddle/fluid/operators/elementwise/mkldnn/elementwise_sub_mkldnn_op.cc diff --git a/paddle/fluid/operators/elementwise/mkldnn/elementwise_sub_mkldnn_op.cc b/paddle/fluid/operators/elementwise/mkldnn/elementwise_sub_mkldnn_op.cc deleted file mode 100644 index 91660b79b0..0000000000 --- a/paddle/fluid/operators/elementwise/mkldnn/elementwise_sub_mkldnn_op.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "paddle/fluid/operators/elementwise/mkldnn/elementwise_mkldnn_op.h" - -namespace ops = paddle::operators; - -REGISTER_OP_KERNEL( - elementwise_sub, - MKLDNN, - paddle::platform::CPUPlace, - ops::EltwiseMKLDNNKernel, - ops::EltwiseMKLDNNKernel, - ops::EltwiseMKLDNNKernel, - ops::EltwiseMKLDNNKernel) diff --git a/paddle/phi/kernels/elementwise_kernel.cc b/paddle/phi/kernels/elementwise_kernel.cc index c0b99b8ddf..d4ffd49b5f 100644 --- a/paddle/phi/kernels/elementwise_kernel.cc +++ b/paddle/phi/kernels/elementwise_kernel.cc @@ -416,6 +416,15 @@ PD_REGISTER_KERNEL(elementwise_pow, #endif #if defined PADDLE_WITH_MKLDNN +PD_REGISTER_KERNEL(subtract, + OneDNN, + ONEDNN, + phi::SubtractKernel, + float, + phi::dtype::bfloat16, + int8_t, + uint8_t) {} + PD_REGISTER_KERNEL( divide, OneDNN, ONEDNN, phi::DivideKernel, float, phi::dtype::bfloat16) {} #endif diff --git a/paddle/phi/kernels/onednn/elementwise_kernel.cc b/paddle/phi/kernels/onednn/elementwise_kernel.cc index e103f23df0..29d527a523 100644 --- a/paddle/phi/kernels/onednn/elementwise_kernel.cc +++ b/paddle/phi/kernels/onednn/elementwise_kernel.cc @@ -133,10 +133,20 @@ void ElementwiseKernel(const OneDNNContext& dev_ctx, ElementwiseKernel(dev_ctx, x, y, axis, out); \ } +DEFINE_ONEDNN_ELEMENTWISE_KERNEL(Subtract, dnnl::algorithm::binary_sub) DEFINE_ONEDNN_ELEMENTWISE_KERNEL(Divide, dnnl::algorithm::binary_div) } // namespace phi +PD_REGISTER_KERNEL(subtract_raw, + OneDNN, + ONEDNN, + phi::SubtractRawKernel, + float, + phi::dtype::bfloat16, + int8_t, + uint8_t) {} + PD_REGISTER_KERNEL(divide_raw, OneDNN, ONEDNN, -- GitLab