Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
7017ac3f
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看板
提交
7017ac3f
编写于
5月 13, 2020
作者:
W
wangcong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
depthwisecon2d-eltwise pass
上级
89f55e63
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
12 deletion
+15
-12
mindspore/ccsrc/kernel/tbe/tbe_kernel_build.cc
mindspore/ccsrc/kernel/tbe/tbe_kernel_build.cc
+11
-8
mindspore/ccsrc/kernel/tbe/tbe_kernel_build.h
mindspore/ccsrc/kernel/tbe/tbe_kernel_build.h
+1
-1
mindspore/ccsrc/operator/ops.cc
mindspore/ccsrc/operator/ops.cc
+1
-0
mindspore/ccsrc/pre_activate/ascend/buffer_fusion/buffer_fusion.cc
.../ccsrc/pre_activate/ascend/buffer_fusion/buffer_fusion.cc
+2
-3
未找到文件。
mindspore/ccsrc/kernel/tbe/tbe_kernel_build.cc
浏览文件 @
7017ac3f
...
...
@@ -38,11 +38,6 @@ constexpr auto kFusionKernelNamePrfix = "te_fusion";
constexpr
auto
kOptional
=
"optional_"
;
constexpr
auto
kOpFormat_FRACTAL_Z
=
"FRACTAL_Z"
;
std
::
map
<
std
::
string
,
std
::
string
>
TbeKernelBuild
::
buffer_fussion_op_map_
=
{
{
"DepthwiseConv2dNative"
,
"DepthwiseConv2D"
},
{
"TensorAdd"
,
"Add"
}
};
std
::
string
NormalizeFullScopeName
(
const
string
&
full_scope_name
)
{
// exp:Default/ReLU-op0 -->Default_ReLU_op0
string
normal_ret
=
full_scope_name
;
...
...
@@ -726,6 +721,16 @@ size_t TbeKernelBuild::GetOptionalInput(const mindspore::CNodePtr &cnode, bool i
return
(
op_info
->
inputs_ptr
().
size
()
+
1
-
cnode
->
inputs
().
size
());
}
std
::
string
TbeKernelBuild
::
GetRealOpType
(
const
std
::
string
&
origin_type
)
{
static
std
::
map
<
std
::
string
,
std
::
string
>
TbeKernelBuild
::
buffer_fussion_op_map
=
{
{
"DepthwiseConv2dNative"
,
"DepthwiseConv2D"
},
{
"TensorAdd"
,
"Add"
}};
string
result
=
origin_type
;
if
(
buffer_fussion_op_map
.
find
(
origin_type
)
!=
buffer_fussion_op_map
.
end
())
{
result
=
buffer_fussion_op_map
[
origin_type
];
}
return
result
;
}
bool
TbeKernelBuild
::
GenFusionComputeInputJson
(
const
mindspore
::
CNodePtr
&
cnode
,
std
::
vector
<
std
::
vector
<
mindspore
::
AnfNodePtr
>>::
iterator
*
layer_iter
,
std
::
vector
<
nlohmann
::
json
>
*
input_desc_list
,
size_t
*
index
)
{
...
...
@@ -831,9 +836,7 @@ bool TbeKernelBuild::GenFusionComputeJson(const mindspore::AnfNodePtr &compute_n
// gen others
auto
type
=
AnfAlgo
::
GetCNodeName
(
cnode
);
// replace special op type for buffer fusion op
if
(
buffer_fussion_op_map_
.
find
(
type
)
!=
buffer_fussion_op_map_
.
end
())
{
type
=
buffer_fussion_op_map_
[
type
];
}
type
=
GetRealOpType
(
type
);
(
*
compute_op_str
)[
"type"
]
=
type
;
tbe
::
TbeAdapter
::
NormalizeFuncName
(
&
type
);
(
*
compute_op_str
)[
"func_name"
]
=
type
;
...
...
mindspore/ccsrc/kernel/tbe/tbe_kernel_build.h
浏览文件 @
7017ac3f
...
...
@@ -76,7 +76,7 @@ class TbeKernelBuild {
std
::
map
<
const
AnfNodePtr
,
FusionDataType
>
*
spec_data_input
);
static
bool
IsDynamicInput
(
const
CNodePtr
&
cnode
);
static
size_t
GetOptionalInput
(
const
CNodePtr
&
cnode
,
bool
is_dynamic_input
);
st
atic
std
::
map
<
std
::
string
,
std
::
string
>
buffer_fussion_op_map_
;
st
d
::
string
GetRealOpType
(
const
std
::
string
&
origin_type
)
;
};
class
TbeKernelJsonCreator
{
...
...
mindspore/ccsrc/operator/ops.cc
浏览文件 @
7017ac3f
...
...
@@ -200,6 +200,7 @@ const PrimitivePtr kPrimOneHot = std::make_shared<Primitive>("OneHot");
const
PrimitivePtr
kPrimGelu
=
std
::
make_shared
<
Primitive
>
(
"Gelu"
);
const
PrimitivePtr
kPrimGeluGrad
=
std
::
make_shared
<
Primitive
>
(
"GeluGrad"
);
const
PrimitivePtr
kPrimRelu
=
std
::
make_shared
<
Primitive
>
(
"ReLU"
);
const
PrimitivePtr
kPrimReluV2
=
std
::
make_shared
<
Primitive
>
(
"ReLUV2"
);
const
PrimitivePtr
kPrimZerosLikeTensor
=
std
::
make_shared
<
Primitive
>
(
"zeros_like_tensor"
);
const
PrimitivePtr
kPrimFakeBprop
=
std
::
make_shared
<
Primitive
>
(
"fake_bprop"
);
...
...
mindspore/ccsrc/pre_activate/ascend/buffer_fusion/buffer_fusion.cc
浏览文件 @
7017ac3f
...
...
@@ -555,7 +555,7 @@ void BufferFusion::MatchDepthwiseConvRelu(const CNodePtr &cnode, const session::
// DepthwiseConvolution--->Elemwise
auto
depthwise_conv
=
cnode
->
input
(
1
);
MS_EXCEPTION_IF_NULL
(
depthwise_conv
);
if
(
cnode
->
isa
<
CNode
>
()
&&
AnfAlgo
::
GetCNodeName
(
depthwise_conv
)
==
prim
::
kPrimDepthwiseConv2dNative
->
name
(
))
{
if
(
cnode
->
isa
<
CNode
>
()
&&
IsPrimitiveCNode
(
depthwise_conv
,
prim
::
kPrimDepthwiseConv2dNative
))
{
std
::
vector
<
int
>
output_used_num
{
SizeToInt
(
manager
->
node_users
()[
depthwise_conv
].
size
())};
AnfAlgo
::
SetNodeAttr
(
kAttrOutputUsedNum
,
MakeValue
(
output_used_num
),
depthwise_conv
);
std
::
unordered_set
<
AnfNodePtr
>
record
{
cnode
,
depthwise_conv
};
...
...
@@ -566,8 +566,7 @@ void BufferFusion::MatchDepthwiseConvRelu(const CNodePtr &cnode, const session::
// Elemwise-->DepthwiseConvolution
auto
relu
=
cnode
->
input
(
1
);
MS_EXCEPTION_IF_NULL
(
relu
);
if
(
cnode
->
isa
<
CNode
>
()
&&
(
AnfAlgo
::
GetCNodeName
(
relu
)
==
prim
::
kPrimRelu
->
name
()
||
AnfAlgo
::
GetCNodeName
(
relu
)
==
kReluV2OpName
))
{
if
(
cnode
->
isa
<
CNode
>
()
&&
(
IsPrimitiveCNode
(
relu
,
prim
::
kPrimRelu
)
||
IsPrimitiveCNode
(
relu
,
prim
::
kPrimReluV2
)))
{
std
::
vector
<
int
>
output_used_num
{
SizeToInt
(
manager
->
node_users
()[
relu
].
size
())};
AnfAlgo
::
SetNodeAttr
(
kAttrOutputUsedNum
,
MakeValue
(
output_used_num
),
relu
);
std
::
unordered_set
<
AnfNodePtr
>
record
{
cnode
,
relu
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录