Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
ca424e73
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
ca424e73
编写于
9月 12, 2019
作者:
Z
zhupengyang
提交者:
GitHub
9月 12, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bilinear-interp arm compute (#2029)
fix bilinear-interp unit test for more cases test=develop
上级
b6379fed
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
64 addition
and
30 deletion
+64
-30
lite/backends/arm/math/interpolate.cc
lite/backends/arm/math/interpolate.cc
+2
-2
lite/tests/kernels/bilinear_interp_compute_test.cc
lite/tests/kernels/bilinear_interp_compute_test.cc
+62
-28
未找到文件。
lite/backends/arm/math/interpolate.cc
浏览文件 @
ca424e73
...
@@ -83,8 +83,8 @@ void bilinear_interp(const float* src,
...
@@ -83,8 +83,8 @@ void bilinear_interp(const float* src,
beta
[
dy
*
2
+
1
]
=
fy
;
beta
[
dy
*
2
+
1
]
=
fy
;
}
}
}
else
{
}
else
{
scale_x
=
static_cast
<
float
>
(
w_in
/
w_out
)
;
scale_x
=
static_cast
<
float
>
(
w_in
)
/
w_out
;
scale_y
=
static_cast
<
float
>
(
h_in
/
h_out
)
;
scale_y
=
static_cast
<
float
>
(
h_in
)
/
h_out
;
// calculate x axis coordinate
// calculate x axis coordinate
for
(
int
dx
=
0
;
dx
<
w_out
;
dx
++
)
{
for
(
int
dx
=
0
;
dx
<
w_out
;
dx
++
)
{
fx
=
scale_x
*
(
dx
+
0.5
f
)
-
0.5
f
;
fx
=
scale_x
*
(
dx
+
0.5
f
)
-
0.5
f
;
...
...
lite/tests/kernels/bilinear_interp_compute_test.cc
浏览文件 @
ca424e73
...
@@ -156,26 +156,30 @@ class BilinearInterpComputeTester : public arena::TestCase {
...
@@ -156,26 +156,30 @@ class BilinearInterpComputeTester : public arena::TestCase {
float
width_scale_
=
0.
f
;
float
width_scale_
=
0.
f
;
int
out_height_
=
-
1
;
int
out_height_
=
-
1
;
int
out_width_
=
-
1
;
int
out_width_
=
-
1
;
int
outsize_height_
=
-
1
;
int
outsize_width_
=
-
1
;
bool
align_corners_
=
true
;
bool
align_corners_
=
true
;
std
::
string
interp_method_
=
"Bilinear"
;
std
::
string
interp_method_
=
"Bilinear"
;
DDim
dims_
{{
1
,
1
}};
DDim
_dims0_
{{
1
,
1
,
16
,
16
}};
DDim
_dims0_
{{
1
,
1
,
16
,
16
}};
DDim
_dims1_
{{
2
}};
DDim
_dims1_
{{
2
}};
public:
public:
BilinearInterpComputeTester
(
const
Place
&
place
,
BilinearInterpComputeTester
(
const
Place
&
place
,
const
std
::
string
&
alias
,
const
std
::
string
&
alias
,
float
height_scale
,
float
scale
,
float
width_scale
,
int
out_height
,
int
out_height
,
int
out_width
,
int
out_width
,
int
outsize_height
,
int
outsize_width
,
bool
align_corners
,
bool
align_corners
,
std
::
string
interp_method
)
std
::
string
interp_method
)
:
TestCase
(
place
,
alias
),
:
TestCase
(
place
,
alias
),
height_scale_
(
height_
scale
),
height_scale_
(
scale
),
width_scale_
(
width_
scale
),
width_scale_
(
scale
),
out_height_
(
out_height
),
out_height_
(
out_height
),
out_width_
(
out_width
),
out_width_
(
out_width
),
outsize_height_
(
outsize_height
),
outsize_width_
(
outsize_width
),
align_corners_
(
align_corners
),
align_corners_
(
align_corners
),
interp_method_
(
interp_method
)
{}
interp_method_
(
interp_method
)
{}
...
@@ -183,8 +187,9 @@ class BilinearInterpComputeTester : public arena::TestCase {
...
@@ -183,8 +187,9 @@ class BilinearInterpComputeTester : public arena::TestCase {
width_scale_
=
height_scale_
;
width_scale_
=
height_scale_
;
std
::
vector
<
const
lite
::
Tensor
*>
inputs
;
std
::
vector
<
const
lite
::
Tensor
*>
inputs
;
inputs
.
emplace_back
(
scope
->
FindTensor
(
input0_
));
inputs
.
emplace_back
(
scope
->
FindTensor
(
input0_
));
if
(
outsize_height_
>
0
&&
outsize_width_
>
0
)
{
inputs
.
emplace_back
(
scope
->
FindTensor
(
input1_
));
inputs
.
emplace_back
(
scope
->
FindTensor
(
input1_
));
auto
outsize_data
=
inputs
[
1
]
->
data
<
int
>
();
}
if
(
out_width_
!=
-
1
&&
out_height_
!=
-
1
)
{
if
(
out_width_
!=
-
1
&&
out_height_
!=
-
1
)
{
height_scale_
=
static_cast
<
float
>
(
out_height_
/
inputs
[
0
]
->
dims
()[
2
]);
height_scale_
=
static_cast
<
float
>
(
out_height_
/
inputs
[
0
]
->
dims
()[
2
]);
width_scale_
=
static_cast
<
float
>
(
out_width_
/
inputs
[
0
]
->
dims
()[
3
]);
width_scale_
=
static_cast
<
float
>
(
out_width_
/
inputs
[
0
]
->
dims
()[
3
]);
...
@@ -192,6 +197,7 @@ class BilinearInterpComputeTester : public arena::TestCase {
...
@@ -192,6 +197,7 @@ class BilinearInterpComputeTester : public arena::TestCase {
auto
*
outputs
=
scope
->
NewTensor
(
output_
);
auto
*
outputs
=
scope
->
NewTensor
(
output_
);
CHECK
(
outputs
);
CHECK
(
outputs
);
if
(
inputs
.
size
()
>
1
)
{
if
(
inputs
.
size
()
>
1
)
{
auto
outsize_data
=
inputs
[
1
]
->
data
<
int
>
();
int
h_out
=
outsize_data
[
0
];
// HW
int
h_out
=
outsize_data
[
0
];
// HW
int
w_out
=
outsize_data
[
1
];
// HW
int
w_out
=
outsize_data
[
1
];
// HW
int
num_cout
=
inputs
[
0
]
->
dims
()[
0
];
int
num_cout
=
inputs
[
0
]
->
dims
()[
0
];
...
@@ -221,7 +227,9 @@ class BilinearInterpComputeTester : public arena::TestCase {
...
@@ -221,7 +227,9 @@ class BilinearInterpComputeTester : public arena::TestCase {
void
PrepareOpDesc
(
cpp
::
OpDesc
*
op_desc
)
{
void
PrepareOpDesc
(
cpp
::
OpDesc
*
op_desc
)
{
op_desc
->
SetType
(
"bilinear_interp"
);
op_desc
->
SetType
(
"bilinear_interp"
);
op_desc
->
SetInput
(
"X"
,
{
input0_
});
op_desc
->
SetInput
(
"X"
,
{
input0_
});
if
(
outsize_height_
>
0
&&
outsize_width_
>
0
)
{
op_desc
->
SetInput
(
"OutSize"
,
{
input1_
});
op_desc
->
SetInput
(
"OutSize"
,
{
input1_
});
}
op_desc
->
SetOutput
(
"Out"
,
{
output_
});
op_desc
->
SetOutput
(
"Out"
,
{
output_
});
op_desc
->
SetAttr
(
"scale"
,
height_scale_
);
op_desc
->
SetAttr
(
"scale"
,
height_scale_
);
op_desc
->
SetAttr
(
"out_h"
,
out_height_
);
op_desc
->
SetAttr
(
"out_h"
,
out_height_
);
...
@@ -237,34 +245,60 @@ class BilinearInterpComputeTester : public arena::TestCase {
...
@@ -237,34 +245,60 @@ class BilinearInterpComputeTester : public arena::TestCase {
}
}
SetCommonTensor
(
input0_
,
_dims0_
,
data0
.
data
());
SetCommonTensor
(
input0_
,
_dims0_
,
data0
.
data
());
std
::
vector
<
int
>
data1
(
_dims1_
.
production
());
if
(
outsize_height_
>
0
&&
outsize_width_
>
0
)
{
for
(
int
i
=
0
;
i
<
_dims1_
.
production
();
i
++
)
{
std
::
vector
<
int
>
data1
(
2
);
data1
[
i
]
=
16
;
data1
[
0
]
=
outsize_height_
;
}
data1
[
1
]
=
outsize_width_
;
SetCommonTensor
(
input1_
,
_dims1_
,
data1
.
data
());
SetCommonTensor
(
input1_
,
_dims1_
,
data1
.
data
());
}
}
}
};
};
void
test_bilinear_interp
(
Place
place
)
{
void
test_bilinear_interp
(
Place
place
)
{
std
::
string
interp_method
=
"Bilinear"
;
std
::
string
interp_method
=
"Bilinear"
;
for
(
float
scale
:
{
1.
,
0.5
,
0.3
})
{
for
(
float
scale
:
{
2.
,
1.
,
0.3
})
{
for
(
int
out_height
:
{
8
,
16
})
{
for
(
bool
align_corners
:
{
true
,
false
})
{
for
(
int
out_width
:
{
8
,
16
})
{
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
new
BilinearInterpComputeTester
(
place
,
"def"
,
scale
,
-
1
,
-
1
,
-
1
,
-
1
,
align_corners
,
interp_method
));
arena
::
Arena
arena
(
std
::
move
(
tester
),
place
,
5e-5
);
arena
.
TestPrecision
();
}
}
for
(
int
out_height
:
{
8
,
16
,
24
})
{
for
(
int
out_width
:
{
8
,
16
,
24
})
{
for
(
bool
align_corners
:
{
true
,
false
})
{
for
(
bool
align_corners
:
{
true
,
false
})
{
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
new
BilinearInterpComputeTester
(
place
,
new
BilinearInterpComputeTester
(
place
,
"def"
,
"def"
,
scale
,
0
,
scale
,
out_height
,
out_height
,
out_width
,
out_width
,
-
1
,
-
1
,
align_corners
,
align_corners
,
interp_method
));
interp_method
));
arena
::
Arena
arena
(
std
::
move
(
tester
),
place
,
2
e-5
);
arena
::
Arena
arena
(
std
::
move
(
tester
),
place
,
5
e-5
);
arena
.
TestPrecision
();
arena
.
TestPrecision
();
}
}
}
}
}
}
for
(
int
outsize_height
:
{
8
,
16
,
24
})
{
for
(
int
outsize_width
:
{
8
,
16
,
24
})
{
for
(
bool
align_corners
:
{
true
,
false
})
{
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
new
BilinearInterpComputeTester
(
place
,
"def"
,
0
,
-
1
,
-
1
,
outsize_height
,
outsize_width
,
align_corners
,
interp_method
));
arena
::
Arena
arena
(
std
::
move
(
tester
),
place
,
5e-5
);
arena
.
TestPrecision
();
}
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录