Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
7d632862
Mace
项目概览
Xiaomi
/
Mace
通知
106
Star
40
Fork
27
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7d632862
编写于
5月 16, 2018
作者:
刘
刘琦
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'transform' into 'master'
Refactor caffe depthwise See merge request !481
上级
1f9b2ee2
1d0f9cc1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
4 deletion
+14
-4
mace/python/tools/converter_tool/caffe_converter.py
mace/python/tools/converter_tool/caffe_converter.py
+8
-2
mace/python/tools/converter_tool/shape_inference.py
mace/python/tools/converter_tool/shape_inference.py
+5
-1
mace/python/tools/converter_tool/transformer.py
mace/python/tools/converter_tool/transformer.py
+1
-1
未找到文件。
mace/python/tools/converter_tool/caffe_converter.py
浏览文件 @
7d632862
...
...
@@ -144,6 +144,7 @@ class CaffeConverter(base_converter.ConverterInterface):
'ReLU'
:
ActivationType
.
RELU
,
'PReLU'
:
ActivationType
.
PRELU
,
'TanH'
:
ActivationType
.
TANH
,
'Sigmoid'
:
ActivationType
.
SIGMOID
,
}
def
__init__
(
self
,
option
,
src_model_file
,
src_weight_file
):
...
...
@@ -337,10 +338,15 @@ class CaffeConverter(base_converter.ConverterInterface):
param
=
caffe_op
.
layer
.
convolution_param
is_depthwise
=
False
if
param
.
HasField
(
caffe_group_str
):
mace_check
(
param
.
group
==
caffe_op
.
blob
[
0
].
shape
[
1
]
and
caffe_op
.
blob
[
0
].
shape
[
0
]
==
1
,
filter_data
=
caffe_op
.
blobs
[
0
]
mace_check
(
param
.
group
==
filter_data
.
shape
[
0
]
and
filter_data
.
shape
[
1
]
==
1
,
"Mace do not support group convolution yet"
)
is_depthwise
=
True
caffe_op
.
blobs
[
0
]
=
filter_data
.
reshape
(
1
,
filter_data
.
shape
[
0
],
filter_data
.
shape
[
2
],
filter_data
.
shape
[
3
])
if
is_depthwise
:
op
.
type
=
MaceOp
.
DepthwiseConv2d
.
name
...
...
mace/python/tools/converter_tool/shape_inference.py
浏览文件 @
7d632862
...
...
@@ -17,6 +17,7 @@ class ShapeInference(object):
def
__init__
(
self
,
net
,
input_nodes
):
self
.
_op_shape_inference
=
{
MaceOp
.
Conv2D
.
name
:
self
.
infer_shape_conv_pool_shape
,
MaceOp
.
DepthwiseConv2d
.
name
:
self
.
infer_shape_conv_pool_shape
,
MaceOp
.
Eltwise
.
name
:
self
.
infer_shape_general
,
MaceOp
.
FoldedBatchNorm
.
name
:
self
.
infer_shape_general
,
MaceOp
.
AddN
.
name
:
self
.
infer_shape_general
,
...
...
@@ -104,7 +105,10 @@ class ShapeInference(object):
if
ConverterUtil
.
data_format
(
op
)
==
DataFormat
.
NCHW
\
and
ConverterUtil
.
filter_format
(
self
.
_net
)
==
FilterFormat
.
OIHW
:
# noqa
# filter format: OIHW
output_shape
[
1
]
=
filter_shape
[
0
]
if
op
.
type
==
MaceOp
.
DepthwiseConv2d
.
name
:
output_shape
[
1
]
=
filter_shape
[
0
]
*
filter_shape
[
1
]
else
:
output_shape
[
1
]
=
filter_shape
[
0
]
output_shape
[
2
]
=
int
(
round_func
((
input_shape
[
2
]
+
paddings
[
0
]
-
filter_shape
[
2
]
-
(
filter_shape
[
2
]
-
1
)
*
...
...
mace/python/tools/converter_tool/transformer.py
浏览文件 @
7d632862
...
...
@@ -692,7 +692,7 @@ class Transformer(base_converter.ConverterInterface):
filter_data
=
filter_data
.
transpose
(
2
,
3
,
0
,
1
)
filter
.
float_data
[:]
=
filter_data
.
flat
filter
.
dims
[:]
=
filter_data
.
shape
elif
op
.
type
==
MaceOp
.
Depthwise
c
onv2d
.
name
:
elif
op
.
type
==
MaceOp
.
Depthwise
C
onv2d
.
name
:
filter_data
=
filter_data
.
transpose
(
2
,
3
,
1
,
0
)
filter
.
float_data
[:]
=
filter_data
.
flat
filter
.
dims
[:]
=
filter_data
.
shape
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录