Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
32a8623d
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
332
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看板
提交
32a8623d
编写于
6月 25, 2018
作者:
L
liuruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix loop predict bus error
上级
ccc6945f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
22 deletion
+17
-22
src/framework/tensor.h
src/framework/tensor.h
+11
-19
src/framework/tensor_util.cpp
src/framework/tensor_util.cpp
+0
-1
src/io/io.cpp
src/io/io.cpp
+1
-1
test/net/test_googlenet.cpp
test/net/test_googlenet.cpp
+5
-1
未找到文件。
src/framework/tensor.h
浏览文件 @
32a8623d
...
...
@@ -85,6 +85,12 @@ class Tensor {
}
}
Tensor
(
const
Tensor
&
inTensor
)
{
this
->
dims_
=
inTensor
.
dims_
;
this
->
holder_
=
inTensor
.
holder_
;
this
->
offset_
=
inTensor
.
offset_
;
}
/*! Return a pointer to mutable memory block. */
template
<
typename
T
>
inline
T
*
data
()
{
...
...
@@ -169,7 +175,9 @@ class Tensor {
/*! The internal of two tensors share the same memory block. */
inline
Tensor
&
ShareDataWith
(
const
Tensor
&
src
)
{
src
.
check_memory_size
();
*
this
=
src
;
if
(
holder_
.
get
()
!=
src
.
holder_
.
get
())
{
*
this
=
src
;
}
return
*
this
;
}
...
...
@@ -198,7 +206,6 @@ class Tensor {
size_t
base
=
numel
()
/
dims_
[
0
];
Tensor
dst
;
dst
.
holder_
=
holder_
;
dst
.
set_layout
(
layout_
);
DDim
dst_dims
=
dims_
;
dst_dims
[
0
]
=
end_idx
-
begin_idx
;
dst
.
Resize
(
dst_dims
);
...
...
@@ -227,9 +234,9 @@ class Tensor {
"Tensor's dims_ is out of bound. "
);
}
inline
DataLayout
layout
()
const
{
return
layout_
;
}
inline
void
set_layout
(
const
DataLayout
layout
)
{
layout_
=
layout
;
}
private:
/**
...
...
@@ -288,21 +295,6 @@ class Tensor {
DDim
dims_
;
/**
* @brief the layout of memory block, default is NHWC.
*
* @note the memory allocation order, describe how weight/data is
* stored
* For example, in 4-D Tensor(rank=4), there are three
* commonly
* used layout. They are
* NCHW, NHWC, CHWN.
* N,C,H,W for respectively the batch size, the number of
* feature maps, the height, the width.
*/
DataLayout
layout_
=
DataLayout
::
kNHWC
;
/**
* @brief A PlaceHolder may be shared by more than one tensor.
*
...
...
src/framework/tensor_util.cpp
浏览文件 @
32a8623d
...
...
@@ -20,7 +20,6 @@ namespace framework {
void
TensorCopy
(
const
Tensor
&
src
,
Tensor
*
dst
)
{
src
.
check_memory_size
();
dst
->
Resize
(
src
.
dims
());
dst
->
set_layout
(
src
.
layout
());
auto
src_ptr
=
src
.
data
<
void
>
();
auto
dst_ptr
=
dst
->
mutable_data
(
src
.
type
());
auto
size
=
src
.
numel
()
*
SizeOfType
(
src
.
type
());
...
...
src/io/io.cpp
浏览文件 @
32a8623d
...
...
@@ -477,7 +477,7 @@ std::shared_ptr<framework::Tensor> Executor<Dtype, P>::Predict(
printf
(
"====================[---------]======================
\n
"
);
#endif
return
std
::
shared_ptr
<
framework
::
Tensor
>
(
output_tensor
);
return
std
::
make_shared
<
framework
::
Tensor
>
(
framework
::
Tensor
(
*
output_tensor
)
);
}
template
<
typename
Dtype
,
Precision
P
>
std
::
shared_ptr
<
framework
::
Tensor
>
Executor
<
Dtype
,
P
>::
Predict
(
...
...
test/net/test_googlenet.cpp
浏览文件 @
32a8623d
...
...
@@ -30,7 +30,11 @@ int main() {
std
::
vector
<
int64_t
>
dims
{
1
,
3
,
224
,
224
};
GetInput
<
float
>
(
g_test_image_1x3x224x224
,
&
input
,
dims
);
auto
time3
=
time
();
executor
.
Predict
(
input
,
dims
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
executor
.
Predict
(
input
,
dims
);
}
auto
time4
=
time
();
DLOG
<<
"predict cost :"
<<
time_diff
(
time3
,
time4
)
<<
"ms
\n
"
;
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录