未验证 提交 493825a5 编写于 作者: P Piotr Paturej 提交者: GitHub

[PHI] Migrate elementwise_sub kernel (#48611)

* Add migrations

* Fix build errors

* Remove elementwise_mul from migration
上级 e8edbb09
// 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<float, dnnl::algorithm::binary_sub>,
ops::EltwiseMKLDNNKernel<paddle::platform::bfloat16,
dnnl::algorithm::binary_sub>,
ops::EltwiseMKLDNNKernel<int8_t, dnnl::algorithm::binary_sub>,
ops::EltwiseMKLDNNKernel<uint8_t, dnnl::algorithm::binary_sub>)
...@@ -416,6 +416,15 @@ PD_REGISTER_KERNEL(elementwise_pow, ...@@ -416,6 +416,15 @@ PD_REGISTER_KERNEL(elementwise_pow,
#endif #endif
#if defined PADDLE_WITH_MKLDNN #if defined PADDLE_WITH_MKLDNN
PD_REGISTER_KERNEL(subtract,
OneDNN,
ONEDNN,
phi::SubtractKernel,
float,
phi::dtype::bfloat16,
int8_t,
uint8_t) {}
PD_REGISTER_KERNEL( PD_REGISTER_KERNEL(
divide, OneDNN, ONEDNN, phi::DivideKernel, float, phi::dtype::bfloat16) {} divide, OneDNN, ONEDNN, phi::DivideKernel, float, phi::dtype::bfloat16) {}
#endif #endif
...@@ -133,10 +133,20 @@ void ElementwiseKernel(const OneDNNContext& dev_ctx, ...@@ -133,10 +133,20 @@ void ElementwiseKernel(const OneDNNContext& dev_ctx,
ElementwiseKernel<T, algorithm>(dev_ctx, x, y, axis, out); \ ElementwiseKernel<T, algorithm>(dev_ctx, x, y, axis, out); \
} }
DEFINE_ONEDNN_ELEMENTWISE_KERNEL(Subtract, dnnl::algorithm::binary_sub)
DEFINE_ONEDNN_ELEMENTWISE_KERNEL(Divide, dnnl::algorithm::binary_div) DEFINE_ONEDNN_ELEMENTWISE_KERNEL(Divide, dnnl::algorithm::binary_div)
} // namespace phi } // namespace phi
PD_REGISTER_KERNEL(subtract_raw,
OneDNN,
ONEDNN,
phi::SubtractRawKernel,
float,
phi::dtype::bfloat16,
int8_t,
uint8_t) {}
PD_REGISTER_KERNEL(divide_raw, PD_REGISTER_KERNEL(divide_raw,
OneDNN, OneDNN,
ONEDNN, ONEDNN,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册