Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
308110ac
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
308110ac
编写于
6月 18, 2020
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add gpu code
上级
54166c03
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
62 addition
and
3 deletion
+62
-3
paddle_inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
...inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
+0
-2
paddle_inference/inferencer-fluid-gpu/include/fluid_gpu_engine.h
...inference/inferencer-fluid-gpu/include/fluid_gpu_engine.h
+56
-1
paddle_inference/inferencer-fluid-gpu/src/fluid_gpu_engine.cpp
...e_inference/inferencer-fluid-gpu/src/fluid_gpu_engine.cpp
+6
-0
未找到文件。
paddle_inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
浏览文件 @
308110ac
...
@@ -531,7 +531,6 @@ class FluidCpuAnalysisDirWithSigmoidCore : public FluidCpuWithSigmoidCore {
...
@@ -531,7 +531,6 @@ class FluidCpuAnalysisDirWithSigmoidCore : public FluidCpuWithSigmoidCore {
return
0
;
return
0
;
}
}
};
};
#if 1
class
FluidCpuAnalysisEncryptCore
:
public
FluidFamilyCore
{
class
FluidCpuAnalysisEncryptCore
:
public
FluidFamilyCore
{
public:
public:
void
ReadBinaryFile
(
const
std
::
string
&
filename
,
std
::
string
*
contents
)
{
void
ReadBinaryFile
(
const
std
::
string
&
filename
,
std
::
string
*
contents
)
{
...
@@ -586,7 +585,6 @@ class FluidCpuAnalysisEncryptCore : public FluidFamilyCore {
...
@@ -586,7 +585,6 @@ class FluidCpuAnalysisEncryptCore : public FluidFamilyCore {
return
0
;
return
0
;
}
}
};
};
#endif
}
// namespace fluid_cpu
}
// namespace fluid_cpu
}
// namespace paddle_serving
}
// namespace paddle_serving
}
// namespace baidu
}
// namespace baidu
paddle_inference/inferencer-fluid-gpu/include/fluid_gpu_engine.h
浏览文件 @
308110ac
...
@@ -21,11 +21,12 @@
...
@@ -21,11 +21,12 @@
#include <string>
#include <string>
#include <utility>
#include <utility>
#include <vector>
#include <vector>
#include "cipher.h" // NOLINT
#include "cipher_utils.h" //NOLINT
#include "core/configure/include/configure_parser.h"
#include "core/configure/include/configure_parser.h"
#include "core/configure/inferencer_configure.pb.h"
#include "core/configure/inferencer_configure.pb.h"
#include "core/predictor/framework/infer.h"
#include "core/predictor/framework/infer.h"
#include "paddle_inference_api.h" // NOLINT
#include "paddle_inference_api.h" // NOLINT
DECLARE_int32
(
gpuid
);
DECLARE_int32
(
gpuid
);
namespace
baidu
{
namespace
baidu
{
...
@@ -535,6 +536,60 @@ class FluidGpuAnalysisDirWithSigmoidCore : public FluidGpuWithSigmoidCore {
...
@@ -535,6 +536,60 @@ class FluidGpuAnalysisDirWithSigmoidCore : public FluidGpuWithSigmoidCore {
}
}
};
};
class
FluidGpuAnalysisEncryptCore
:
public
FluidFamilyCore
{
public:
void
ReadBinaryFile
(
const
std
::
string
&
filename
,
std
::
string
*
contents
)
{
std
::
ifstream
fin
(
filename
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
fin
.
seekg
(
0
,
std
::
ios
::
end
);
contents
->
clear
();
contents
->
resize
(
fin
.
tellg
());
fin
.
seekg
(
0
,
std
::
ios
::
beg
);
fin
.
read
(
&
(
contents
->
at
(
0
)),
contents
->
size
());
fin
.
close
();
}
int
create
(
const
predictor
::
InferEngineCreationParams
&
params
)
{
std
::
string
data_path
=
params
.
get_path
();
if
(
access
(
data_path
.
c_str
(),
F_OK
)
==
-
1
)
{
LOG
(
ERROR
)
<<
"create paddle predictor failed, path note exits: "
<<
data_path
;
return
-
1
;
}
std
::
string
model_buffer
,
params_buffer
,
key_buffer
;
ReadBinaryFile
(
data_path
+
"encry_model"
,
&
model_buffer
);
ReadBinaryFile
(
data_path
+
"encry_params"
,
&
params_buffer
);
ReadBinaryFile
(
data_path
+
"key"
,
&
key_buffer
);
VLOG
(
2
)
<<
"prepare for encryption model"
;
auto
cipher
=
paddle
::
framework
::
CipherFactory
::
CreateCipher
(
""
);
std
::
string
real_model_buffer
=
cipher
->
Decrypt
(
model_buffer
,
key_buffer
);
std
::
string
real_params_buffer
=
cipher
->
Decrypt
(
params_buffer
,
key_buffer
);
paddle
::
AnalysisConfig
analysis_config
;
analysis_config
.
SetModelBuffer
(
&
real_model_buffer
[
0
],
real_model_buffer
.
size
(),
&
real_params_buffer
[
0
],
real_params_buffer
.
size
());
analysis_config
.
EnableUseGpu
(
100
,
FLAGS_gpuid
);
analysis_config
.
SetCpuMathLibraryNumThreads
(
1
);
if
(
params
.
enable_memory_optimization
())
{
analysis_config
.
EnableMemoryOptim
();
}
analysis_config
.
SwitchSpecifyInputNames
(
true
);
AutoLock
lock
(
GlobalPaddleCreateMutex
::
instance
());
VLOG
(
2
)
<<
"decrypt model file sucess"
;
_core
=
paddle
::
CreatePaddlePredictor
<
paddle
::
AnalysisConfig
>
(
analysis_config
);
if
(
NULL
==
_core
.
get
())
{
LOG
(
ERROR
)
<<
"create paddle predictor failed, path: "
<<
data_path
;
return
-
1
;
}
VLOG
(
2
)
<<
"create paddle predictor sucess, path: "
<<
data_path
;
return
0
;
}
};
}
// namespace fluid_gpu
}
// namespace fluid_gpu
}
// namespace paddle_serving
}
// namespace paddle_serving
}
// namespace baidu
}
// namespace baidu
paddle_inference/inferencer-fluid-gpu/src/fluid_gpu_engine.cpp
浏览文件 @
308110ac
...
@@ -54,6 +54,12 @@ REGIST_FACTORY_OBJECT_IMPL_WITH_NAME(
...
@@ -54,6 +54,12 @@ REGIST_FACTORY_OBJECT_IMPL_WITH_NAME(
::
baidu
::
paddle_serving
::
predictor
::
InferEngine
,
::
baidu
::
paddle_serving
::
predictor
::
InferEngine
,
"FLUID_GPU_NATIVE_DIR_SIGMOID"
);
"FLUID_GPU_NATIVE_DIR_SIGMOID"
);
REGIST_FACTORY_OBJECT_IMPL_WITH_NAME
(
::
baidu
::
paddle_serving
::
predictor
::
FluidInferEngine
<
FluidGpuAnalysisEncryptCore
>
,
::
baidu
::
paddle_serving
::
predictor
::
InferEngine
,
"FLUID_GPU_ANALYSIS_ENCRPT"
)
}
// namespace fluid_gpu
}
// namespace fluid_gpu
}
// namespace paddle_serving
}
// namespace paddle_serving
}
// namespace baidu
}
// namespace baidu
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录