Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
as350144
Mace
提交
c213c27f
Mace
项目概览
as350144
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
2
Star
1
Fork
1
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
c213c27f
编写于
12月 01, 2017
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update the logic : output type equals op type.
上级
7f43b237
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
6 addition
and
24 deletion
+6
-24
mace/kernels/opencl/helper.cc
mace/kernels/opencl/helper.cc
+2
-4
mace/ops/conv_2d_test.cc
mace/ops/conv_2d_test.cc
+4
-20
未找到文件。
mace/kernels/opencl/helper.cc
浏览文件 @
c213c27f
...
...
@@ -57,9 +57,8 @@ void CalImage2DShape(const std::vector<index_t> &shape, /* NHWC */
std
::
string
DataTypeToCLType
(
const
DataType
dt
)
{
switch
(
dt
)
{
case
DT_FLOAT
:
return
"float"
;
case
DT_HALF
:
return
"
half
"
;
return
"
float
"
;
case
DT_UINT8
:
return
"uchar"
;
case
DT_INT8
:
...
...
@@ -85,9 +84,8 @@ std::string DataTypeToCLType(const DataType dt) {
std
::
string
DataTypeToOPENCLCMDDataType
(
const
DataType
dt
)
{
switch
(
dt
)
{
case
DT_FLOAT
:
return
"f"
;
case
DT_HALF
:
return
"
h
"
;
return
"
f
"
;
default:
LOG
(
FATAL
)
<<
"Not supported data type for opencl cmd data type"
;
return
""
;
...
...
mace/ops/conv_2d_test.cc
浏览文件 @
c213c27f
...
...
@@ -194,16 +194,12 @@ void TestNHWCSimple3x3SAME() {
TEST_F
(
Conv2dOpTest
,
CPUSimple
)
{
TestNHWCSimple3x3VALID
<
DeviceType
::
CPU
,
float
>
();
TestNHWCSimple3x3VALID
<
DeviceType
::
CPU
,
half
>
();
TestNHWCSimple3x3SAME
<
DeviceType
::
CPU
,
float
>
();
TestNHWCSimple3x3SAME
<
DeviceType
::
CPU
,
half
>
();
}
TEST_F
(
Conv2dOpTest
,
OPENCLSimple
)
{
TestNHWCSimple3x3VALID
<
DeviceType
::
OPENCL
,
float
>
();
TestNHWCSimple3x3VALID
<
DeviceType
::
OPENCL
,
half
>
();
TestNHWCSimple3x3SAME
<
DeviceType
::
OPENCL
,
float
>
();
TestNHWCSimple3x3SAME
<
DeviceType
::
OPENCL
,
half
>
();
}
template
<
DeviceType
D
>
...
...
@@ -294,12 +290,10 @@ void TestNHWCSimple3x3WithoutBias() {
TEST_F
(
Conv2dOpTest
,
CPUWithoutBias
)
{
TestNHWCSimple3x3WithoutBias
<
DeviceType
::
CPU
,
float
>
();
TestNHWCSimple3x3WithoutBias
<
DeviceType
::
CPU
,
half
>
();
}
TEST_F
(
Conv2dOpTest
,
OPENCLWithoutBias
)
{
TestNHWCSimple3x3WithoutBias
<
DeviceType
::
OPENCL
,
float
>
();
TestNHWCSimple3x3WithoutBias
<
DeviceType
::
OPENCL
,
half
>
();
}
template
<
DeviceType
D
>
...
...
@@ -408,12 +402,10 @@ static void TestNHWCCombined3x3() {
TEST_F
(
Conv2dOpTest
,
CPUStride2
)
{
TestNHWCCombined3x3
<
DeviceType
::
CPU
,
float
>
();
TestNHWCCombined3x3
<
DeviceType
::
CPU
,
half
>
();
}
TEST_F
(
Conv2dOpTest
,
OPENCLStride2
)
{
TestNHWCCombined3x3
<
DeviceType
::
OPENCL
,
float
>
();
TestNHWCCombined3x3
<
DeviceType
::
OPENCL
,
half
>
();
}
template
<
DeviceType
D
>
...
...
@@ -608,19 +600,10 @@ static void TestHalfComplexConvNxNS12(const std::vector<index_t> &shape) {
Tensor
expected
;
expected
.
Copy
(
*
net
.
GetOutput
(
"Output"
));
std
::
vector
<
half
>
input_data
(
float_input_data
.
begin
(),
float_input_data
.
end
());
std
::
vector
<
half
>
filter_data
(
float_filter_data
.
begin
(),
float_filter_data
.
end
());
std
::
vector
<
half
>
bias_data
(
float_bias_data
.
begin
(),
float_bias_data
.
end
());
net
.
AddInputFromArray
<
D
,
half
>
(
"InputHalf"
,
{
batch
,
height
,
width
,
input_channels
},
input_data
);
net
.
AddInputFromArray
<
D
,
half
>
(
"FilterHalf"
,
{
kernel_h
,
kernel_w
,
input_channels
,
output_channels
},
filter_data
);
net
.
AddInputFromArray
<
D
,
half
>
(
"BiasHalf"
,
{
output_channels
},
bias_data
);
// run on gpu
BufferToImage
<
D
,
half
>
(
net
,
"Input
Half
"
,
"InputImage"
,
kernels
::
BufferType
::
IN_OUT
);
BufferToImage
<
D
,
half
>
(
net
,
"Filter
Half
"
,
"FilterImage"
,
kernels
::
BufferType
::
FILTER
);
BufferToImage
<
D
,
half
>
(
net
,
"Bias
Half
"
,
"BiasImage"
,
kernels
::
BufferType
::
ARGUMENT
);
BufferToImage
<
D
,
half
>
(
net
,
"Input"
,
"InputImage"
,
kernels
::
BufferType
::
IN_OUT
);
BufferToImage
<
D
,
half
>
(
net
,
"Filter"
,
"FilterImage"
,
kernels
::
BufferType
::
FILTER
);
BufferToImage
<
D
,
half
>
(
net
,
"Bias"
,
"BiasImage"
,
kernels
::
BufferType
::
ARGUMENT
);
OpDefBuilder
(
"Conv2D"
,
"Conv2dTest"
)
.
Input
(
"InputImage"
)
...
...
@@ -630,6 +613,7 @@ static void TestHalfComplexConvNxNS12(const std::vector<index_t> &shape) {
.
AddIntsArg
(
"strides"
,
{
stride_h
,
stride_w
})
.
AddIntArg
(
"padding"
,
type
)
.
AddIntsArg
(
"dilations"
,
{
1
,
1
})
.
AddIntArg
(
"T"
,
static_cast
<
int
>
(
DataType
::
DT_HALF
))
.
Finalize
(
net
.
NewOperatorDef
());
// Run on device
net
.
RunOp
(
D
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录