Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
66553ac3
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看板
提交
66553ac3
编写于
7月 08, 2020
作者:
H
hongxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize code
上级
9febf7fd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
9 addition
and
13 deletion
+9
-13
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_generate_strategy.cc
.../parallel/auto_parallel/rec_core/rec_generate_strategy.cc
+1
-2
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_parse_graph.cc
.../ccsrc/parallel/auto_parallel/rec_core/rec_parse_graph.cc
+1
-11
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_parse_graph.h
...e/ccsrc/parallel/auto_parallel/rec_core/rec_parse_graph.h
+7
-0
未找到文件。
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_generate_strategy.cc
浏览文件 @
66553ac3
...
...
@@ -168,12 +168,11 @@ std::vector<std::vector<int32_t>> PrepareGatherV2(const std::vector<std::shared_
const
size_t
iter_ops
,
std
::
vector
<
int32_t
>
s
)
{
std
::
vector
<
std
::
vector
<
int32_t
>>
strategies
;
int32_t
axis
=
0
;
auto
axis_input
=
GetValue
<
int
>
(
ops
[
iter_ops
]
->
input_value
().
at
(
2
));
if
(
axis_input
<
0
)
{
axis_input
+=
SizeToInt
(
ops
[
iter_ops
]
->
inputs_tensor_info
()[
0
].
shape
().
size
());
}
axis
=
axis_input
;
int32_t
axis
=
axis_input
;
if
(
axis
>=
SizeToInt
(
s
.
size
()))
{
MS_LOG
(
EXCEPTION
)
<<
"Failure: GatherV2' axis out of range."
;
}
...
...
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_parse_graph.cc
浏览文件 @
66553ac3
...
...
@@ -20,7 +20,6 @@
#include <memory>
#include <string>
#include <vector>
#include <set>
#include "ir/value.h"
#include "parallel/auto_parallel/rec_core/rec_graph.h"
...
...
@@ -215,23 +214,16 @@ std::shared_ptr<Graph> EliminateGraph(const std::shared_ptr<Graph> &graph,
const
std
::
shared_ptr
<
std
::
vector
<
std
::
vector
<
size_t
>>>
&
eli_list
,
const
std
::
shared_ptr
<
std
::
vector
<
size_t
>>
&
index_list
)
{
MS_EXCEPTION_IF_NULL
(
graph
);
static
const
std
::
set
<
OperatorType
>
elementwise_type
=
{
OperatorType
::
kRecReLU
,
OperatorType
::
kRecLog
,
OperatorType
::
kRecExp
,
OperatorType
::
kRecAdd
,
OperatorType
::
kRecElmWiseOp
,
OperatorType
::
kRecBiasAdd
,
OperatorType
::
kRecSub
,
OperatorType
::
kRecMul
,
OperatorType
::
kRecDiv
,
OperatorType
::
kRecSqueeze
,
OperatorType
::
kRecReduce
,
OperatorType
::
kRecCast
,
OperatorType
::
kRecReshape
,
OperatorType
::
kRecGatherV2
,
OperatorType
::
kRecArgWithValue
};
for
(
size_t
node_index
=
0
;
node_index
<
(
size_t
)
graph
->
nodes
.
size
();
node_index
++
)
{
auto
type
=
graph
->
nodes
[
node_index
].
apply
.
op_type
;
if
(
elementwise_type
.
find
(
type
)
!=
elementwise_t
ype
.
end
())
{
if
(
ElementWiseOpType
.
find
(
type
)
!=
ElementWiseOpT
ype
.
end
())
{
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."
;
...
...
@@ -241,13 +233,11 @@ 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
)
{
continue
;
}
new_graph
->
nodes
.
push_back
(
graph
->
nodes
[
i
]);
auto
*
node_in
=
&
new_graph
->
nodes
[
index_list
->
at
(
i
)].
node_in
;
for
(
size_t
j
=
node_in
->
size
();
j
>
0
;
j
--
)
{
...
...
mindspore/ccsrc/parallel/auto_parallel/rec_core/rec_parse_graph.h
浏览文件 @
66553ac3
...
...
@@ -22,12 +22,19 @@
#include <string>
#include <utility>
#include <vector>
#include <set>
#include "parallel/auto_parallel/rec_core/rec_graph.h"
#include "parallel/ops_info/operator_info.h"
namespace
mindspore
{
namespace
parallel
{
static
const
std
::
set
<
OperatorType
>
ElementWiseOpType
=
{
OperatorType
::
kRecReLU
,
OperatorType
::
kRecLog
,
OperatorType
::
kRecExp
,
OperatorType
::
kRecAdd
,
OperatorType
::
kRecElmWiseOp
,
OperatorType
::
kRecBiasAdd
,
OperatorType
::
kRecSub
,
OperatorType
::
kRecMul
,
OperatorType
::
kRecDiv
,
OperatorType
::
kRecSqueeze
,
OperatorType
::
kRecReduce
,
OperatorType
::
kRecCast
,
OperatorType
::
kRecReshape
,
OperatorType
::
kRecGatherV2
,
OperatorType
::
kRecArgWithValue
};
const
std
::
map
<
std
::
string
,
OperatorType
>
DictOpType
{
{
MATMUL
,
OperatorType
::
kRecMatMul
},
{
CONV2D
,
OperatorType
::
kRecConvolution
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录