Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
3c2420a3
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,发现更多精彩内容 >>
未验证
提交
3c2420a3
编写于
12月 29, 2022
作者:
Y
ykkk2333
提交者:
GitHub
12月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xpu kernels support api int64 vector inputs, test=kunlun (#49336)
上级
418edae5
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
249 addition
and
115 deletion
+249
-115
cmake/external/xpu.cmake
cmake/external/xpu.cmake
+1
-1
paddle/phi/kernels/xpu/compare_kernel.cc
paddle/phi/kernels/xpu/compare_kernel.cc
+24
-16
paddle/phi/kernels/xpu/elementwise_add_kernel.cc
paddle/phi/kernels/xpu/elementwise_add_kernel.cc
+11
-2
paddle/phi/kernels/xpu/elementwise_divide_grad_kernel.cc
paddle/phi/kernels/xpu/elementwise_divide_grad_kernel.cc
+15
-9
paddle/phi/kernels/xpu/elementwise_divide_kernel.cc
paddle/phi/kernels/xpu/elementwise_divide_kernel.cc
+10
-2
paddle/phi/kernels/xpu/elementwise_grad_kernel.cc
paddle/phi/kernels/xpu/elementwise_grad_kernel.cc
+30
-18
paddle/phi/kernels/xpu/elementwise_kernel.cc
paddle/phi/kernels/xpu/elementwise_kernel.cc
+50
-10
paddle/phi/kernels/xpu/elementwise_multiply_grad_kernel.cc
paddle/phi/kernels/xpu/elementwise_multiply_grad_kernel.cc
+14
-9
paddle/phi/kernels/xpu/elementwise_multiply_kernel.cc
paddle/phi/kernels/xpu/elementwise_multiply_kernel.cc
+10
-2
paddle/phi/kernels/xpu/elementwise_subtract_grad_kernel.cc
paddle/phi/kernels/xpu/elementwise_subtract_grad_kernel.cc
+16
-9
paddle/phi/kernels/xpu/elementwise_subtract_kernel.cc
paddle/phi/kernels/xpu/elementwise_subtract_kernel.cc
+10
-2
paddle/phi/kernels/xpu/prod_kernel.cc
paddle/phi/kernels/xpu/prod_kernel.cc
+12
-7
paddle/phi/kernels/xpu/reduce_max_kernel.cc
paddle/phi/kernels/xpu/reduce_max_kernel.cc
+11
-7
paddle/phi/kernels/xpu/reduce_mean_kernel.cc
paddle/phi/kernels/xpu/reduce_mean_kernel.cc
+12
-7
paddle/phi/kernels/xpu/reduce_min_kernel.cc
paddle/phi/kernels/xpu/reduce_min_kernel.cc
+12
-7
paddle/phi/kernels/xpu/reduce_sum_kernel.cc
paddle/phi/kernels/xpu/reduce_sum_kernel.cc
+11
-7
未找到文件。
cmake/external/xpu.cmake
浏览文件 @
3c2420a3
...
...
@@ -10,7 +10,7 @@ set(XPU_RT_LIB_NAME "libxpurt.so")
if
(
NOT DEFINED XPU_BASE_URL
)
set
(
XPU_BASE_URL_WITHOUT_DATE
"https://baidu-kunlun-product.su.bcebos.com/KL-SDK/klsdk-dev"
)
set
(
XPU_BASE_URL
"
${
XPU_BASE_URL_WITHOUT_DATE
}
/202212
15
"
)
set
(
XPU_BASE_URL
"
${
XPU_BASE_URL_WITHOUT_DATE
}
/202212
27
"
)
else
()
set
(
XPU_BASE_URL
"
${
XPU_BASE_URL
}
"
)
endif
()
...
...
paddle/phi/kernels/xpu/compare_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -52,22 +52,30 @@ void XPUCompareKernelImpl(const Context& dev_ctx,
PADDLE_ENFORCE_XDNN_SUCCESS
(
ret
,
"compare op"
);
}
#define DEFINE_XPU_COMPARE_KERNEL(name, functor) \
template <typename T, typename Context> \
void name##RawKernel(const Context& dev_ctx, \
const DenseTensor& x, \
const DenseTensor& y, \
int axis, \
DenseTensor* out) { \
using XPUType = typename XPUTypeTrait<T>::Type; \
XPUCompareKernelImpl<T, XPUType, Context>(dev_ctx, x, y, out, functor); \
} \
template <typename T, typename Context> \
void name##Kernel(const Context& dev_ctx, \
const DenseTensor& x, \
const DenseTensor& y, \
DenseTensor* out) { \
name##RawKernel<T, Context>(dev_ctx, x, y, -1, out); \
#define DEFINE_XPU_COMPARE_KERNEL(name, functor) \
template <typename T, typename Context> \
void name##RawKernel(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, \
bool* z, \
const std::vector<int>& xshape, \
const std::vector<int>& yshape) { \
return functor(ctx, x, y, z, xshape, yshape); \
}; \
XPUCompareKernelImpl<T, XPUType, Context>(dev_ctx, x, y, out, f); \
} \
template <typename T, typename Context> \
void name##Kernel(const Context& dev_ctx, \
const DenseTensor& x, \
const DenseTensor& y, \
DenseTensor* out) { \
name##RawKernel<T, Context>(dev_ctx, x, y, -1, out); \
}
DEFINE_XPU_COMPARE_KERNEL
(
Equal
,
xpu
::
broadcast_equal
<
XPUType
>
)
...
...
paddle/phi/kernels/xpu/elementwise_add_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -54,8 +54,17 @@ void AddRawKernel(const Context& dev_ctx,
int
axis
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
xpu
::
broadcast_add
<
XPUType
>
);
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_add
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
xshape
,
yshape
);
};
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
f
);
}
}
// namespace phi
...
...
paddle/phi/kernels/xpu/elementwise_divide_grad_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -35,15 +35,21 @@ void DivideGradKernel(const Context& dev_ctx,
DenseTensor
*
dy
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
funcs
::
ElementwiseGradPreProcess
(
dout
,
dx
);
XPUElementwiseGrad
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
dout
,
axis
,
dx
,
dy
,
xpu
::
broadcast_div_grad
<
XPUType
>
,
true
);
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
const
XPUType
*
y
,
const
XPUType
*
z
,
const
XPUType
*
dz
,
XPUType
*
dy
,
XPUType
*
dx
,
const
std
::
vector
<
int
>&
xshape
,
const
std
::
vector
<
int
>&
yshape
)
{
return
xpu
::
broadcast_div_grad
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
dz
,
dy
,
dx
,
xshape
,
yshape
);
};
XPUElementwiseGrad
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
dout
,
axis
,
dx
,
dy
,
f
,
true
);
}
}
// namespace phi
...
...
paddle/phi/kernels/xpu/elementwise_divide_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -31,8 +31,16 @@ void DivideRawKernel(const Context& dev_ctx,
int
axis
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
xpu
::
broadcast_div
<
XPUType
>
);
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
...
...
paddle/phi/kernels/xpu/elementwise_grad_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -29,15 +29,21 @@ void MaximumGradKernel(const Context& dev_ctx,
DenseTensor
*
dx
,
DenseTensor
*
dy
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
XPUElementwiseGrad
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
dout
,
axis
,
dx
,
dy
,
xpu
::
broadcast_max_grad
<
XPUType
>
,
true
);
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
const
XPUType
*
y
,
const
XPUType
*
z
,
const
XPUType
*
dz
,
XPUType
*
dy
,
XPUType
*
dx
,
const
std
::
vector
<
int
>&
xshape
,
const
std
::
vector
<
int
>&
yshape
)
{
return
xpu
::
broadcast_max_grad
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
dz
,
dy
,
dx
,
xshape
,
yshape
);
};
XPUElementwiseGrad
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
dout
,
axis
,
dx
,
dy
,
f
,
true
);
}
template
<
typename
T
,
typename
Context
>
...
...
@@ -49,15 +55,21 @@ void MinimumGradKernel(const Context& dev_ctx,
DenseTensor
*
dx
,
DenseTensor
*
dy
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
XPUElementwiseGrad
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
dout
,
axis
,
dx
,
dy
,
xpu
::
broadcast_min_grad
<
XPUType
>
,
true
);
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
const
XPUType
*
y
,
const
XPUType
*
z
,
const
XPUType
*
dz
,
XPUType
*
dy
,
XPUType
*
dx
,
const
std
::
vector
<
int
>&
xshape
,
const
std
::
vector
<
int
>&
yshape
)
{
return
xpu
::
broadcast_min_grad
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
dz
,
dy
,
dx
,
xshape
,
yshape
);
};
XPUElementwiseGrad
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
dout
,
axis
,
dx
,
dy
,
f
,
true
);
}
}
// namespace phi
...
...
paddle/phi/kernels/xpu/elementwise_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -27,8 +27,16 @@ void FloorDivideRawKernel(const Context& dev_ctx,
int
axis
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
xpu
::
broadcast_floordiv
<
XPUType
>
);
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_floordiv
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
xshape
,
yshape
);
};
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
f
);
}
template
<
typename
T
,
typename
Context
>
...
...
@@ -38,8 +46,16 @@ void MaximumRawKernel(const Context& dev_ctx,
int
axis
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
xpu
::
broadcast_max
<
XPUType
>
);
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_max
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
xshape
,
yshape
);
};
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
f
);
}
template
<
typename
T
,
typename
Context
>
...
...
@@ -49,8 +65,16 @@ void MinimumRawKernel(const Context& dev_ctx,
int
axis
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
xpu
::
broadcast_min
<
XPUType
>
);
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_min
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
xshape
,
yshape
);
};
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
f
);
}
template
<
typename
T
,
typename
Context
>
...
...
@@ -60,8 +84,16 @@ void RemainderRawKernel(const Context& dev_ctx,
int
axis
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
xpu
::
broadcast_mod
<
XPUType
>
);
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_mod
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
xshape
,
yshape
);
};
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
f
);
}
template
<
typename
T
,
typename
Context
>
...
...
@@ -71,8 +103,16 @@ void ElementwisePowRawKernel(const Context& dev_ctx,
int
axis
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
xpu
::
broadcast_pow
<
XPUType
>
);
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_pow
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
xshape
,
yshape
);
};
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
f
);
}
}
// namespace phi
...
...
paddle/phi/kernels/xpu/elementwise_multiply_grad_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -34,15 +34,20 @@ void MultiplyGradKernel(const Context& dev_ctx,
DenseTensor
*
dy
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
funcs
::
ElementwiseGradPreProcess
(
dout
,
dx
);
XPUElementwiseGrad
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
dout
,
axis
,
dx
,
dy
,
xpu
::
broadcast_mul_grad
<
XPUType
>
,
true
);
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
const
XPUType
*
y
,
const
XPUType
*
z
,
const
XPUType
*
dz
,
XPUType
*
dy
,
XPUType
*
dx
,
const
std
::
vector
<
int
>&
xshape
,
const
std
::
vector
<
int
>&
yshape
)
{
return
xpu
::
broadcast_mul_grad
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
dz
,
dy
,
dx
,
xshape
,
yshape
);
};
XPUElementwiseGrad
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
dout
,
axis
,
dx
,
dy
,
f
,
true
);
}
}
// namespace phi
...
...
paddle/phi/kernels/xpu/elementwise_multiply_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -31,8 +31,16 @@ void MultiplyRawKernel(const Context& dev_ctx,
int
axis
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
xpu
::
broadcast_mul
<
XPUType
>
);
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
...
...
paddle/phi/kernels/xpu/elementwise_subtract_grad_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -28,15 +28,22 @@ void SubtractGradKernel(const Context& dev_ctx,
DenseTensor
*
dx
,
DenseTensor
*
dy
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
phi
::
XPUElementwiseGrad
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
dout
,
axis
,
dx
,
dy
,
xpu
::
broadcast_sub_grad
<
XPUType
>
,
false
);
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
const
XPUType
*
y
,
const
XPUType
*
z
,
const
XPUType
*
dz
,
XPUType
*
dy
,
XPUType
*
dx
,
const
std
::
vector
<
int
>&
xshape
,
const
std
::
vector
<
int
>&
yshape
)
{
return
xpu
::
broadcast_sub_grad
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
dz
,
dy
,
dx
,
xshape
,
yshape
);
};
phi
::
XPUElementwiseGrad
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
dout
,
axis
,
dx
,
dy
,
f
,
false
);
}
}
// namespace phi
...
...
paddle/phi/kernels/xpu/elementwise_subtract_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -26,8 +26,16 @@ void SubtractRawKernel(const Context& dev_ctx,
int
axis
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
phi
::
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
xpu
::
broadcast_sub
<
XPUType
>
);
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_sub
<
XPUType
>
(
ctx
,
x
,
y
,
z
,
xshape
,
yshape
);
};
phi
::
XPUElementwise
<
T
,
XPUType
>
(
dev_ctx
,
x
,
y
,
axis
,
out
,
f
);
}
}
// namespace phi
...
...
paddle/phi/kernels/xpu/prod_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -29,13 +29,18 @@ void ProdRawKernel(const Context& dev_ctx,
bool
reduce_all
,
DenseTensor
*
out
)
{
reduce_all
=
recompute_reduce_all
(
x
,
dims
,
reduce_all
);
int
r
=
XPUReduce
<
Context
,
T
>
(
dev_ctx
,
x
,
dims
.
GetData
(),
keep_dim
,
reduce_all
,
out
,
xpu
::
reduce_prod
<
T
>
);
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
XPUType
*
y
,
const
std
::
vector
<
int
>&
xdims
,
const
std
::
vector
<
int
>&
reduce_dims
)
{
return
xpu
::
reduce_prod
<
XPUType
>
(
ctx
,
x
,
y
,
xdims
,
reduce_dims
);
};
int
r
=
XPUReduce
<
Context
,
T
>
(
dev_ctx
,
x
,
dims
.
GetData
(),
keep_dim
,
reduce_all
,
out
,
f
);
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"reduce_prod"
);
}
...
...
paddle/phi/kernels/xpu/reduce_max_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -29,13 +29,17 @@ void MaxRawKernel(const Context& dev_ctx,
bool
reduce_all
,
DenseTensor
*
out
)
{
reduce_all
=
recompute_reduce_all
(
x
,
dims
,
reduce_all
);
int
r
=
XPUReduce
<
Context
,
T
>
(
dev_ctx
,
x
,
dims
.
GetData
(),
keep_dim
,
reduce_all
,
out
,
xpu
::
reduce_max
<
T
>
);
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
XPUType
*
y
,
const
std
::
vector
<
int
>&
xdims
,
const
std
::
vector
<
int
>&
reduce_dims
)
{
return
xpu
::
reduce_max
<
XPUType
>
(
ctx
,
x
,
y
,
xdims
,
reduce_dims
);
};
int
r
=
XPUReduce
<
Context
,
XPUType
>
(
dev_ctx
,
x
,
dims
.
GetData
(),
keep_dim
,
reduce_all
,
out
,
f
);
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"reduce_max"
);
}
...
...
paddle/phi/kernels/xpu/reduce_mean_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -29,13 +29,18 @@ void MeanRawKernel(const Context& dev_ctx,
bool
reduce_all
,
DenseTensor
*
out
)
{
reduce_all
=
recompute_reduce_all
(
x
,
dims
,
reduce_all
);
int
r
=
XPUReduce
<
Context
,
T
>
(
dev_ctx
,
x
,
dims
.
GetData
(),
keep_dim
,
reduce_all
,
out
,
xpu
::
reduce_mean
<
T
>
);
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
XPUType
*
y
,
const
std
::
vector
<
int
>&
xdims
,
const
std
::
vector
<
int
>&
reduce_dims
)
{
return
xpu
::
reduce_mean
<
XPUType
>
(
ctx
,
x
,
y
,
xdims
,
reduce_dims
);
};
int
r
=
XPUReduce
<
Context
,
XPUType
>
(
dev_ctx
,
x
,
dims
.
GetData
(),
keep_dim
,
reduce_all
,
out
,
f
);
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"reduce_mean"
);
}
...
...
paddle/phi/kernels/xpu/reduce_min_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -29,13 +29,18 @@ void MinRawKernel(const Context& dev_ctx,
bool
reduce_all
,
DenseTensor
*
out
)
{
reduce_all
=
recompute_reduce_all
(
x
,
dims
,
reduce_all
);
int
r
=
XPUReduce
<
Context
,
T
>
(
dev_ctx
,
x
,
dims
.
GetData
(),
keep_dim
,
reduce_all
,
out
,
xpu
::
reduce_min
<
T
>
);
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
XPUType
*
y
,
const
std
::
vector
<
int
>&
xdims
,
const
std
::
vector
<
int
>&
reduce_dims
)
{
return
xpu
::
reduce_min
<
XPUType
>
(
ctx
,
x
,
y
,
xdims
,
reduce_dims
);
};
int
r
=
XPUReduce
<
Context
,
XPUType
>
(
dev_ctx
,
x
,
dims
.
GetData
(),
keep_dim
,
reduce_all
,
out
,
f
);
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"reduce_min"
);
}
...
...
paddle/phi/kernels/xpu/reduce_sum_kernel.cc
浏览文件 @
3c2420a3
...
...
@@ -30,13 +30,17 @@ void SumRawKernel(const Context& dev_ctx,
DataType
out_dtype
,
DenseTensor
*
out
)
{
reduce_all
=
recompute_reduce_all
(
x
,
dims
,
reduce_all
);
int
r
=
XPUReduce
<
Context
,
T
>
(
dev_ctx
,
x
,
dims
.
GetData
(),
keep_dim
,
reduce_all
,
out
,
xpu
::
reduce_sum
<
T
>
);
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
XPUType
*
y
,
const
std
::
vector
<
int
>&
xdims
,
const
std
::
vector
<
int
>&
reduce_dims
)
{
return
xpu
::
reduce_sum
<
XPUType
>
(
ctx
,
x
,
y
,
xdims
,
reduce_dims
);
};
int
r
=
XPUReduce
<
Context
,
XPUType
>
(
dev_ctx
,
x
,
dims
.
GetData
(),
keep_dim
,
reduce_all
,
out
,
f
);
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"reduce_sum"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录