Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
051add42
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
051add42
编写于
5月 19, 2023
作者:
Z
zhangyuqin1998
提交者:
GitHub
5月 19, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move raw kernel to legacy (#53830)
上级
4a4ffe9a
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
439 addition
and
137 deletion
+439
-137
paddle/phi/kernels/cpu/elementwise_divide_kernel.cc
paddle/phi/kernels/cpu/elementwise_divide_kernel.cc
+8
-9
paddle/phi/kernels/cpu/elementwise_multiply_kernel.cc
paddle/phi/kernels/cpu/elementwise_multiply_kernel.cc
+23
-4
paddle/phi/kernels/elementwise_divide_kernel.h
paddle/phi/kernels/elementwise_divide_kernel.h
+0
-7
paddle/phi/kernels/elementwise_kernel.cc
paddle/phi/kernels/elementwise_kernel.cc
+0
-79
paddle/phi/kernels/elementwise_multiply_kernel.h
paddle/phi/kernels/elementwise_multiply_kernel.h
+0
-7
paddle/phi/kernels/kps/elementwise_divide_kernel.cu
paddle/phi/kernels/kps/elementwise_divide_kernel.cu
+19
-5
paddle/phi/kernels/kps/elementwise_multiply_kernel.cu
paddle/phi/kernels/kps/elementwise_multiply_kernel.cu
+19
-6
paddle/phi/kernels/legacy/cpu/elementwise_divide_kernel.cc
paddle/phi/kernels/legacy/cpu/elementwise_divide_kernel.cc
+66
-0
paddle/phi/kernels/legacy/cpu/elementwise_multiply_kernel.cc
paddle/phi/kernels/legacy/cpu/elementwise_multiply_kernel.cc
+47
-0
paddle/phi/kernels/legacy/elementwise_multipy_kernel.h
paddle/phi/kernels/legacy/elementwise_multipy_kernel.h
+28
-0
paddle/phi/kernels/legacy/kps/elementwise_divide_kernel.cu
paddle/phi/kernels/legacy/kps/elementwise_divide_kernel.cu
+52
-0
paddle/phi/kernels/legacy/kps/elementwise_multiply_kernel.cu
paddle/phi/kernels/legacy/kps/elementwise_multiply_kernel.cu
+54
-0
paddle/phi/kernels/legacy/xpu/elementwise_divide_kernel.cc
paddle/phi/kernels/legacy/xpu/elementwise_divide_kernel.cc
+53
-0
paddle/phi/kernels/legacy/xpu/elementwise_multiply_kernel.cc
paddle/phi/kernels/legacy/xpu/elementwise_multiply_kernel.cc
+55
-0
paddle/phi/kernels/selected_rows/elementwise_multiply_kernel.h
...e/phi/kernels/selected_rows/elementwise_multiply_kernel.h
+1
-0
paddle/phi/kernels/xpu/elementwise_divide_kernel.cc
paddle/phi/kernels/xpu/elementwise_divide_kernel.cc
+7
-12
paddle/phi/kernels/xpu/elementwise_multiply_kernel.cc
paddle/phi/kernels/xpu/elementwise_multiply_kernel.cc
+7
-8
未找到文件。
paddle/phi/kernels/cpu/elementwise_divide_kernel.cc
浏览文件 @
051add42
...
...
@@ -23,11 +23,10 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
DivideRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
int
axis
,
DenseTensor
*
out
)
{
void
DivideKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
DenseTensor
*
out
)
{
// allocate memory for out
dev_ctx
.
template
Alloc
<
T
>(
out
);
if
(
x
.
dims
()
==
y
.
dims
()
&&
std
::
is_floating_point
<
T
>::
value
)
{
...
...
@@ -38,10 +37,10 @@ void DivideRawKernel(const Context& dev_ctx,
auto
y_dims
=
y
.
dims
();
if
(
x_dims
.
size
()
>=
y_dims
.
size
())
{
funcs
::
ElementwiseCompute
<
funcs
::
DivideFunctor
<
T
>
,
T
>
(
dev_ctx
,
x
,
y
,
funcs
::
DivideFunctor
<
T
>
(),
out
,
axis
);
dev_ctx
,
x
,
y
,
funcs
::
DivideFunctor
<
T
>
(),
out
,
-
1
);
}
else
{
funcs
::
ElementwiseCompute
<
funcs
::
InverseDivideFunctor
<
T
>
,
T
>
(
dev_ctx
,
x
,
y
,
funcs
::
InverseDivideFunctor
<
T
>
(),
out
,
axis
);
dev_ctx
,
x
,
y
,
funcs
::
InverseDivideFunctor
<
T
>
(),
out
,
-
1
);
}
}
}
...
...
@@ -54,10 +53,10 @@ using complex128 = ::phi::dtype::complex<double>;
// NOTE(chenweihang): using bfloat16 will cause redefine with xpu bfloat16
// using bfloat16 = ::phi::dtype::bfloat16;
PD_REGISTER_KERNEL
(
divide
_raw
,
PD_REGISTER_KERNEL
(
divide
,
CPU
,
ALL_LAYOUT
,
phi
::
Divide
Raw
Kernel
,
phi
::
DivideKernel
,
float
,
double
,
int
,
...
...
paddle/phi/kernels/cpu/elementwise_multiply_kernel.cc
浏览文件 @
051add42
...
...
@@ -22,8 +22,27 @@
namespace
phi
{
// Create the definition of Multiply
DEFINE_CPU_ELEMENTWISE_OP
(
Multiply
)
template
<
typename
T
,
typename
Context
>
void
MultiplyKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
DenseTensor
*
out
)
{
dev_ctx
.
template
Alloc
<
T
>(
out
);
if
(
x
.
dims
()
==
y
.
dims
())
{
SameDimsElementwiseCompute
<
SameDimsMultiplyFunctor
<
CPUContext
,
T
>>
()(
dev_ctx
,
x
,
y
,
out
);
}
else
{
auto
x_dims
=
x
.
dims
();
auto
y_dims
=
y
.
dims
();
if
(
x_dims
.
size
()
>=
y_dims
.
size
())
{
funcs
::
ElementwiseCompute
<
funcs
::
MultiplyFunctor
<
T
>
,
T
>
(
dev_ctx
,
x
,
y
,
funcs
::
MultiplyFunctor
<
T
>
(),
out
,
-
1
);
}
else
{
funcs
::
ElementwiseCompute
<
funcs
::
InverseMultiplyFunctor
<
T
>
,
T
>
(
dev_ctx
,
x
,
y
,
funcs
::
InverseMultiplyFunctor
<
T
>
(),
out
,
-
1
);
}
}
}
}
// namespace phi
...
...
@@ -33,10 +52,10 @@ using complex128 = ::phi::dtype::complex<double>;
// NOTE(chenweihang): using bfloat16 will cause redefine with xpu bfloat16
// using bfloat16 = ::phi::dtype::bfloat16;
PD_REGISTER_KERNEL
(
multiply
_raw
,
PD_REGISTER_KERNEL
(
multiply
,
CPU
,
ALL_LAYOUT
,
phi
::
Multiply
Raw
Kernel
,
phi
::
MultiplyKernel
,
float
,
double
,
int
,
...
...
paddle/phi/kernels/elementwise_divide_kernel.h
浏览文件 @
051add42
...
...
@@ -19,13 +19,6 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
DivideRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
int
axis
,
DenseTensor
*
out
);
template
<
typename
T
,
typename
Context
>
void
DivideKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
...
...
paddle/phi/kernels/elementwise_kernel.cc
浏览文件 @
051add42
...
...
@@ -23,22 +23,6 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
DivideKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
DenseTensor
*
out
)
{
DivideRawKernel
<
T
,
Context
>
(
dev_ctx
,
x
,
y
,
-
1
,
out
);
}
template
<
typename
T
,
typename
Context
>
void
MultiplyKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
DenseTensor
*
out
)
{
MultiplyRawKernel
<
T
,
Context
>
(
dev_ctx
,
x
,
y
,
-
1
,
out
);
}
template
<
typename
T
,
typename
Context
>
void
AddKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
...
...
@@ -85,35 +69,9 @@ PD_REGISTER_KERNEL(add,
complex64
,
complex128
)
{}
PD_REGISTER_KERNEL
(
multiply
,
CPU
,
ALL_LAYOUT
,
phi
::
MultiplyKernel
,
float
,
double
,
int
,
int64_t
,
bool
,
complex64
,
complex128
,
phi
::
dtype
::
bfloat16
)
{}
PD_REGISTER_KERNEL
(
divide
,
CPU
,
ALL_LAYOUT
,
phi
::
DivideKernel
,
float
,
double
,
int
,
int64_t
,
complex64
,
complex128
)
{}
#if defined(PADDLE_WITH_XPU_KP) && defined(PADDLE_WITH_XPU)
PD_REGISTER_KERNEL
(
subtract
,
KPS
,
ALL_LAYOUT
,
phi
::
SubtractKernel
,
float
)
{}
PD_REGISTER_KERNEL
(
add
,
KPS
,
ALL_LAYOUT
,
phi
::
AddKernel
,
float
)
{}
PD_REGISTER_KERNEL
(
multiply
,
KPS
,
ALL_LAYOUT
,
phi
::
MultiplyKernel
,
float
)
{}
PD_REGISTER_KERNEL
(
divide
,
KPS
,
ALL_LAYOUT
,
phi
::
DivideKernel
,
float
)
{}
#elif defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_KERNEL
(
subtract
,
KPS
,
...
...
@@ -142,39 +100,10 @@ PD_REGISTER_KERNEL(add,
phi
::
dtype
::
bfloat16
,
complex64
,
complex128
)
{}
PD_REGISTER_KERNEL
(
multiply
,
KPS
,
ALL_LAYOUT
,
phi
::
MultiplyKernel
,
float
,
double
,
int
,
int64_t
,
bool
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
,
complex64
,
complex128
)
{}
PD_REGISTER_KERNEL
(
divide
,
KPS
,
ALL_LAYOUT
,
phi
::
DivideKernel
,
float
,
double
,
int
,
int64_t
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
,
complex64
,
complex128
)
{}
#endif
#if defined(PADDLE_WITH_XPU) && !defined(PADDLE_WITH_XPU_KP)
PD_REGISTER_KERNEL
(
divide
,
XPU
,
ALL_LAYOUT
,
phi
::
DivideKernel
,
phi
::
dtype
::
float16
,
float
)
{}
PD_REGISTER_KERNEL
(
add
,
XPU
,
ALL_LAYOUT
,
...
...
@@ -184,14 +113,6 @@ PD_REGISTER_KERNEL(add,
int
,
int64_t
)
{}
PD_REGISTER_KERNEL
(
multiply
,
XPU
,
ALL_LAYOUT
,
phi
::
MultiplyKernel
,
phi
::
dtype
::
float16
,
float
,
int
,
int64_t
)
{}
PD_REGISTER_KERNEL
(
subtract
,
XPU
,
ALL_LAYOUT
,
...
...
paddle/phi/kernels/elementwise_multiply_kernel.h
浏览文件 @
051add42
...
...
@@ -19,13 +19,6 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
MultiplyRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
int
axis
,
DenseTensor
*
out
);
template
<
typename
T
,
typename
Context
>
void
MultiplyKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
...
...
paddle/phi/kernels/kps/elementwise_divide_kernel.cu
浏览文件 @
051add42
...
...
@@ -22,13 +22,27 @@
namespace
phi
{
// Create the definition of Divide
DEFINE_CUDA_ELEMENTWISE_OP
(
Divide
)
template
<
typename
T
,
typename
Context
>
void
DivideKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
DenseTensor
*
out
)
{
std
::
vector
<
const
DenseTensor
*>
inputs
;
inputs
.
reserve
(
2
);
std
::
vector
<
DenseTensor
*>
outputs
;
outputs
.
reserve
(
1
);
inputs
.
emplace_back
(
&
x
);
inputs
.
emplace_back
(
&
y
);
outputs
.
emplace_back
(
out
);
dev_ctx
.
template
Alloc
<
T
>(
out
);
funcs
::
BroadcastKernel
<
T
>
(
dev_ctx
,
inputs
,
&
outputs
,
funcs
::
DivideFunctor
<
T
>
(),
-
1
);
}
}
// namespace phi
#ifdef PADDLE_WITH_XPU_KP
PD_REGISTER_KERNEL
(
divide
_raw
,
KPS
,
ALL_LAYOUT
,
phi
::
DivideRaw
Kernel
,
float
)
{}
PD_REGISTER_KERNEL
(
divide
,
KPS
,
ALL_LAYOUT
,
phi
::
Divide
Kernel
,
float
)
{}
#else
using
float16
=
phi
::
dtype
::
float16
;
...
...
@@ -36,10 +50,10 @@ using bfloat16 = phi::dtype::bfloat16;
using
complex64
=
::
phi
::
dtype
::
complex
<
float
>
;
using
complex128
=
::
phi
::
dtype
::
complex
<
double
>
;
PD_REGISTER_KERNEL
(
divide
_raw
,
PD_REGISTER_KERNEL
(
divide
,
KPS
,
ALL_LAYOUT
,
phi
::
Divide
Raw
Kernel
,
phi
::
DivideKernel
,
float
,
double
,
int
,
...
...
paddle/phi/kernels/kps/elementwise_multiply_kernel.cu
浏览文件 @
051add42
...
...
@@ -22,14 +22,27 @@
namespace
phi
{
// Create the definition of Multiply
DEFINE_CUDA_ELEMENTWISE_OP
(
Multiply
)
template
<
typename
T
,
typename
Context
>
void
MultiplyKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
DenseTensor
*
out
)
{
std
::
vector
<
const
DenseTensor
*>
inputs
;
inputs
.
reserve
(
2
);
std
::
vector
<
DenseTensor
*>
outputs
;
outputs
.
reserve
(
1
);
inputs
.
emplace_back
(
&
x
);
inputs
.
emplace_back
(
&
y
);
outputs
.
emplace_back
(
out
);
dev_ctx
.
template
Alloc
<
T
>(
out
);
funcs
::
BroadcastKernel
<
T
>
(
dev_ctx
,
inputs
,
&
outputs
,
funcs
::
MultiplyFunctor
<
T
>
(),
-
1
);
}
}
// namespace phi
#ifdef PADDLE_WITH_XPU_KP
PD_REGISTER_KERNEL
(
multiply_raw
,
KPS
,
ALL_LAYOUT
,
phi
::
MultiplyRawKernel
,
float
)
{}
PD_REGISTER_KERNEL
(
multiply
,
KPS
,
ALL_LAYOUT
,
phi
::
MultiplyKernel
,
float
)
{}
#else
using
float16
=
phi
::
dtype
::
float16
;
...
...
@@ -37,10 +50,10 @@ using bfloat16 = phi::dtype::bfloat16;
using
complex64
=
::
phi
::
dtype
::
complex
<
float
>
;
using
complex128
=
::
phi
::
dtype
::
complex
<
double
>
;
PD_REGISTER_KERNEL
(
multiply
_raw
,
PD_REGISTER_KERNEL
(
multiply
,
KPS
,
ALL_LAYOUT
,
phi
::
Multiply
Raw
Kernel
,
phi
::
MultiplyKernel
,
float
,
double
,
int
,
...
...
paddle/phi/kernels/legacy/cpu/elementwise_divide_kernel.cc
0 → 100644
浏览文件 @
051add42
// Copyright (c) 2023 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/phi/api/ext/dispatch.h"
#include "paddle/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/common/bfloat16.h"
#include "paddle/phi/common/complex.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/cpu/elementwise.h"
#include "paddle/phi/kernels/impl/elementwise_kernel_impl.h"
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
DivideRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
int
axis
,
DenseTensor
*
out
)
{
// allocate memory for out
dev_ctx
.
template
Alloc
<
T
>(
out
);
if
(
x
.
dims
()
==
y
.
dims
()
&&
std
::
is_floating_point
<
T
>::
value
)
{
SameDimsElementwiseCompute
<
SameDimsDivideFunctor
<
CPUContext
,
T
>>
()(
dev_ctx
,
x
,
y
,
out
);
}
else
{
auto
x_dims
=
x
.
dims
();
auto
y_dims
=
y
.
dims
();
if
(
x_dims
.
size
()
>=
y_dims
.
size
())
{
funcs
::
ElementwiseCompute
<
funcs
::
DivideFunctor
<
T
>
,
T
>
(
dev_ctx
,
x
,
y
,
funcs
::
DivideFunctor
<
T
>
(),
out
,
axis
);
}
else
{
funcs
::
ElementwiseCompute
<
funcs
::
InverseDivideFunctor
<
T
>
,
T
>
(
dev_ctx
,
x
,
y
,
funcs
::
InverseDivideFunctor
<
T
>
(),
out
,
axis
);
}
}
}
}
// namespace phi
using
complex64
=
::
phi
::
dtype
::
complex
<
float
>
;
using
complex128
=
::
phi
::
dtype
::
complex
<
double
>
;
// NOTE(chenweihang): using bfloat16 will cause redefine with xpu bfloat16
// using bfloat16 = ::phi::dtype::bfloat16;
PD_REGISTER_KERNEL
(
divide_raw
,
CPU
,
ALL_LAYOUT
,
phi
::
DivideRawKernel
,
float
,
double
,
int
,
int64_t
,
complex64
,
complex128
)
{}
paddle/phi/kernels/legacy/cpu/elementwise_multiply_kernel.cc
0 → 100644
浏览文件 @
051add42
// Copyright (c) 2023 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/phi/api/ext/dispatch.h"
#include "paddle/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/common/bfloat16.h"
#include "paddle/phi/common/complex.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/cpu/elementwise.h"
#include "paddle/phi/kernels/impl/elementwise_kernel_impl.h"
namespace
phi
{
// Create the definition of Multiply
DEFINE_CPU_ELEMENTWISE_OP
(
Multiply
)
}
// namespace phi
using
complex64
=
::
phi
::
dtype
::
complex
<
float
>
;
using
complex128
=
::
phi
::
dtype
::
complex
<
double
>
;
// NOTE(chenweihang): using bfloat16 will cause redefine with xpu bfloat16
// using bfloat16 = ::phi::dtype::bfloat16;
PD_REGISTER_KERNEL
(
multiply_raw
,
CPU
,
ALL_LAYOUT
,
phi
::
MultiplyRawKernel
,
float
,
double
,
int
,
int64_t
,
bool
,
complex64
,
complex128
,
phi
::
dtype
::
bfloat16
)
{}
paddle/phi/kernels/legacy/elementwise_multipy_kernel.h
0 → 100644
浏览文件 @
051add42
// Copyright (c) 2023 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.
#pragma once
#include "paddle/phi/core/dense_tensor.h"
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
MultiplyRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
int
axis
,
DenseTensor
*
out
);
}
// namespace phi
paddle/phi/kernels/legacy/kps/elementwise_divide_kernel.cu
0 → 100644
浏览文件 @
051add42
// Copyright (c) 2023 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/phi/backends/gpu/gpu_context.h"
#ifndef PADDLE_WITH_XPU_KP
#include "paddle/phi/common/complex.h"
#include "paddle/phi/common/float16.h"
#endif
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/elementwise_kernel_impl.h"
namespace
phi
{
// Create the definition of Divide
DEFINE_CUDA_ELEMENTWISE_OP
(
Divide
)
}
// namespace phi
#ifdef PADDLE_WITH_XPU_KP
PD_REGISTER_KERNEL
(
divide_raw
,
KPS
,
ALL_LAYOUT
,
phi
::
DivideRawKernel
,
float
)
{}
#else
using
float16
=
phi
::
dtype
::
float16
;
using
bfloat16
=
phi
::
dtype
::
bfloat16
;
using
complex64
=
::
phi
::
dtype
::
complex
<
float
>
;
using
complex128
=
::
phi
::
dtype
::
complex
<
double
>
;
PD_REGISTER_KERNEL
(
divide_raw
,
KPS
,
ALL_LAYOUT
,
phi
::
DivideRawKernel
,
float
,
double
,
int
,
int64_t
,
float16
,
bfloat16
,
complex64
,
complex128
)
{}
#endif
paddle/phi/kernels/legacy/kps/elementwise_multiply_kernel.cu
0 → 100644
浏览文件 @
051add42
// Copyright (c) 2023 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/phi/backends/gpu/gpu_context.h"
#ifndef PADDLE_WITH_XPU_KP
#include "paddle/phi/common/complex.h"
#include "paddle/phi/common/float16.h"
#endif
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/elementwise_kernel_impl.h"
namespace
phi
{
// Create the definition of Multiply
DEFINE_CUDA_ELEMENTWISE_OP
(
Multiply
)
}
// namespace phi
#ifdef PADDLE_WITH_XPU_KP
PD_REGISTER_KERNEL
(
multiply_raw
,
KPS
,
ALL_LAYOUT
,
phi
::
MultiplyRawKernel
,
float
)
{}
#else
using
float16
=
phi
::
dtype
::
float16
;
using
bfloat16
=
phi
::
dtype
::
bfloat16
;
using
complex64
=
::
phi
::
dtype
::
complex
<
float
>
;
using
complex128
=
::
phi
::
dtype
::
complex
<
double
>
;
PD_REGISTER_KERNEL
(
multiply_raw
,
KPS
,
ALL_LAYOUT
,
phi
::
MultiplyRawKernel
,
float
,
double
,
int
,
int64_t
,
bool
,
float16
,
complex64
,
complex128
,
bfloat16
)
{}
#endif
paddle/phi/kernels/legacy/xpu/elementwise_divide_kernel.cc
0 → 100644
浏览文件 @
051add42
// Copyright (c) 2023 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/phi/kernels/elementwise_divide_kernel.h"
#include <memory>
#include <string>
#include "paddle/phi/backends/xpu/xpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/elementwise_base.h"
#include "paddle/phi/kernels/xpu/elementwise.h"
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
DivideRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
int
axis
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
const
XPUType
*
y
,
XPUType
*
z
,
const
std
::
vector
<
int
>&
xshape
,
const
std
::
vector
<
int
>&
yshape
)
{
return
xpu
::
broadcast_div
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
xshape
,
yshape
);
};
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
f
);
}
}
// namespace phi
PD_REGISTER_KERNEL
(
divide_raw
,
XPU
,
ALL_LAYOUT
,
phi
::
DivideRawKernel
,
phi
::
dtype
::
float16
,
float
)
{}
paddle/phi/kernels/legacy/xpu/elementwise_multiply_kernel.cc
0 → 100644
浏览文件 @
051add42
// Copyright (c) 2023 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/phi/kernels/elementwise_multiply_kernel.h"
#include <memory>
#include <string>
#include "paddle/phi/backends/xpu/xpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/elementwise_base.h"
#include "paddle/phi/kernels/xpu/elementwise.h"
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
MultiplyRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
int
axis
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
const
XPUType
*
y
,
XPUType
*
z
,
const
std
::
vector
<
int
>&
xshape
,
const
std
::
vector
<
int
>&
yshape
)
{
return
xpu
::
broadcast_mul
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
xshape
,
yshape
);
};
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
f
);
}
}
// namespace phi
PD_REGISTER_KERNEL
(
multiply_raw
,
XPU
,
ALL_LAYOUT
,
phi
::
MultiplyRawKernel
,
phi
::
dtype
::
float16
,
float
,
int
,
int64_t
)
{}
paddle/phi/kernels/selected_rows/elementwise_multiply_kernel.h
浏览文件 @
051add42
...
...
@@ -16,6 +16,7 @@ limitations under the License. */
#include "paddle/phi/core/dense_tensor.h"
#include "paddle/phi/core/selected_rows.h"
#include "paddle/phi/kernels/legacy/elementwise_multipy_kernel.h"
namespace
phi
{
namespace
sr
{
...
...
paddle/phi/kernels/xpu/elementwise_divide_kernel.cc
浏览文件 @
051add42
...
...
@@ -25,11 +25,10 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
DivideRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
int
axis
,
DenseTensor
*
out
)
{
void
DivideKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
...
...
@@ -40,14 +39,10 @@ void DivideRawKernel(const Context& dev_ctx,
return
xpu
::
broadcast_div
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
xshape
,
yshape
);
};
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
f
);
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
-
1
,
out
,
f
);
}
}
// namespace phi
PD_REGISTER_KERNEL
(
divide_raw
,
XPU
,
ALL_LAYOUT
,
phi
::
DivideRawKernel
,
phi
::
dtype
::
float16
,
float
)
{}
PD_REGISTER_KERNEL
(
divide
,
XPU
,
ALL_LAYOUT
,
phi
::
DivideKernel
,
phi
::
dtype
::
float16
,
float
)
{}
paddle/phi/kernels/xpu/elementwise_multiply_kernel.cc
浏览文件 @
051add42
...
...
@@ -25,11 +25,10 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
MultiplyRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
int
axis
,
DenseTensor
*
out
)
{
void
MultiplyKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
...
...
@@ -40,15 +39,15 @@ void MultiplyRawKernel(const Context& dev_ctx,
return
xpu
::
broadcast_mul
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
xshape
,
yshape
);
};
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
f
);
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
-
1
,
out
,
f
);
}
}
// namespace phi
PD_REGISTER_KERNEL
(
multiply
_raw
,
PD_REGISTER_KERNEL
(
multiply
,
XPU
,
ALL_LAYOUT
,
phi
::
Multiply
Raw
Kernel
,
phi
::
MultiplyKernel
,
phi
::
dtype
::
float16
,
float
,
int
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录