Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
e5d3bb53
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,发现更多精彩内容 >>
提交
e5d3bb53
编写于
1月 03, 2018
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add caffe ops stat script and fix addn bugs.
上级
793a30ef
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
1529 addition
and
12 deletion
+1529
-12
mace/kernels/addn.h
mace/kernels/addn.h
+2
-7
mace/kernels/opencl/addn.cc
mace/kernels/opencl/addn.cc
+4
-2
mace/ops/addn.h
mace/ops/addn.h
+6
-3
mace/proto/BUILD
mace/proto/BUILD
+9
-0
mace/proto/caffe.proto
mace/proto/caffe.proto
+1459
-0
mace/python/tools/BUILD
mace/python/tools/BUILD
+9
-0
mace/python/tools/caffe_ops_stats.py
mace/python/tools/caffe_ops_stats.py
+38
-0
mace/python/tools/tf_converter_lib.py
mace/python/tools/tf_converter_lib.py
+2
-0
未找到文件。
mace/kernels/addn.h
浏览文件 @
e5d3bb53
...
...
@@ -11,10 +11,9 @@
namespace
mace
{
namespace
kernels
{
struct
AddNFunctorBase
{};
template
<
DeviceType
D
,
typename
T
>
struct
AddNFunctor
:
AddNFunctorBase
{
struct
AddNFunctor
{
void
operator
()(
const
std
::
vector
<
const
Tensor
*>
&
input_tensors
,
Tensor
*
output_tensor
,
StatsFuture
*
future
)
{
output_tensor
->
ResizeLike
(
input_tensors
[
0
]);
...
...
@@ -24,10 +23,6 @@ struct AddNFunctor : AddNFunctorBase {
memset
(
output_ptr
,
0
,
size
*
sizeof
(
T
));
int
n
=
input_tensors
.
size
();
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
MACE_CHECK
(
input_tensors
[
i
]
->
dim
(
0
)
==
output_tensor
->
dim
(
0
));
MACE_CHECK
(
input_tensors
[
i
]
->
dim
(
1
)
==
output_tensor
->
dim
(
1
));
MACE_CHECK
(
input_tensors
[
i
]
->
dim
(
2
)
==
output_tensor
->
dim
(
2
));
MACE_CHECK
(
input_tensors
[
i
]
->
dim
(
3
)
==
output_tensor
->
dim
(
3
));
Tensor
::
MappingGuard
input_map
(
input_tensors
[
i
]);
const
T
*
input_ptr
=
input_tensors
[
i
]
->
data
<
T
>
();
for
(
index_t
j
=
0
;
j
<
size
;
++
j
)
{
...
...
@@ -44,7 +39,7 @@ void AddNFunctor<DeviceType::NEON, float>::operator()(
StatsFuture
*
future
);
template
<
typename
T
>
struct
AddNFunctor
<
DeviceType
::
OPENCL
,
T
>
:
AddNFunctorBase
{
struct
AddNFunctor
<
DeviceType
::
OPENCL
,
T
>
{
void
operator
()(
const
std
::
vector
<
const
Tensor
*>
&
input_tensors
,
Tensor
*
output_tensor
,
StatsFuture
*
future
);
};
...
...
mace/kernels/opencl/addn.cc
浏览文件 @
e5d3bb53
...
...
@@ -17,6 +17,8 @@ static void AddN(const std::vector<const Tensor *> &input_tensors,
if
(
input_tensors
.
size
()
>
4
)
{
MACE_NOT_IMPLEMENTED
;
}
output
->
ResizeLike
(
input_tensors
[
0
]);
const
index_t
batch
=
output
->
dim
(
0
);
const
index_t
height
=
output
->
dim
(
1
);
const
index_t
width
=
output
->
dim
(
2
);
...
...
@@ -36,8 +38,8 @@ static void AddN(const std::vector<const Tensor *> &input_tensors,
uint32_t
idx
=
0
;
for
(
auto
input
:
input_tensors
)
{
addn_kernel
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
())));
addn_kernel
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
())));
}
addn_kernel
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
buffer
())));
...
...
mace/ops/addn.h
浏览文件 @
e5d3bb53
...
...
@@ -17,11 +17,14 @@ class AddNOp : public Operator<D, T> {
:
Operator
<
D
,
T
>
(
operator_def
,
ws
)
{}
bool
Run
(
StatsFuture
*
future
)
override
{
Tensor
*
output_tensor
=
this
->
outputs_
[
0
]
;
Tensor
*
output_tensor
=
this
->
Output
(
0
)
;
int
n
=
this
->
inputs_
.
size
();
vector
<
const
Tensor
*>
inputs
(
n
,
nullptr
);
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
inputs
[
i
]
=
this
->
inputs_
[
i
];
inputs
[
0
]
=
this
->
Input
(
0
);
for
(
int
i
=
1
;
i
<
n
;
++
i
)
{
inputs
[
i
]
=
this
->
Input
(
i
);
MACE_CHECK
(
inputs
[
0
]
->
dim_size
()
==
inputs
[
i
]
->
dim_size
());
MACE_CHECK
(
inputs
[
0
]
->
size
()
==
inputs
[
i
]
->
size
());
}
functor_
(
inputs
,
output_tensor
,
future
);
...
...
mace/proto/BUILD
浏览文件 @
e5d3bb53
...
...
@@ -18,3 +18,12 @@ py_proto_library(
srcs_version
=
"PY2AND3"
,
deps
=
[
"@com_google_protobuf//:protobuf_python"
],
)
py_proto_library
(
name
=
"caffe_py"
,
srcs
=
[
"caffe.proto"
],
default_runtime
=
"@com_google_protobuf//:protobuf_python"
,
protoc
=
"@com_google_protobuf//:protoc"
,
srcs_version
=
"PY2AND3"
,
deps
=
[
"@com_google_protobuf//:protobuf_python"
],
)
mace/proto/caffe.proto
0 → 100644
浏览文件 @
e5d3bb53
此差异已折叠。
点击以展开。
mace/python/tools/BUILD
浏览文件 @
e5d3bb53
...
...
@@ -43,3 +43,12 @@ py_binary(
"//mace/proto:mace_py"
,
],
)
py_binary
(
name
=
"caffe_ops_stats"
,
srcs
=
[
"caffe_ops_stats.py"
],
srcs_version
=
"PY2AND3"
,
deps
=
[
"//mace/proto:caffe_py"
,
],
)
mace/python/tools/caffe_ops_stats.py
0 → 100644
浏览文件 @
e5d3bb53
from
mace.proto
import
caffe_pb2
import
google.protobuf.text_format
import
operator
import
functools
import
argparse
import
sys
import
six
FLAGS
=
None
def
main
(
unused_args
):
net
=
caffe_pb2
.
NetParameter
()
with
open
(
FLAGS
.
input
)
as
f
:
google
.
protobuf
.
text_format
.
Merge
(
str
(
f
.
read
()),
net
)
ops
=
{}
for
layer
in
net
.
layer
:
if
layer
.
type
not
in
ops
:
ops
[
layer
.
type
]
=
1
else
:
ops
[
layer
.
type
]
+=
1
for
key
,
value
in
sorted
(
ops
.
items
(),
key
=
operator
.
itemgetter
(
1
)):
print
key
,
":"
,
value
def
parse_args
():
'''Parses command line arguments.'''
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--input'
,
type
=
str
,
default
=
''
,
help
=
'Caffe
\'
GraphDef
\'
file to load.'
)
return
parser
.
parse_known_args
()
if
__name__
==
'__main__'
:
FLAGS
,
unparsed
=
parse_args
()
main
(
unused_args
=
[
sys
.
argv
[
0
]]
+
unparsed
)
mace/python/tools/tf_converter_lib.py
浏览文件 @
e5d3bb53
...
...
@@ -465,6 +465,8 @@ class TFConverter(object):
and
self
.
tf_graph
[
final_op
.
name
][
0
].
type
==
'BatchToSpaceND'
:
final_op
=
self
.
tf_graph
[
final_op
.
name
][
0
]
self
.
resolved_ops
[
final_op
.
name
]
=
1
self
.
unused_tensor
.
add
(
get_input_tensor
(
final_op
,
1
).
name
)
self
.
unused_tensor
.
add
(
get_input_tensor
(
final_op
,
2
).
name
)
else
:
raise
Exception
(
'Convert atrous conv error: no BatchToSpaceND op'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录