Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mr.Vain
Mace
提交
1bd4f908
Mace
项目概览
Mr.Vain
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
1
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
1bd4f908
编写于
12月 29, 2018
作者:
B
Bin Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix hexagon supernode without biasadd
上级
97e2d5d4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
4 deletion
+20
-4
mace/python/tools/converter_tool/hexagon_converter.py
mace/python/tools/converter_tool/hexagon_converter.py
+5
-3
tools/validate.py
tools/validate.py
+15
-1
未找到文件。
mace/python/tools/converter_tool/hexagon_converter.py
浏览文件 @
1bd4f908
...
@@ -12,6 +12,9 @@
...
@@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
copy
import
numpy
as
np
from
operator
import
mul
from
mace.proto
import
mace_pb2
from
mace.proto
import
mace_pb2
from
mace.python.tools.converter_tool
import
base_converter
from
mace.python.tools.converter_tool
import
base_converter
...
@@ -24,9 +27,6 @@ from mace.python.tools.converter_tool.base_converter import PoolingType
...
@@ -24,9 +27,6 @@ from mace.python.tools.converter_tool.base_converter import PoolingType
from
mace.python.tools.convert_util
import
mace_check
from
mace.python.tools.convert_util
import
mace_check
from
mace.python.tools
import
graph_util
from
mace.python.tools
import
graph_util
import
copy
from
operator
import
mul
class
HexagonOps
(
object
):
class
HexagonOps
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -133,6 +133,8 @@ class HexagonConverter(base_converter.ConverterInterface):
...
@@ -133,6 +133,8 @@ class HexagonConverter(base_converter.ConverterInterface):
print
(
'Supernode requires biasadd, we add it.'
)
print
(
'Supernode requires biasadd, we add it.'
)
bias_data
=
np
.
zeros
(
channels
,
dtype
=
int
)
bias_data
=
np
.
zeros
(
channels
,
dtype
=
int
)
bias_tensor
=
self
.
_model
.
tensors
.
add
()
bias_tensor
=
self
.
_model
.
tensors
.
add
()
bias_tensor
.
data_type
=
mace_pb2
.
DT_INT32
bias_tensor
.
dims
.
extend
([
channels
])
bias_tensor
.
int32_data
.
extend
(
bias_data
)
bias_tensor
.
int32_data
.
extend
(
bias_data
)
bias_tensor
.
minval
=
0
bias_tensor
.
minval
=
0
bias_tensor
.
maxval
=
0
bias_tensor
.
maxval
=
0
...
...
tools/validate.py
浏览文件 @
1bd4f908
...
@@ -66,9 +66,22 @@ def calculate_similarity(u, v, data_type=np.float64):
...
@@ -66,9 +66,22 @@ def calculate_similarity(u, v, data_type=np.float64):
return
np
.
dot
(
u
,
v
)
/
(
np
.
linalg
.
norm
(
u
)
*
np
.
linalg
.
norm
(
v
))
return
np
.
dot
(
u
,
v
)
/
(
np
.
linalg
.
norm
(
u
)
*
np
.
linalg
.
norm
(
v
))
def
calculate_pixel_accuracy
(
out_value
,
mace_out_value
):
out_value
=
out_value
.
reshape
((
-
1
,
out_value
.
shape
[
-
1
]))
batches
=
out_value
.
shape
[
0
]
classes
=
out_value
.
shape
[
1
]
mace_out_value
=
mace_out_value
.
reshape
((
batches
,
classes
))
correct_count
=
0
for
i
in
range
(
batches
):
if
np
.
argmax
(
out_value
[
i
])
==
np
.
argmax
(
mace_out_value
[
i
]):
correct_count
+=
1
return
1.0
*
correct_count
/
batches
def
compare_output
(
platform
,
device_type
,
output_name
,
mace_out_value
,
def
compare_output
(
platform
,
device_type
,
output_name
,
mace_out_value
,
out_value
,
validation_threshold
):
out_value
,
validation_threshold
):
if
mace_out_value
.
size
!=
0
:
if
mace_out_value
.
size
!=
0
:
pixel_accuracy
=
calculate_pixel_accuracy
(
out_value
,
mace_out_value
)
out_value
=
out_value
.
reshape
(
-
1
)
out_value
=
out_value
.
reshape
(
-
1
)
mace_out_value
=
mace_out_value
.
reshape
(
-
1
)
mace_out_value
=
mace_out_value
.
reshape
(
-
1
)
assert
len
(
out_value
)
==
len
(
mace_out_value
)
assert
len
(
out_value
)
==
len
(
mace_out_value
)
...
@@ -76,7 +89,8 @@ def compare_output(platform, device_type, output_name, mace_out_value,
...
@@ -76,7 +89,8 @@ def compare_output(platform, device_type, output_name, mace_out_value,
similarity
=
calculate_similarity
(
out_value
,
mace_out_value
)
similarity
=
calculate_similarity
(
out_value
,
mace_out_value
)
common
.
MaceLogger
.
summary
(
common
.
MaceLogger
.
summary
(
output_name
+
' MACE VS '
+
platform
.
upper
()
output_name
+
' MACE VS '
+
platform
.
upper
()
+
' similarity: '
+
str
(
similarity
)
+
' , sqnr: '
+
str
(
sqnr
))
+
' similarity: '
+
str
(
similarity
)
+
' , sqnr: '
+
str
(
sqnr
)
+
' , pixel_accuracy: '
+
str
(
pixel_accuracy
))
if
similarity
>
validation_threshold
:
if
similarity
>
validation_threshold
:
common
.
MaceLogger
.
summary
(
common
.
MaceLogger
.
summary
(
common
.
StringFormatter
.
block
(
"Similarity Test Passed"
))
common
.
StringFormatter
.
block
(
"Similarity Test Passed"
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录