Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
179d8a27
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看板
提交
179d8a27
编写于
8月 07, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 07, 2020
浏览文件
操作
浏览文件
下载
差异文件
!4064 fix pass fail when ReduceMin's axis set with one int number
Merge pull request !4064 from huanghui/reduce-min-fission-pass
上级
a3959071
d7f28a72
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
11 deletion
+14
-11
mindspore/ccsrc/backend/optimizer/ascend/ir_fission/reduce_min_fission.cc
...backend/optimizer/ascend/ir_fission/reduce_min_fission.cc
+14
-11
未找到文件。
mindspore/ccsrc/backend/optimizer/ascend/ir_fission/reduce_min_fission.cc
浏览文件 @
179d8a27
...
...
@@ -32,7 +32,7 @@ CNodePtr CreateReduceMin(const FuncGraphPtr &graph, const AnfNodePtr &input, con
return
reduce_min
;
}
bool
NeedOptmize
(
const
TypeId
&
dtype
,
const
std
::
vector
<
size_t
>
&
shape
,
const
std
::
vector
<
int
>
&
axis
)
{
bool
NeedOpt
i
mize
(
const
TypeId
&
dtype
,
const
std
::
vector
<
size_t
>
&
shape
,
const
std
::
vector
<
int
>
&
axis
)
{
if
(
dtype
!=
kNumberTypeFloat32
)
{
MS_LOG
(
INFO
)
<<
"ReduceMin's input Dtype is not float32, no need optimize!"
;
return
false
;
...
...
@@ -84,7 +84,7 @@ std::vector<size_t> GetInferShape(const std::vector<size_t> &shape, const std::v
for
(
size_t
item
=
0
;
item
<
shape
.
size
();
++
item
)
{
if
(
axis_first
.
end
()
!=
std
::
find
(
axis_first
.
begin
(),
axis_first
.
end
(),
item
))
{
if
(
keep_dims
)
{
// If keep_dims is true, curre
tn dime
sion set to 1
// If keep_dims is true, curre
nt dimen
sion set to 1
shape_first
.
push_back
(
1
);
}
}
else
{
...
...
@@ -110,28 +110,31 @@ const AnfNodePtr ReduceMinFission::Process(const FuncGraphPtr &graph, const AnfN
CheckCNodeInputSize
(
cnode
,
2
);
auto
shape
=
AnfAlgo
::
GetPrevNodeOutputInferShape
(
cnode
,
0
);
auto
dtype
=
AnfAlgo
::
GetPrevNodeOutputInferDataType
(
cnode
,
0
);
if
(
!
AnfAlgo
::
HasNodeAttr
(
kAttrAxis
,
cnode
))
{
MS_LOG
(
INFO
)
<<
"ReduceMin has no axis, no need optimize!"
;
auto
prim
=
AnfAlgo
::
GetCNodePrimitive
(
cnode
);
MS_EXCEPTION_IF_NULL
(
prim
);
if
(
!
prim
->
HasAttr
(
kAttrAxis
)
||
!
prim
->
HasAttr
(
kAttrKeepDims
))
{
MS_LOG
(
INFO
)
<<
"ReduceMin has no axis or keep_dims, no need optimize!"
;
return
nullptr
;
}
auto
axis
=
AnfAlgo
::
GetNodeAttr
<
std
::
vector
<
int
>>
(
cnode
,
kAttrAxis
);
if
(
!
AnfAlgo
::
HasNodeAttr
(
kAttrKeepDims
,
cnode
))
{
MS_LOG
(
INFO
)
<<
"ReduceMin has no keep_dims, no need optimize!"
;
auto
axis
_value
=
prim
->
GetAttr
(
kAttrAxis
);
MS_EXCEPTION_IF_NULL
(
axis_value
);
if
(
!
axis_value
->
isa
<
ValueSequeue
>
())
{
return
nullptr
;
}
auto
axis
=
AnfAlgo
::
GetNodeAttr
<
std
::
vector
<
int
>>
(
cnode
,
kAttrAxis
);
auto
keep_dims
=
AnfAlgo
::
GetNodeAttr
<
bool
>
(
cnode
,
kAttrKeepDims
);
if
(
!
NeedOptmize
(
dtype
,
shape
,
axis
))
{
if
(
!
NeedOpt
i
mize
(
dtype
,
shape
,
axis
))
{
MS_LOG
(
INFO
)
<<
"No need optimize for this ReduceMin. "
<<
cnode
->
DebugString
();
return
nullptr
;
}
// Create reduce_min1
CNodePtr
reduce_min1
=
CreateReduceMin
(
graph
,
cnode
->
input
(
1
),
cnode
);
std
::
vector
<
int
>
axis_fi
sr
t
=
CalFirstAxis
(
shape
,
axis
);
std
::
vector
<
size_t
>
shape_first
=
GetInferShape
(
shape
,
axis_fi
sr
t
,
keep_dims
);
std
::
vector
<
int
>
axis_fi
rs
t
=
CalFirstAxis
(
shape
,
axis
);
std
::
vector
<
size_t
>
shape_first
=
GetInferShape
(
shape
,
axis_fi
rs
t
,
keep_dims
);
AnfAlgo
::
SetOutputInferTypeAndShape
({
dtype
},
{
shape_first
},
reduce_min1
.
get
());
AnfAlgo
::
SetNodeAttr
(
kAttrAxis
,
MakeValue
(
axis_fi
sr
t
),
reduce_min1
);
AnfAlgo
::
SetNodeAttr
(
kAttrAxis
,
MakeValue
(
axis_fi
rs
t
),
reduce_min1
);
// Create reduce_min2
CNodePtr
reduce_min2
=
CreateReduceMin
(
graph
,
reduce_min1
,
cnode
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录