Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
TonyTonyFun
Paddle
提交
ca5567e1
P
Paddle
项目概览
TonyTonyFun
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
ca5567e1
编写于
8月 29, 2022
作者:
Z
zhangbo9674
提交者:
GitHub
8月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine expand_as_v2 XPU kernel, test=kunlun (#45501)
上级
fbd83812
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
13 deletion
+13
-13
paddle/phi/kernels/xpu/expand_as_kernel.cc
paddle/phi/kernels/xpu/expand_as_kernel.cc
+13
-13
未找到文件。
paddle/phi/kernels/xpu/expand_as_kernel.cc
浏览文件 @
ca5567e1
...
...
@@ -23,11 +23,11 @@ namespace phi {
template
<
typename
Context
,
typename
T
>
void
ExpandAs
(
const
Context
&
context
,
const
DenseTensor
&
in0
,
const
DenseTensor
&
x
,
const
std
::
vector
<
int
>&
target_shape
,
DenseTensor
*
out
0
)
{
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
auto
in_dims
=
in0
.
dims
();
auto
in_dims
=
x
.
dims
();
auto
vec_in_dims
=
phi
::
vectorize
<
int
>
(
in_dims
);
auto
diff
=
target_shape
.
size
()
-
vec_in_dims
.
size
();
vec_in_dims
.
insert
(
vec_in_dims
.
begin
(),
diff
,
1
);
...
...
@@ -50,23 +50,23 @@ void ExpandAs(const Context& context,
}
}
phi
::
DDim
out_dims
=
phi
::
make_ddim
(
target_shape
);
out
0
->
Resize
(
out_dims
);
context
.
template
Alloc
<
T
>(
out
0
);
auto
&
in0
_shape
=
vec_in_dims
;
auto
out
0
_shape
=
phi
::
vectorize
<
int
>
(
out_dims
);
out
->
Resize
(
out_dims
);
context
.
template
Alloc
<
T
>(
out
);
auto
&
x
_shape
=
vec_in_dims
;
auto
out_shape
=
phi
::
vectorize
<
int
>
(
out_dims
);
int
r
=
XPU_SUCCESS
;
if
(
std
::
is_same
<
T
,
bool
>::
value
)
{
auto
in0_data
=
reinterpret_cast
<
const
int8_t
*>
(
in0
.
data
<
T
>
());
auto
out
0_data
=
reinterpret_cast
<
int8_t
*>
(
out0
->
data
<
T
>
());
auto
x_data
=
reinterpret_cast
<
const
int8_t
*>
(
x
.
data
<
T
>
());
auto
out
_data
=
reinterpret_cast
<
int8_t
*>
(
out
->
data
<
T
>
());
r
=
xpu
::
broadcast
<
int8_t
>
(
context
.
x_context
(),
in0_data
,
out0_data
,
in0_shape
,
out0
_shape
);
context
.
x_context
(),
x_data
,
out_data
,
x_shape
,
out
_shape
);
}
else
{
auto
in0_data
=
reinterpret_cast
<
const
XPUType
*>
(
in0
.
data
<
T
>
());
auto
out
0_data
=
reinterpret_cast
<
XPUType
*>
(
out0
->
data
<
T
>
());
auto
x_data
=
reinterpret_cast
<
const
XPUType
*>
(
x
.
data
<
T
>
());
auto
out
_data
=
reinterpret_cast
<
XPUType
*>
(
out
->
data
<
T
>
());
r
=
xpu
::
broadcast
<
XPUType
>
(
context
.
x_context
(),
in0_data
,
out0_data
,
in0_shape
,
out0
_shape
);
context
.
x_context
(),
x_data
,
out_data
,
x_shape
,
out
_shape
);
}
PADDLE_ENFORCE_EQ
(
r
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录