Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
7deff6de
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看板
提交
7deff6de
编写于
5月 16, 2019
作者:
X
xiebaiyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix crash when close optimise in gpu test close
#1626
上级
43e040dc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
71 addition
and
29 deletion
+71
-29
src/framework/executor.cpp
src/framework/executor.cpp
+20
-10
src/framework/executor.h
src/framework/executor.h
+5
-0
src/framework/type_trait.h
src/framework/type_trait.h
+44
-0
src/operators/op_param.h
src/operators/op_param.h
+2
-19
未找到文件。
src/framework/executor.cpp
浏览文件 @
7deff6de
...
...
@@ -467,21 +467,32 @@ PMStatus Executor<Device, T>::Predict() {
++
op_index
;
#endif
}
#ifdef PADDLE_MOBILE_PROFILE
PrintProfile
(
profile
);
#endif
return
PMSuccess
;
}
#ifdef PADDLE_MOBILE_PROFILE
template
<
typename
Device
,
typename
T
>
void
Executor
<
Device
,
T
>::
PrintProfile
(
const
vector
<
Executor
<
Device
,
T
>::
ProfInfo
>
&
profile
)
const
{
std
::
unordered_map
<
std
::
string
,
uint64_t
>
_tp
;
for
(
int
i
=
0
;
i
<
profile
.
size
();
i
++
)
{
const
auto
&
pInfo
=
profile
[
i
];
uint64_t
timeCost
=
pInfo
.
runEnd
-
pInfo
.
runBegin
;
if
(
ops_of_block0_
[
i
]
->
Type
()
==
"conv2d"
||
ops_of_block0_
[
i
]
->
Type
()
==
"depthwise_conv2d"
)
{
auto
inputs
=
ops_of_block0_
[
i
]
->
Inputs
();
auto
*
filter
=
GetVarValue
<
LoDTensor
>
(
"Filter"
,
inputs
,
*
(
program_
.
scope
));
if
(
this
->
ops_of_block0_
[
i
]
->
Type
()
==
"conv2d"
||
this
->
ops_of_block0_
[
i
]
->
Type
()
==
"depthwise_conv2d"
)
{
auto
inputs
=
this
->
ops_of_block0_
[
i
]
->
Inputs
();
auto
*
filter
=
GetVarValue
<
ProfileTensorType
>
(
"Filter"
,
inputs
,
*
(
this
->
program_
.
scope
));
int
kernel_size
=
filter
->
dims
()[
2
];
_tp
[
ops_of_block0_
[
i
]
->
Type
()
+
"_"
+
std
::
to_string
(
kernel_size
)]
+=
timeCost
;
_tp
[
this
->
ops_of_block0_
[
i
]
->
Type
()
+
"_"
+
std
::
to_string
(
kernel_size
)]
+=
timeCost
;
}
else
{
_tp
[
ops_of_block0_
[
i
]
->
Type
()]
+=
timeCost
;
_tp
[
this
->
ops_of_block0_
[
i
]
->
Type
()]
+=
timeCost
;
}
}
printf
(
"====================[ profile ]======================
\n
"
);
...
...
@@ -502,9 +513,8 @@ PMStatus Executor<Device, T>::Predict() {
static_cast
<
float
>
(
p
.
second
)
/
_ptotal
*
100.0
);
}
printf
(
"====================[---------]======================
\n
"
);
#endif
return
PMSuccess
;
}
#endif
template
<
typename
Device
,
typename
T
>
void
Executor
<
Device
,
T
>::
FeedTensorData
(
const
vector
<
framework
::
Tensor
>
&
v
)
{
...
...
src/framework/executor.h
浏览文件 @
7deff6de
...
...
@@ -25,6 +25,7 @@ limitations under the License. */
#include "framework/operator.h"
#include "framework/program/program.h"
#include "framework/tensor.h"
#include "framework/type_trait.h"
namespace
paddle_mobile
{
namespace
framework
{
...
...
@@ -98,11 +99,15 @@ class Executor {
DDim
input_dim_last_
;
#ifdef PADDLE_MOBILE_PROFILE
typedef
typename
DtypeTensorTrait
<
Device
>::
gtype
ProfileTensorType
;
struct
ProfInfo
{
int
tid
=
0
;
uint64_t
runBegin
=
0UL
;
uint64_t
runEnd
=
0UL
;
};
void
PrintProfile
(
const
vector
<
Executor
<
Device
,
T
>::
ProfInfo
>
&
profile
)
const
;
#endif
};
...
...
src/framework/type_trait.h
0 → 100644
浏览文件 @
7deff6de
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <common/types.h>
#include <string>
namespace
paddle_mobile
{
namespace
framework
{
template
<
typename
Dtype
>
struct
DtypeTensorTrait
{
// This is the type we obtained in variable.
typedef
framework
::
LoDTensor
gtype
;
// This type will be the parent class type
// or the same type.
typedef
framework
::
Tensor
rtype
;
};
#ifdef PADDLE_MOBILE_CL
template
<
>
struct
DtypeTensorTrait
<
GPU_CL
>
{
// This is the type we obtained in variable.
typedef
framework
::
CLImage
gtype
;
// This type will be the parent class type
// or the same type.
typedef
framework
::
CLImage
rtype
;
};
#endif
}
// namespace framework
}
// namespace paddle_mobile
src/operators/op_param.h
浏览文件 @
7deff6de
...
...
@@ -23,6 +23,7 @@ limitations under the License. */
#include "framework/lod_tensor.h"
#include "framework/scope.h"
#include "framework/tensor.h"
#include "framework/type_trait.h"
#include "framework/variable.h"
#ifdef PADDLE_MOBILE_FPGA_V1
...
...
@@ -53,25 +54,7 @@ using framework::Variable;
using
std
::
string
;
using
std
::
vector
;
template
<
typename
Dtype
>
struct
DtypeTensorTrait
{
// This is the type we obtained in variable.
typedef
framework
::
LoDTensor
gtype
;
// This type will be the parent class type
// or the same type.
typedef
framework
::
Tensor
rtype
;
};
#ifdef PADDLE_MOBILE_CL
template
<
>
struct
DtypeTensorTrait
<
GPU_CL
>
{
// This is the type we obtained in variable.
typedef
framework
::
CLImage
gtype
;
// This type will be the parent class type
// or the same type.
typedef
framework
::
CLImage
rtype
;
};
#endif
using
framework
::
DtypeTensorTrait
;
class
OpParam
{
public:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录