Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_77200941
mindspore
提交
39790ccf
M
mindspore
项目概览
2301_77200941
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
39790ccf
编写于
6月 11, 2020
作者:
H
hongxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize code
上级
bee57fda
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
33 deletion
+46
-33
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_generate_strategy.cc
.../parallel/auto_parallel/rec_core/rec_generate_strategy.cc
+2
-13
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_generate_strategy.h
...c/parallel/auto_parallel/rec_core/rec_generate_strategy.h
+0
-3
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_graph.h
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_graph.h
+1
-0
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_parse_graph.cc
.../ccsrc/parallel/auto_parallel/rec_core/rec_parse_graph.cc
+42
-17
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_parse_graph.h
...e/ccsrc/parallel/auto_parallel/rec_core/rec_parse_graph.h
+1
-0
未找到文件。
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_generate_strategy.cc
浏览文件 @
39790ccf
...
...
@@ -146,16 +146,6 @@ std::vector<std::vector<int32_t>> PrepareBatchNorm(const std::shared_ptr<Graph>
return
strategies
;
}
std
::
vector
<
std
::
vector
<
int32_t
>>
PrepareSoftmaxWithLogits
(
const
std
::
shared_ptr
<
Graph
>
&
graph
,
const
std
::
vector
<
std
::
shared_ptr
<
OperatorInfo
>>
&
ops
,
const
size_t
iter_graph
,
const
size_t
iter_ops
)
{
std
::
vector
<
std
::
vector
<
int32_t
>>
strategies
=
MakeDataParallelStrategy
(
graph
,
ops
,
iter_graph
,
iter_ops
);
graph
->
nodes
[
iter_graph
].
tensor_parm
.
tensor_str
.
str_w
=
graph
->
nodes
[
iter_graph
].
tensor_parm
.
tensor_str
.
str_h
;
graph
->
nodes
[
iter_graph
].
tensor_parm
.
tensor_str
.
str_h
=
graph
->
nodes
[
iter_graph
].
tensor_parm
.
tensor_str
.
str_c
;
graph
->
nodes
[
iter_graph
].
tensor_parm
.
tensor_str
.
str_c
=
graph
->
nodes
[
iter_graph
].
tensor_parm
.
tensor_str
.
str_n
;
return
strategies
;
}
std
::
vector
<
std
::
vector
<
int32_t
>>
PrepareBiasAdd
(
const
std
::
shared_ptr
<
std
::
vector
<
int32_t
>>
&
s
)
{
std
::
vector
<
std
::
vector
<
int32_t
>>
strategies
;
strategies
.
push_back
(
*
s
);
...
...
@@ -299,9 +289,8 @@ std::vector<std::vector<int32_t>> PrepareStrategy(const std::shared_ptr<Graph> &
return
PreparePReLU
(
graph
,
ops
,
iter_graph
,
iter_ops
);
}
else
if
(
type
==
BATCH_NORM
)
{
return
PrepareBatchNorm
(
graph
,
ops
,
iter_graph
,
iter_ops
);
}
else
if
(
type
==
SOFTMAX_CROSS_ENTROPY_WITH_LOGITS
)
{
return
PrepareSoftmaxWithLogits
(
graph
,
ops
,
iter_graph
,
iter_ops
);
}
else
if
(
type
==
SOFTMAX
||
type
==
LOG_SOFTMAX
||
type
==
SPARSE_SOFTMAX_CROSS_ENTROPY_WITH_LOGITS
)
{
}
else
if
(
type
==
SOFTMAX
||
type
==
LOG_SOFTMAX
||
type
==
SPARSE_SOFTMAX_CROSS_ENTROPY_WITH_LOGITS
||
type
==
SOFTMAX_CROSS_ENTROPY_WITH_LOGITS
)
{
return
MakeDataParallelStrategy
(
graph
,
ops
,
iter_graph
,
iter_ops
);
}
else
{
return
MakeRecSearchStrategy
(
graph
,
ops
,
iter_graph
,
iter_ops
);
...
...
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_generate_strategy.h
浏览文件 @
39790ccf
...
...
@@ -40,9 +40,6 @@ std::vector<std::vector<int32_t>> PreparePReLU(const std::shared_ptr<Graph> &gra
std
::
vector
<
std
::
vector
<
int32_t
>>
PrepareBatchNorm
(
const
std
::
shared_ptr
<
Graph
>
&
graph
,
const
std
::
vector
<
std
::
shared_ptr
<
OperatorInfo
>>
&
ops
,
const
size_t
iter_graph
,
const
size_t
iter_ops
);
std
::
vector
<
std
::
vector
<
int32_t
>>
PrepareSoftmaxWithLogits
(
const
std
::
shared_ptr
<
Graph
>
&
graph
,
const
std
::
vector
<
std
::
shared_ptr
<
OperatorInfo
>>
&
ops
,
const
size_t
iter_graph
,
const
size_t
iter_ops
);
std
::
vector
<
std
::
vector
<
int32_t
>>
PrepareBiasAdd
(
const
std
::
shared_ptr
<
std
::
vector
<
int32_t
>>
&
s
);
std
::
vector
<
std
::
vector
<
int32_t
>>
PrepareOneHot
(
const
std
::
shared_ptr
<
std
::
vector
<
int32_t
>>
&
s
);
std
::
vector
<
std
::
vector
<
int32_t
>>
PrepareGatherV2
(
const
std
::
shared_ptr
<
std
::
vector
<
int32_t
>>
&
s
);
...
...
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_graph.h
浏览文件 @
39790ccf
...
...
@@ -69,6 +69,7 @@ class Graph {
std
::
vector
<
size_t
>
node_in
;
// Nodes that point from this node
std
::
vector
<
size_t
>
node_out
;
std
::
vector
<
size_t
>
node_in_aux
;
// Node Type Info: Application or Constant. Defined in enum <InfoType> .
InfoType
info
;
// Operator info. Defined in struct <OperatorRec> .
...
...
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_parse_graph.cc
浏览文件 @
39790ccf
...
...
@@ -171,21 +171,41 @@ void Eliminate_Aux(const size_t node_index, const std::shared_ptr<Graph> graph,
eli
.
push_back
(
graph
->
nodes
[
node_index
].
node_out
[
i
]);
}
eli_list
->
push_back
(
eli
);
for
(
auto
input_index
:
graph
->
nodes
[
node_index
].
node_in
)
{
auto
it
=
find
(
graph
->
nodes
[
input_index
].
node_out
.
begin
(),
graph
->
nodes
[
input_index
].
node_out
.
end
(),
node_index
);
if
(
it
!=
graph
->
nodes
[
input_index
].
node_out
.
end
())
{
graph
->
nodes
[
input_index
].
node_out
.
erase
(
it
);
for
(
auto
output_index
:
graph
->
nodes
[
node_index
].
node_out
)
{
graph
->
nodes
[
input_index
].
node_out
.
push_back
(
output_index
);
}
for
(
size_t
i
=
0
;
i
<
graph
->
nodes
[
node_index
].
node_in
.
size
();
i
++
)
{
auto
*
incoming_outputs
=
&
graph
->
nodes
[
graph
->
nodes
[
node_index
].
node_in
[
i
]].
node_out
;
auto
it
=
find
(
incoming_outputs
->
begin
(),
incoming_outputs
->
end
(),
node_index
);
if
(
it
!=
incoming_outputs
->
end
())
{
it
=
incoming_outputs
->
erase
(
it
);
incoming_outputs
->
insert
(
it
,
graph
->
nodes
[
node_index
].
node_out
.
begin
(),
graph
->
nodes
[
node_index
].
node_out
.
end
());
}
}
for
(
size_t
i
=
0
;
i
<
graph
->
nodes
[
node_index
].
node_in_aux
.
size
();
i
++
)
{
auto
*
aux_incoming_outputs
=
&
graph
->
nodes
[
graph
->
nodes
[
node_index
].
node_in_aux
[
i
]].
node_out
;
auto
it
=
find
(
aux_incoming_outputs
->
begin
(),
aux_incoming_outputs
->
end
(),
node_index
);
if
(
it
!=
aux_incoming_outputs
->
end
())
{
it
=
aux_incoming_outputs
->
erase
(
it
);
aux_incoming_outputs
->
insert
(
it
,
graph
->
nodes
[
node_index
].
node_out
.
begin
(),
graph
->
nodes
[
node_index
].
node_out
.
end
());
}
}
for
(
auto
output_index
:
graph
->
nodes
[
node_index
].
node_out
)
{
auto
it
=
find
(
graph
->
nodes
[
output_index
].
node_in
.
begin
(),
graph
->
nodes
[
output_index
].
node_in
.
end
(),
node_index
);
if
(
it
!=
graph
->
nodes
[
output_index
].
node_in
.
end
())
{
graph
->
nodes
[
output_index
].
node_in
.
erase
(
it
);
for
(
auto
input_index
:
graph
->
nodes
[
node_index
].
node_in
)
{
graph
->
nodes
[
output_index
].
node_in
.
push_back
(
input_index
);
for
(
size_t
i
=
0
;
i
<
graph
->
nodes
[
node_index
].
node_out
.
size
();
i
++
)
{
auto
*
outgoing_inputs
=
&
graph
->
nodes
[
graph
->
nodes
[
node_index
].
node_out
[
i
]].
node_in
;
auto
it
=
find
(
outgoing_inputs
->
begin
(),
outgoing_inputs
->
end
(),
node_index
);
if
(
it
!=
outgoing_inputs
->
end
())
{
if
(
graph
->
nodes
[
node_index
].
node_in
.
size
()
>
0
)
{
outgoing_inputs
->
at
(
std
::
distance
(
outgoing_inputs
->
begin
(),
it
))
=
graph
->
nodes
[
node_index
].
node_in
[
0
];
for
(
size_t
j
=
1
;
j
<
graph
->
nodes
[
node_index
].
node_in
.
size
();
j
++
)
{
graph
->
nodes
[
graph
->
nodes
[
node_index
].
node_out
[
i
]].
node_in_aux
.
push_back
(
graph
->
nodes
[
node_index
].
node_in
[
j
]);
}
for
(
size_t
j
=
1
;
j
<
graph
->
nodes
[
node_index
].
node_in_aux
.
size
();
j
++
)
{
graph
->
nodes
[
graph
->
nodes
[
node_index
].
node_out
[
i
]].
node_in_aux
.
push_back
(
graph
->
nodes
[
node_index
].
node_in_aux
[
j
]);
}
}
else
{
outgoing_inputs
->
erase
(
it
);
}
}
}
...
...
@@ -206,10 +226,12 @@ std::shared_ptr<Graph> EliminateGraph(const std::shared_ptr<Graph> graph,
Eliminate_Aux
(
node_index
,
graph
,
eli_list
);
}
}
index_list
->
reserve
(
graph
->
nodes
.
size
());
for
(
size_t
i
=
0
;
i
<
(
size_t
)
graph
->
nodes
.
size
();
i
++
)
{
index_list
->
push_back
(
i
);
}
for
(
size_t
i
=
0
;
i
<
(
size_t
)
eli_list
->
size
();
i
++
)
{
if
(
eli_list
->
at
(
i
)[
0
]
>=
index_list
->
size
())
{
MS_LOG
(
EXCEPTION
)
<<
"Failure: Operators' elements out of range."
;
...
...
@@ -219,6 +241,7 @@ std::shared_ptr<Graph> EliminateGraph(const std::shared_ptr<Graph> graph,
index_list
->
at
(
j
)
--
;
}
}
std
::
shared_ptr
<
Graph
>
new_graph
(
new
Graph
);
for
(
size_t
i
=
0
;
i
<
graph
->
nodes
.
size
();
i
++
)
{
if
(
index_list
->
at
(
i
)
>
SIZE_MAX
/
2
)
{
...
...
@@ -226,11 +249,13 @@ std::shared_ptr<Graph> EliminateGraph(const std::shared_ptr<Graph> graph,
}
new_graph
->
nodes
.
push_back
(
graph
->
nodes
[
i
]);
for
(
size_t
j
=
0
;
j
<
new_graph
->
nodes
[
index_list
->
at
(
i
)].
node_in
.
size
();
j
++
)
{
new_graph
->
nodes
[
index_list
->
at
(
i
)].
node_in
[
j
]
=
index_list
->
at
(
new_graph
->
nodes
[
index_list
->
at
(
i
)].
node_in
[
j
]);
auto
*
node_in
=
&
new_graph
->
nodes
[
index_list
->
at
(
i
)].
node_in
;
for
(
size_t
j
=
0
;
j
<
node_in
->
size
();
j
++
)
{
node_in
->
at
(
j
)
=
index_list
->
at
(
node_in
->
at
(
j
));
}
for
(
size_t
j
=
0
;
j
<
new_graph
->
nodes
[
index_list
->
at
(
i
)].
node_out
.
size
();
j
++
)
{
new_graph
->
nodes
[
index_list
->
at
(
i
)].
node_out
[
j
]
=
index_list
->
at
(
new_graph
->
nodes
[
index_list
->
at
(
i
)].
node_out
[
j
]);
auto
*
node_out
=
&
new_graph
->
nodes
[
index_list
->
at
(
i
)].
node_out
;
for
(
size_t
j
=
0
;
j
<
node_out
->
size
();
j
++
)
{
node_out
->
at
(
j
)
=
index_list
->
at
(
node_out
->
at
(
j
));
}
}
return
new_graph
;
...
...
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_parse_graph.h
浏览文件 @
39790ccf
...
...
@@ -59,6 +59,7 @@ const std::map<std::string, OperatorType> DictOpType{
{
PRELU
,
OperatorType
::
kRecPReLU
},
{
L2_NORMALIZE
,
OperatorType
::
kRecElmWiseOp
},
{
TENSOR_ADD
,
OperatorType
::
kRecElmWiseOp
},
{
SUB
,
OperatorType
::
kRecElmWiseOp
},
{
MUL
,
OperatorType
::
kRecElmWiseOp
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录