Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
1df40eed
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看板
提交
1df40eed
编写于
10月 24, 2018
作者:
E
eclipsess
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add tensor mutable and lod
上级
abc1eaf3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
9 deletion
+18
-9
src/operators/kernel/arm/im2sequence_kernel.cpp
src/operators/kernel/arm/im2sequence_kernel.cpp
+13
-4
test/net/test_eng.cpp
test/net/test_eng.cpp
+5
-5
未找到文件。
src/operators/kernel/arm/im2sequence_kernel.cpp
浏览文件 @
1df40eed
...
@@ -35,7 +35,7 @@ template <>
...
@@ -35,7 +35,7 @@ template <>
void
Im2SequenceKernel
<
CPU
,
float
>::
Compute
(
void
Im2SequenceKernel
<
CPU
,
float
>::
Compute
(
const
Im2SequenceParam
<
CPU
>
&
param
)
const
{
const
Im2SequenceParam
<
CPU
>
&
param
)
const
{
const
Tensor
*
in_x
=
param
.
Input
();
const
Tensor
*
in_x
=
param
.
Input
();
Tensor
*
out
=
param
.
Output
();
framework
::
LoD
Tensor
*
out
=
param
.
Output
();
out
->
mutable_data
<
float
>
();
out
->
mutable_data
<
float
>
();
std
::
vector
<
int
>
kernels
=
param
.
Kernels
();
std
::
vector
<
int
>
kernels
=
param
.
Kernels
();
...
@@ -52,22 +52,31 @@ void Im2SequenceKernel<CPU, float>::Compute(
...
@@ -52,22 +52,31 @@ void Im2SequenceKernel<CPU, float>::Compute(
paddings
[
2
],
strides
[
0
]);
paddings
[
2
],
strides
[
0
]);
int
output_width
=
Im2SeqOutputSize
(
img_width
,
kernels
[
1
],
paddings
[
1
],
int
output_width
=
Im2SeqOutputSize
(
img_width
,
kernels
[
1
],
paddings
[
1
],
paddings
[
3
],
strides
[
1
]);
paddings
[
3
],
strides
[
1
]);
const
std
::
vector
<
int
>
dilations
({
1
,
1
});
out
->
mutable_data
<
float
>
({
batch_size
*
output_height
*
output_width
,
img_channels
*
kernels
[
0
]
*
kernels
[
1
]});
const
std
::
vector
<
int
>
dilations
({
1
,
1
});
// TODO: verify
// TODO: verify
auto
out_dims
=
out
->
dims
();
auto
out_dims
=
out
->
dims
();
out
->
Resize
({
batch_size
,
out
->
numel
()
/
batch_size
});
out
->
Resize
({
batch_size
,
out
->
numel
()
/
batch_size
});
for
(
int
i
=
0
;
i
<
batch_size
;
i
++
)
{
for
(
int
i
=
0
;
i
<
batch_size
;
i
++
)
{
const
Tensor
src
=
const
Tensor
src
=
in_x
->
Slice
(
i
,
i
+
1
).
Resize
({
img_channels
,
img_height
,
img_width
});
in_x
->
Slice
(
i
,
i
+
1
).
Resize
({
img_channels
,
img_height
,
img_width
});
Tensor
dst
=
out
->
Slice
(
i
,
i
+
1
).
Resize
(
Tensor
dst
=
out
->
Slice
(
i
,
i
+
1
).
Resize
(
{
output_height
,
output_width
,
img_channels
,
kernels
[
0
],
kernels
[
1
]});
{
output_height
,
output_width
,
img_channels
,
kernels
[
0
],
kernels
[
1
]});
math
::
Im2ColFunctor
<
math
::
ColFormat
::
kOCF
,
CPU
,
float
>
f
;
math
::
Im2ColFunctor
<
math
::
ColFormat
::
kOCF
,
CPU
,
float
>
f
;
f
(
src
,
dilations
,
strides
,
paddings
,
&
dst
);
f
(
src
,
dilations
,
strides
,
paddings
,
&
dst
);
}
}
out
->
Resize
(
out_dims
);
out
->
Resize
(
out_dims
);
framework
::
LoD
lod
(
1
);
lod
[
0
].
reserve
(
batch_size
+
1
);
int
offset
=
0
;
lod
[
0
].
push_back
(
offset
);
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
{
offset
+=
output_height
*
output_width
;
lod
[
0
].
push_back
(
offset
);
}
out
->
set_lod
(
lod
);
}
}
template
class
Im2SequenceKernel
<
CPU
,
float
>;
template
class
Im2SequenceKernel
<
CPU
,
float
>;
...
...
test/net/test_eng.cpp
浏览文件 @
1df40eed
...
@@ -27,9 +27,9 @@ int main() {
...
@@ -27,9 +27,9 @@ int main() {
true
))
{
true
))
{
auto
time2
=
time
();
auto
time2
=
time
();
std
::
cout
<<
"load cost :"
<<
time_diff
(
time1
,
time1
)
<<
"ms"
<<
std
::
endl
;
std
::
cout
<<
"load cost :"
<<
time_diff
(
time1
,
time1
)
<<
"ms"
<<
std
::
endl
;
std
::
vector
<
int64_t
>
dims
{
1
,
1
,
48
,
48
};
std
::
vector
<
int64_t
>
dims
{
1
,
1
,
48
,
512
};
LoDTensor
input_tensor
;
LoDTensor
input_tensor
;
SetupTensor
<
float
>
(
&
input_tensor
,
{
1
,
1
,
48
,
48
},
static_cast
<
float
>
(
0
),
SetupTensor
<
float
>
(
&
input_tensor
,
{
1
,
1
,
48
,
512
},
static_cast
<
float
>
(
0
),
static_cast
<
float
>
(
1
));
static_cast
<
float
>
(
1
));
std
::
vector
<
float
>
input
(
input_tensor
.
data
<
float
>
(),
std
::
vector
<
float
>
input
(
input_tensor
.
data
<
float
>
(),
...
@@ -39,9 +39,9 @@ int main() {
...
@@ -39,9 +39,9 @@ int main() {
paddle_mobile
.
PredictLod
(
input_tensor
);
paddle_mobile
.
PredictLod
(
input_tensor
);
}
}
auto
time3
=
time
();
auto
time3
=
time
();
// for (int i = 0; i < 10
; ++i) {
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
// paddle_mobile.Predict(input, dims
);
paddle_mobile
.
PredictLod
(
input_tensor
);
//
}
}
auto
time4
=
time
();
auto
time4
=
time
();
std
::
cout
<<
"predict cost :"
<<
time_diff
(
time3
,
time4
)
<<
"ms"
std
::
cout
<<
"predict cost :"
<<
time_diff
(
time3
,
time4
)
<<
"ms"
<<
std
::
endl
;
<<
std
::
endl
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录