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,
beta
[
dy
*
2
+
1
]
=
fy
;
}
}
else
{
scale_x
=
static_cast
<
float
>
(
w_in
/
w_out
)
;
scale_y
=
static_cast
<
float
>
(
h_in
/
h_out
)
;
scale_x
=
static_cast
<
float
>
(
w_in
)
/
w_out
;
scale_y
=
static_cast
<
float
>
(
h_in
)
/
h_out
;
// calculate x axis coordinate
for
(
int
dx
=
0
;
dx
<
w_out
;
dx
++
)
{
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 {
float
width_scale_
=
0.
f
;
int
out_height_
=
-
1
;
int
out_width_
=
-
1
;
int
outsize_height_
=
-
1
;
int
outsize_width_
=
-
1
;
bool
align_corners_
=
true
;
std
::
string
interp_method_
=
"Bilinear"
;
DDim
dims_
{{
1
,
1
}};
DDim
_dims0_
{{
1
,
1
,
16
,
16
}};
DDim
_dims1_
{{
2
}};
public:
BilinearInterpComputeTester
(
const
Place
&
place
,
const
std
::
string
&
alias
,
float
height_scale
,
float
width_scale
,
float
scale
,
int
out_height
,
int
out_width
,
int
outsize_height
,
int
outsize_width
,
bool
align_corners
,
std
::
string
interp_method
)
:
TestCase
(
place
,
alias
),
height_scale_
(
height_
scale
),
width_scale_
(
width_
scale
),
height_scale_
(
scale
),
width_scale_
(
scale
),
out_height_
(
out_height
),
out_width_
(
out_width
),
outsize_height_
(
outsize_height
),
outsize_width_
(
outsize_width
),
align_corners_
(
align_corners
),
interp_method_
(
interp_method
)
{}
...
...
@@ -183,8 +187,9 @@ class BilinearInterpComputeTester : public arena::TestCase {
width_scale_
=
height_scale_
;
std
::
vector
<
const
lite
::
Tensor
*>
inputs
;
inputs
.
emplace_back
(
scope
->
FindTensor
(
input0_
));
inputs
.
emplace_back
(
scope
->
FindTensor
(
input1_
));
auto
outsize_data
=
inputs
[
1
]
->
data
<
int
>
();
if
(
outsize_height_
>
0
&&
outsize_width_
>
0
)
{
inputs
.
emplace_back
(
scope
->
FindTensor
(
input1_
));
}
if
(
out_width_
!=
-
1
&&
out_height_
!=
-
1
)
{
height_scale_
=
static_cast
<
float
>
(
out_height_
/
inputs
[
0
]
->
dims
()[
2
]);
width_scale_
=
static_cast
<
float
>
(
out_width_
/
inputs
[
0
]
->
dims
()[
3
]);
...
...
@@ -192,6 +197,7 @@ class BilinearInterpComputeTester : public arena::TestCase {
auto
*
outputs
=
scope
->
NewTensor
(
output_
);
CHECK
(
outputs
);
if
(
inputs
.
size
()
>
1
)
{
auto
outsize_data
=
inputs
[
1
]
->
data
<
int
>
();
int
h_out
=
outsize_data
[
0
];
// HW
int
w_out
=
outsize_data
[
1
];
// HW
int
num_cout
=
inputs
[
0
]
->
dims
()[
0
];
...
...
@@ -221,7 +227,9 @@ class BilinearInterpComputeTester : public arena::TestCase {
void
PrepareOpDesc
(
cpp
::
OpDesc
*
op_desc
)
{
op_desc
->
SetType
(
"bilinear_interp"
);
op_desc
->
SetInput
(
"X"
,
{
input0_
});
op_desc
->
SetInput
(
"OutSize"
,
{
input1_
});
if
(
outsize_height_
>
0
&&
outsize_width_
>
0
)
{
op_desc
->
SetInput
(
"OutSize"
,
{
input1_
});
}
op_desc
->
SetOutput
(
"Out"
,
{
output_
});
op_desc
->
SetAttr
(
"scale"
,
height_scale_
);
op_desc
->
SetAttr
(
"out_h"
,
out_height_
);
...
...
@@ -237,32 +245,58 @@ class BilinearInterpComputeTester : public arena::TestCase {
}
SetCommonTensor
(
input0_
,
_dims0_
,
data0
.
data
());
std
::
vector
<
int
>
data1
(
_dims1_
.
production
());
for
(
int
i
=
0
;
i
<
_dims1_
.
production
();
i
++
)
{
data1
[
i
]
=
16
;
if
(
outsize_height_
>
0
&&
outsize_width_
>
0
)
{
std
::
vector
<
int
>
data1
(
2
);
data1
[
0
]
=
outsize_height_
;
data1
[
1
]
=
outsize_width_
;
SetCommonTensor
(
input1_
,
_dims1_
,
data1
.
data
());
}
SetCommonTensor
(
input1_
,
_dims1_
,
data1
.
data
());
}
};
void
test_bilinear_interp
(
Place
place
)
{
std
::
string
interp_method
=
"Bilinear"
;
for
(
float
scale
:
{
1.
,
0.5
,
0.3
})
{
for
(
int
out_height
:
{
8
,
16
})
{
for
(
int
out_width
:
{
8
,
16
})
{
for
(
bool
align_corners
:
{
true
,
false
})
{
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
new
BilinearInterpComputeTester
(
place
,
"def"
,
scale
,
scale
,
out_height
,
out_width
,
align_corners
,
interp_method
));
arena
::
Arena
arena
(
std
::
move
(
tester
),
place
,
2e-5
);
arena
.
TestPrecision
();
}
for
(
float
scale
:
{
2.
,
1.
,
0.3
})
{
for
(
bool
align_corners
:
{
true
,
false
})
{
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
})
{
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
new
BilinearInterpComputeTester
(
place
,
"def"
,
0
,
out_height
,
out_width
,
-
1
,
-
1
,
align_corners
,
interp_method
));
arena
::
Arena
arena
(
std
::
move
(
tester
),
place
,
5e-5
);
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录