Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
621d8a71
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
621d8a71
编写于
6月 28, 2021
作者:
B
Baibaifan
提交者:
GitHub
6月 28, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mode_c_embeding_bugs (#33801)
上级
95007981
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
81 addition
and
10 deletion
+81
-10
python/paddle/distributed/collective.py
python/paddle/distributed/collective.py
+81
-10
未找到文件。
python/paddle/distributed/collective.py
浏览文件 @
621d8a71
...
...
@@ -1219,6 +1219,65 @@ def _parallel_embedding(x,
return
out
def
_parallel_embedding_npu
(
x
,
per_part_embeddings
,
origin_size
,
param_attr
,
inner_rank
,
num_partitions
,
name
,
group
=
None
):
"""
NPU Parallel Embedding
"""
if
group
is
not
None
and
not
group
.
is_member
():
return
ring_id
=
0
if
group
is
None
else
group
.
id
origin_num_embeddings
=
origin_size
[
0
]
embedding
=
paddle
.
nn
.
Embedding
(
per_part_embeddings
,
origin_size
[
1
],
padding_idx
=
per_part_embeddings
-
1
,
sparse
=
False
,
weight_attr
=
param_attr
,
name
=
name
)
origin_input_shape
=
x
.
shape
if
len
(
origin_input_shape
)
==
2
:
x
=
paddle
.
unsqueeze
(
x
,
axis
=-
1
)
else
:
assert
origin_input_shape
[
-
1
]
==
1
,
(
"The last dimension size of x must be 1."
)
x_shard
=
paddle
.
shard_index
(
x
,
origin_num_embeddings
,
num_partitions
,
inner_rank
,
per_part_embeddings
-
1
)
if
len
(
origin_input_shape
)
==
2
:
x_shard
=
paddle
.
squeeze
(
x_shard
,
axis
=-
1
)
emb_out
=
embedding
(
x_shard
)
startup_block
=
paddle
.
static
.
default_startup_program
().
global_block
()
main_block
=
paddle
.
static
.
default_main_program
().
global_block
()
startup_block
.
vars
[
embedding
.
weight
.
name
].
is_distributed
=
True
main_block
.
vars
[
embedding
.
weight
.
name
].
is_distributed
=
True
out
=
main_block
.
create_var
(
shape
=
emb_out
.
shape
,
dtype
=
emb_out
.
dtype
,
type
=
emb_out
.
type
,
lod_level
=
emb_out
.
lod_level
,
persistable
=
False
,
is_data
=
False
,
need_check_feed
=
emb_out
.
desc
.
need_check_feed
())
main_block
.
append_op
(
type
=
'c_allreduce_sum'
,
inputs
=
{
'X'
:
emb_out
},
outputs
=
{
'Out'
:
out
},
attrs
=
{
'ring_id'
:
ring_id
,
'use_calc_stream'
:
True
,
'use_model_parallel'
:
True
})
return
out
def
split
(
x
,
size
,
operation
,
...
...
@@ -1332,16 +1391,28 @@ def split(x,
"but received vocabulary={} num_partitions={}"
.
format
(
size
[
0
],
num_partitions
)
per_part_size
=
size
[
0
]
//
num_partitions
emb_out
=
_parallel_embedding
(
x
,
per_part_size
,
size
,
weight_attr
,
inner_rank
,
num_partitions
,
name
,
group
=
None
)
return
emb_out
if
core
.
is_compiled_with_npu
():
emb_out
=
_parallel_embedding_npu
(
x
,
per_part_size
,
size
,
weight_attr
,
inner_rank
,
num_partitions
,
name
,
group
=
None
)
return
emb_out
else
:
emb_out
=
_parallel_embedding
(
x
,
per_part_size
,
size
,
weight_attr
,
inner_rank
,
num_partitions
,
name
,
group
=
None
)
return
emb_out
else
:
should_split
=
False
if
axis
==
0
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录