Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
9c8e750c
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9c8e750c
编写于
5月 20, 2020
作者:
H
hongxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
maximize strategy dynamically
上级
d84ccfe8
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
61 addition
and
32 deletion
+61
-32
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_generate_strategy.cc
.../parallel/auto_parallel/rec_core/rec_generate_strategy.cc
+61
-32
未找到文件。
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_generate_strategy.cc
浏览文件 @
9c8e750c
...
...
@@ -81,16 +81,33 @@ std::vector<std::vector<int32_t>> PrepareVirtualDataset(const std::vector<std::s
std
::
vector
<
std
::
vector
<
int32_t
>>
PrepareBiasAdd
(
const
std
::
vector
<
std
::
shared_ptr
<
OperatorInfo
>>
&
ops
,
const
size_t
iter_ops
,
std
::
vector
<
int32_t
>
s
)
{
std
::
vector
<
std
::
vector
<
int32_t
>>
strategies
;
for
(
size_t
iter_op_inputs
=
0
;
iter_op_inputs
<
ops
[
iter_ops
]
->
inputs_tensor_info
().
size
();
iter_op_inputs
++
)
{
if
(
ops
[
iter_ops
]
->
inputs_tensor_info
()[
iter_op_inputs
].
shape
().
size
()
==
1
)
{
auto
max
=
s
[
max_element
(
s
.
begin
(),
s
.
end
())
-
s
.
begin
()];
std
::
vector
<
int32_t
>
s_single
;
s_single
.
push_back
(
max
);
strategies
.
push_back
(
s_single
);
continue
;
auto
dev_num
=
g_device_manager
->
DeviceNum
();
size_t
cut_num
=
1
;
for
(
size_t
iter_s
=
0
;
iter_s
<
s
.
size
();
iter_s
++
)
{
cut_num
*=
s
[
iter_s
];
}
if
(
cut_num
!=
dev_num
)
{
std
::
vector
<
int32_t
>
s_max
=
s
;
for
(
size_t
dim
=
0
;
dim
<
(
size_t
)
ops
[
iter_ops
]
->
inputs_tensor_info
()[
0
].
shape
().
size
();
dim
++
)
{
size_t
shape
=
ops
[
iter_ops
]
->
inputs_tensor_info
()[
0
].
shape
()[
dim
]
/
s
[
dim
];
while
(
cut_num
<
dev_num
&&
shape
%
2
==
0
)
{
shape
=
shape
/
2
;
s_max
[
dim
]
=
s_max
[
dim
]
*
2
;
cut_num
=
cut_num
*
2
;
}
if
(
cut_num
==
dev_num
)
{
break
;
}
strategies
.
push_back
(
s
);
}
s
=
s_max
;
}
strategies
.
push_back
(
s
);
std
::
vector
<
int32_t
>
s_biasadd
;
s_biasadd
.
push_back
(
s
[
1
]);
strategies
.
push_back
(
s_biasadd
);
return
strategies
;
}
...
...
@@ -423,27 +440,22 @@ std::vector<std::vector<int32_t>> GenerateStrategiesFromStrategy(const std::vect
}
auto
dev_num
=
g_device_manager
->
DeviceNum
();
size_t
cut_num
=
1
;
for
(
size_t
i
=
0
;
i
<
s
.
size
();
i
++
)
{
cut_num
*=
s
[
i
];
}
if
(
cut_num
<
dev_num
)
{
size_t
diff
=
dev_num
/
cut_num
;
if
(
s
[
0
]
*
diff
>
dev_num
)
{
MS_LOG
(
EXCEPTION
)
<<
"Failure: Can not continue to partition in the N-dimension of the element-wise operator."
;
}
s
[
0
]
=
s
[
0
]
*
diff
;
}
for
(
size_t
i
=
0
;
i
<
(
size_t
)
ops
[
iter_ops
]
->
inputs_tensor_info
().
size
();
i
++
)
{
if
(
ops
[
iter_ops
]
->
inputs_tensor_info
()[
i
].
shape
().
size
()
==
0
)
{
for
(
size_t
iter_op_inputs
=
0
;
iter_op_inputs
<
(
size_t
)
ops
[
iter_ops
]
->
inputs_tensor_info
().
size
();
iter_op_inputs
++
)
{
if
(
ops
[
iter_ops
]
->
inputs_tensor_info
()[
iter_op_inputs
].
shape
().
size
()
==
0
)
{
stra
.
push_back
(
s_empty
);
continue
;
}
size_t
cut_num
=
1
;
for
(
size_t
iter_s
=
0
;
iter_s
<
s
.
size
();
iter_s
++
)
{
cut_num
*=
s
[
iter_s
];
}
if
(
cut_num
==
dev_num
)
{
std
::
vector
<
int32_t
>
s_1
=
s
;
bool
modified
=
false
;
for
(
size_t
j
=
0
;
j
<
(
size_t
)
ops
[
iter_ops
]
->
inputs_tensor_info
()[
i
].
shape
().
size
();
j
++
)
{
if
(
ops
[
iter_ops
]
->
inputs_tensor_info
()[
i
].
shape
()[
j
]
==
1
)
{
for
(
size_t
j
=
0
;
j
<
(
size_t
)
ops
[
iter_ops
]
->
inputs_tensor_info
()[
iter_op_inputs
].
shape
().
size
();
j
++
)
{
if
(
ops
[
iter_ops
]
->
inputs_tensor_info
()[
iter_op_inputs
].
shape
()[
j
]
==
1
)
{
s_1
[
j
]
=
1
;
modified
=
true
;
}
...
...
@@ -453,6 +465,23 @@ std::vector<std::vector<int32_t>> GenerateStrategiesFromStrategy(const std::vect
}
else
{
stra
.
push_back
(
s
);
}
continue
;
}
std
::
vector
<
int32_t
>
s_max
=
s
;
for
(
size_t
dim
=
0
;
dim
<
(
size_t
)
ops
[
iter_ops
]
->
inputs_tensor_info
()[
iter_op_inputs
].
shape
().
size
();
dim
++
)
{
size_t
shape
=
ops
[
iter_ops
]
->
inputs_tensor_info
()[
iter_op_inputs
].
shape
()[
dim
]
/
s
[
dim
];
while
(
cut_num
<
dev_num
&&
shape
%
2
==
0
)
{
shape
=
shape
/
2
;
s_max
[
dim
]
=
s_max
[
dim
]
*
2
;
cut_num
=
cut_num
*
2
;
}
if
(
cut_num
==
dev_num
)
{
break
;
}
}
stra
.
push_back
(
s_max
);
}
return
stra
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录