Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
f9077aa4
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看板
提交
f9077aa4
编写于
7月 23, 2020
作者:
J
jiweibo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update for subgraph. test=develop
上级
47ebc8c4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
31 addition
and
25 deletion
+31
-25
lite/api/cxx_api.cc
lite/api/cxx_api.cc
+1
-1
lite/api/cxx_api.h
lite/api/cxx_api.h
+8
-6
lite/api/cxx_api_impl.cc
lite/api/cxx_api_impl.cc
+9
-9
lite/backends/cuda/stream_guard.h
lite/backends/cuda/stream_guard.h
+1
-1
lite/core/program.cc
lite/core/program.cc
+3
-3
lite/core/program.h
lite/core/program.h
+9
-5
未找到文件。
lite/api/cxx_api.cc
浏览文件 @
f9077aa4
...
@@ -357,7 +357,7 @@ void Predictor::GenRuntimeProgram() {
...
@@ -357,7 +357,7 @@ void Predictor::GenRuntimeProgram() {
program_generated_
=
true
;
program_generated_
=
true
;
#ifdef LITE_WITH_CUDA
#ifdef LITE_WITH_CUDA
if
(
!
cuda_use_multi_stream_
)
{
if
(
!
cuda_use_multi_stream_
)
{
program_
->
UpdateCuda
Context
(
cuda_exec_stream_
,
cuda_io_stream_
);
program_
->
UpdateCuda
Stream
(
cuda_exec_stream_
,
cuda_io_stream_
);
}
}
#endif
#endif
}
}
...
...
lite/api/cxx_api.h
浏览文件 @
f9077aa4
...
@@ -158,10 +158,12 @@ class LITE_API Predictor {
...
@@ -158,10 +158,12 @@ class LITE_API Predictor {
cuda_use_multi_stream_
=
multi_stream
;
cuda_use_multi_stream_
=
multi_stream
;
}
}
bool
cuda_use_multi_stream
()
{
return
cuda_use_multi_stream_
;
}
bool
cuda_use_multi_stream
()
{
return
cuda_use_multi_stream_
;
}
void
set_cuda_exec_stream
(
cudaStream_t
stream
)
{
cuda_exec_stream_
=
stream
;
}
void
set_cuda_exec_stream
(
cudaStream_t
*
stream
)
{
void
set_cuda_io_stream
(
cudaStream_t
stream
)
{
cuda_io_stream_
=
stream
;
}
cuda_exec_stream_
=
stream
;
cudaStream_t
cuda_exec_stream
()
{
return
cuda_exec_stream_
;
}
}
cudaStream_t
cuda_io_stream
()
{
return
cuda_io_stream_
;
}
void
set_cuda_io_stream
(
cudaStream_t
*
stream
)
{
cuda_io_stream_
=
stream
;
}
cudaStream_t
*
cuda_exec_stream
()
{
return
cuda_exec_stream_
;
}
cudaStream_t
*
cuda_io_stream
()
{
return
cuda_io_stream_
;
}
#endif
#endif
private:
private:
...
@@ -177,8 +179,8 @@ class LITE_API Predictor {
...
@@ -177,8 +179,8 @@ class LITE_API Predictor {
#ifdef LITE_WITH_CUDA
#ifdef LITE_WITH_CUDA
bool
cuda_use_multi_stream_
{
false
};
bool
cuda_use_multi_stream_
{
false
};
cudaStream_t
cuda_io_stream_
;
cudaStream_t
*
cuda_io_stream_
{
nullptr
}
;
cudaStream_t
cuda_exec_stream_
;
cudaStream_t
*
cuda_exec_stream_
{
nullptr
}
;
#endif
#endif
};
};
...
...
lite/api/cxx_api_impl.cc
浏览文件 @
f9077aa4
...
@@ -135,14 +135,14 @@ void CxxPaddleApiImpl::InitCudaEnv(std::vector<std::string> *passes) {
...
@@ -135,14 +135,14 @@ void CxxPaddleApiImpl::InitCudaEnv(std::vector<std::string> *passes) {
}
}
void
CxxPaddleApiImpl
::
SyncCudaInputs
()
{
void
CxxPaddleApiImpl
::
SyncCudaInputs
()
{
TargetWrapperCuda
::
RecordEvent
(
cuda_input_event_
,
cuda_io_stream_
->
stream
());
TargetWrapperCuda
::
RecordEvent
(
cuda_input_event_
,
*
cuda_io_stream_
->
stream
());
if
(
cuda_use_multi_stream_
)
{
if
(
cuda_use_multi_stream_
)
{
for
(
int
i
=
0
;
i
<
lite
::
kMaxStream
;
++
i
)
{
for
(
int
i
=
0
;
i
<
lite
::
kMaxStream
;
++
i
)
{
TargetWrapperCuda
::
StreamSync
(
cuda_exec_streams_
[
i
].
stream
(),
TargetWrapperCuda
::
StreamSync
(
*
cuda_exec_streams_
[
i
].
stream
(),
cuda_input_event_
);
cuda_input_event_
);
}
}
}
else
{
}
else
{
TargetWrapperCuda
::
StreamSync
(
cuda_exec_stream_
->
stream
(),
TargetWrapperCuda
::
StreamSync
(
*
cuda_exec_stream_
->
stream
(),
cuda_input_event_
);
cuda_input_event_
);
}
}
}
}
...
@@ -151,14 +151,14 @@ void CxxPaddleApiImpl::SyncCudaOutputs() {
...
@@ -151,14 +151,14 @@ void CxxPaddleApiImpl::SyncCudaOutputs() {
if
(
cuda_use_multi_stream_
)
{
if
(
cuda_use_multi_stream_
)
{
for
(
size_t
i
=
0
;
i
<
cuda_output_events_
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
cuda_output_events_
.
size
();
++
i
)
{
TargetWrapperCuda
::
RecordEvent
(
cuda_output_events_
[
i
],
TargetWrapperCuda
::
RecordEvent
(
cuda_output_events_
[
i
],
cuda_exec_streams_
[
i
].
stream
());
*
cuda_exec_streams_
[
i
].
stream
());
TargetWrapperCuda
::
StreamSync
(
cuda_io_stream_
->
stream
(),
TargetWrapperCuda
::
StreamSync
(
*
cuda_io_stream_
->
stream
(),
cuda_output_events_
[
i
]);
cuda_output_events_
[
i
]);
}
}
}
else
{
}
else
{
TargetWrapperCuda
::
RecordEvent
(
cuda_output_events_
[
0
],
TargetWrapperCuda
::
RecordEvent
(
cuda_output_events_
[
0
],
cuda_exec_stream_
->
stream
());
*
cuda_exec_stream_
->
stream
());
TargetWrapperCuda
::
StreamSync
(
cuda_io_stream_
->
stream
(),
TargetWrapperCuda
::
StreamSync
(
*
cuda_io_stream_
->
stream
(),
cuda_output_events_
[
0
]);
cuda_output_events_
[
0
]);
}
}
}
}
...
@@ -168,7 +168,7 @@ std::unique_ptr<lite_api::Tensor> CxxPaddleApiImpl::GetInput(int i) {
...
@@ -168,7 +168,7 @@ std::unique_ptr<lite_api::Tensor> CxxPaddleApiImpl::GetInput(int i) {
auto
*
x
=
raw_predictor_
->
GetInput
(
i
);
auto
*
x
=
raw_predictor_
->
GetInput
(
i
);
#ifdef LITE_WITH_CUDA
#ifdef LITE_WITH_CUDA
return
std
::
unique_ptr
<
lite_api
::
Tensor
>
(
return
std
::
unique_ptr
<
lite_api
::
Tensor
>
(
new
lite_api
::
Tensor
(
x
,
cuda_io_stream_
->
stream
()));
new
lite_api
::
Tensor
(
x
,
*
cuda_io_stream_
->
stream
()));
#else
#else
return
std
::
unique_ptr
<
lite_api
::
Tensor
>
(
new
lite_api
::
Tensor
(
x
));
return
std
::
unique_ptr
<
lite_api
::
Tensor
>
(
new
lite_api
::
Tensor
(
x
));
#endif
#endif
...
@@ -179,7 +179,7 @@ std::unique_ptr<const lite_api::Tensor> CxxPaddleApiImpl::GetOutput(
...
@@ -179,7 +179,7 @@ std::unique_ptr<const lite_api::Tensor> CxxPaddleApiImpl::GetOutput(
const
auto
*
x
=
raw_predictor_
->
GetOutput
(
i
);
const
auto
*
x
=
raw_predictor_
->
GetOutput
(
i
);
#ifdef LITE_WITH_CUDA
#ifdef LITE_WITH_CUDA
return
std
::
unique_ptr
<
lite_api
::
Tensor
>
(
return
std
::
unique_ptr
<
lite_api
::
Tensor
>
(
new
lite_api
::
Tensor
(
x
,
cuda_io_stream_
->
stream
()));
new
lite_api
::
Tensor
(
x
,
*
cuda_io_stream_
->
stream
()));
#else
#else
return
std
::
unique_ptr
<
lite_api
::
Tensor
>
(
new
lite_api
::
Tensor
(
x
));
return
std
::
unique_ptr
<
lite_api
::
Tensor
>
(
new
lite_api
::
Tensor
(
x
));
#endif
#endif
...
...
lite/backends/cuda/stream_guard.h
浏览文件 @
f9077aa4
...
@@ -44,7 +44,7 @@ class CudaStreamGuard {
...
@@ -44,7 +44,7 @@ class CudaStreamGuard {
lite
::
TargetWrapperCuda
::
DestroyStream
(
stream_
);
lite
::
TargetWrapperCuda
::
DestroyStream
(
stream_
);
}
}
}
}
cudaStream_t
stream
()
{
return
stream_
;
}
cudaStream_t
*
stream
()
{
return
&
stream_
;
}
bool
owned
()
{
return
owned_
;
}
bool
owned
()
{
return
owned_
;
}
private:
private:
...
...
lite/core/program.cc
浏览文件 @
f9077aa4
...
@@ -243,9 +243,9 @@ RuntimeProgram::RuntimeProgram(
...
@@ -243,9 +243,9 @@ RuntimeProgram::RuntimeProgram(
}
}
#ifdef LITE_WITH_CUDA
#ifdef LITE_WITH_CUDA
void
RuntimeProgram
::
UpdateCuda
Context
(
cudaStream_t
exec
,
cudaStream_t
io
)
{
void
RuntimeProgram
::
UpdateCuda
Stream
(
cudaStream_t
*
exec
,
cudaStream_t
*
io
)
{
for
(
auto
&
inst
:
instructions_
)
{
for
(
auto
&
inst
:
instructions_
[
kRootBlockIdx
]
)
{
inst
.
UpdateCuda
Context
(
exec
,
io
);
inst
.
UpdateCuda
Stream
(
exec
,
io
);
}
}
}
}
#endif
#endif
...
...
lite/core/program.h
浏览文件 @
f9077aa4
...
@@ -140,10 +140,14 @@ struct Instruction {
...
@@ -140,10 +140,14 @@ struct Instruction {
}
}
}
}
void
Sync
()
const
{
kernel_
->
mutable_context
()
->
As
<
CUDAContext
>
().
Sync
();
}
void
Sync
()
const
{
kernel_
->
mutable_context
()
->
As
<
CUDAContext
>
().
Sync
();
}
void
UpdateCuda
Context
(
cudaStream_t
exec
,
cudaStream_t
io
)
{
void
UpdateCuda
Stream
(
cudaStream_t
*
exec
,
cudaStream_t
*
io
)
{
if
(
kernel_
->
target
()
==
TargetType
::
kCUDA
)
{
if
(
kernel_
->
target
()
==
TargetType
::
kCUDA
)
{
kernel_
->
mutable_context
()
->
As
<
CUDAContext
>
().
SetExecStream
(
exec
);
if
(
exec
)
{
kernel_
->
mutable_context
()
->
As
<
CUDAContext
>
().
SetIoStream
(
io
);
kernel_
->
mutable_context
()
->
As
<
CUDAContext
>
().
SetExecStream
(
*
exec
);
}
if
(
io
)
{
kernel_
->
mutable_context
()
->
As
<
CUDAContext
>
().
SetIoStream
(
*
io
);
}
}
}
}
}
#endif
#endif
...
@@ -245,9 +249,9 @@ class LITE_API RuntimeProgram {
...
@@ -245,9 +249,9 @@ class LITE_API RuntimeProgram {
void
SaveToProgram
(
std
::
shared_ptr
<
cpp
::
ProgramDesc
>
program_desc
);
void
SaveToProgram
(
std
::
shared_ptr
<
cpp
::
ProgramDesc
>
program_desc
);
#ifdef LITE_WITH_CUDA
#ifdef LITE_WITH_CUDA
// UpdateCuda
Context
will update the exec stream and io stream of all kernels
// UpdateCuda
Stream
will update the exec stream and io stream of all kernels
// in the program.
// in the program.
void
UpdateCuda
Context
(
cudaStream_t
exec
,
cudaStream_t
io
);
void
UpdateCuda
Stream
(
cudaStream_t
*
exec
,
cudaStream_t
*
io
);
#endif
#endif
private:
private:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录