Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
Mace
提交
64d30558
Mace
项目概览
慢慢CG
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
0
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看板
提交
64d30558
编写于
11月 22, 2017
作者:
W
wuchenghui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add QuantizedResizeBilinear_8 op test
上级
3539dea7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
141 addition
and
1 deletion
+141
-1
.gitignore
.gitignore
+1
-1
mace/dsp/test/quantized_resize_bilinear_test.cc
mace/dsp/test/quantized_resize_bilinear_test.cc
+140
-0
未找到文件。
.gitignore
浏览文件 @
64d30558
bazel-*
/
bazel-*
tags
.idea/
cmake-build-debug/
...
...
mace/dsp/test/quantized_resize_bilinear_test.cc
0 → 100644
浏览文件 @
64d30558
//
// Copyright (c) 2017 XiaoMi All rights reserved.
//
#include "mace/dsp/hexagon_control_wrapper.h"
#include "gtest/gtest.h"
using
namespace
mace
;
static
NetDef
BuildNetDef
()
{
std
::
cout
<<
"Building net def"
<<
std
::
endl
;
NetDef
net
;
net
.
set_name
(
"quantized_resize_bilinear_test"
);
// input op
OperatorDef
*
input_op
=
net
.
add_op
();
input_op
->
set_name
(
"input_node"
);
input_op
->
set_type
(
"INPUT"
);
input_op
->
set_node_id
(
0
);
input_op
->
set_padding
(
0
);
input_op
->
add_out_max_byte_size
(
1000
);
// relu op
OperatorDef
*
resize_bilinear_op
=
net
.
add_op
();
resize_bilinear_op
->
set_name
(
"relu"
);
resize_bilinear_op
->
set_type
(
"QuantizedResizeBilinear_8"
);
resize_bilinear_op
->
set_node_id
(
1
);
resize_bilinear_op
->
set_padding
(
0
);
resize_bilinear_op
->
add_input
(
"input_node"
);
resize_bilinear_op
->
add_input
(
"new_dim"
);
resize_bilinear_op
->
add_input
(
"input_min"
);
resize_bilinear_op
->
add_input
(
"input_max"
);
resize_bilinear_op
->
add_output
(
"resize_bilinear:0"
);
resize_bilinear_op
->
add_output
(
"resize_bilinear:1"
);
resize_bilinear_op
->
add_output
(
"resize_bilinear:2"
);
NodeInput
*
input_node_input
=
resize_bilinear_op
->
add_node_input
();
input_node_input
->
set_node_id
(
0
);
input_node_input
->
set_output_port
(
0
);
input_node_input
=
resize_bilinear_op
->
add_node_input
();
input_node_input
->
set_node_id
(
10
);
input_node_input
->
set_output_port
(
0
);
input_node_input
=
resize_bilinear_op
->
add_node_input
();
input_node_input
->
set_node_id
(
11
);
input_node_input
->
set_output_port
(
0
);
input_node_input
=
resize_bilinear_op
->
add_node_input
();
input_node_input
->
set_node_id
(
12
);
input_node_input
->
set_output_port
(
0
);
resize_bilinear_op
->
add_out_max_byte_size
(
1000
);
resize_bilinear_op
->
add_out_max_byte_size
(
1000
);
resize_bilinear_op
->
add_out_max_byte_size
(
1000
);
// output op
OperatorDef
*
output_op
=
net
.
add_op
();
output_op
->
set_name
(
"__output__"
);
output_op
->
set_type
(
"OUTPUT"
);
output_op
->
set_op_id
(
2
);
input_node_input
=
output_op
->
add_node_input
();
input_node_input
->
set_node_id
(
1
);
input_node_input
->
set_output_port
(
0
);
// tensor
TensorProto
*
new_dim_tensor
=
net
.
add_tensors
();
new_dim_tensor
->
set_name
(
"new_dim"
);
new_dim_tensor
->
add_dims
(
2
);
new_dim_tensor
->
set_data_type
(
DataType
::
DT_INT32
);
new_dim_tensor
->
set_node_id
(
10
);
new_dim_tensor
->
add_int32_data
(
1
);
new_dim_tensor
->
add_int32_data
(
1
);
TensorProto
*
input_min_tensor
=
net
.
add_tensors
();
input_min_tensor
->
set_name
(
"input_min"
);
input_min_tensor
->
add_dims
(
1
);
input_min_tensor
->
set_data_type
(
DataType
::
DT_FLOAT
);
input_min_tensor
->
set_node_id
(
11
);
input_min_tensor
->
add_float_data
(
-
100.0
);
TensorProto
*
input_max_tensor
=
net
.
add_tensors
();
input_max_tensor
->
set_name
(
"input_max"
);
input_max_tensor
->
add_dims
(
1
);
input_max_tensor
->
set_data_type
(
DataType
::
DT_FLOAT
);
input_max_tensor
->
set_node_id
(
12
);
input_max_tensor
->
add_float_data
(
100.0
);
// input & output info
InputInfo
*
input_info
=
net
.
add_input_info
();
input_info
->
set_name
(
"input_node"
);
input_info
->
set_node_id
(
0
);
input_info
->
add_dims
(
1
);
input_info
->
add_dims
(
2
);
input_info
->
add_dims
(
2
);
input_info
->
add_dims
(
128
);
input_info
->
set_data_type
(
DataType
::
DT_UINT8
);
input_info
->
set_max_byte_size
(
1000
);
OutputInfo
*
output_info
=
net
.
add_output_info
();
output_info
->
set_name
(
"output_node"
);
output_info
->
set_node_id
(
1
);
output_info
->
add_dims
(
1
);
output_info
->
add_dims
(
1
);
output_info
->
add_dims
(
1
);
output_info
->
add_dims
(
128
);
output_info
->
set_data_type
(
DataType
::
DT_UINT8
);
output_info
->
set_max_byte_size
(
1000
);
return
net
;
}
TEST
(
QuantizedResizeBilinearTest
,
QuantizedResizeBilinear
)
{
testing
::
internal
::
LogToStderr
();
HexagonControlWrapper
wrapper
;
wrapper
.
Init
();
wrapper
.
SetDebugLevel
(
3
);
wrapper
.
Config
();
NetDef
net
=
BuildNetDef
();
wrapper
.
SetupGraph
(
net
);
Allocator
*
cpu_allocator
=
GetDeviceAllocator
(
DeviceType
::
CPU
);
Tensor
input_tensor
(
cpu_allocator
,
DT_UINT8
);
Tensor
output_tensor
(
cpu_allocator
,
DT_UINT8
);
input_tensor
.
Resize
({
1
,
2
,
2
,
128
});
output_tensor
.
Resize
({
1
,
1
,
1
,
128
});
uint8_t
*
input_data
=
input_tensor
.
mutable_data
<
uint8_t
>
();
const
uint8_t
*
output_data
=
output_tensor
.
data
<
uint8_t
>
();
for
(
int
c
=
0
;
c
<
128
;
++
c
)
{
input_data
[
c
]
=
input_data
[
c
+
128
]
=
input_data
[
c
+
256
]
=
input_data
[
c
+
384
]
=
(
uint8_t
)
c
;
}
VLOG
(
0
)
<<
wrapper
.
ExecuteGraph
(
input_tensor
,
&
output_tensor
);
wrapper
.
PrintLog
();
for
(
int
i
=
0
;
i
<
output_tensor
.
size
();
++
i
)
{
std
::
cout
<<
(
int32_t
)
output_data
[
i
]
<<
" "
;
}
std
::
cout
<<
std
::
endl
;
VLOG
(
0
)
<<
wrapper
.
TeardownGraph
();
wrapper
.
Finalize
();
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录