Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
3da43dca
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3da43dca
编写于
11月 08, 2018
作者:
M
minqiyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Because anakin do NOT use glog, so we revert anakin related change
test=develop
上级
49710960
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
20 deletion
+20
-20
paddle/fluid/inference/api/api_anakin_engine.cc
paddle/fluid/inference/api/api_anakin_engine.cc
+18
-18
paddle/fluid/inference/tests/api/anakin_rnn1_tester.cc
paddle/fluid/inference/tests/api/anakin_rnn1_tester.cc
+2
-2
未找到文件。
paddle/fluid/inference/api/api_anakin_engine.cc
浏览文件 @
3da43dca
...
...
@@ -50,7 +50,7 @@ template <typename Target>
bool
PaddleInferenceAnakinPredictor
<
Target
>::
Init
(
const
contrib
::
AnakinConfig
&
config
)
{
if
(
!
(
graph_
.
load
(
config
.
model_file
)))
{
VLOG
(
3
0
)
<<
"fail to load graph from "
<<
config
.
model_file
;
VLOG
(
3
)
<<
"fail to load graph from "
<<
config
.
model_file
;
return
false
;
}
auto
inputs
=
graph_
.
get_ins
();
...
...
@@ -76,15 +76,15 @@ bool PaddleInferenceAnakinPredictor<Target>::Run(
std
::
vector
<
PaddleTensor
>
*
output_data
,
int
batch_size
)
{
for
(
const
auto
&
input
:
inputs
)
{
if
(
input
.
dtype
!=
PaddleDType
::
FLOAT32
)
{
VLOG
(
3
0
)
<<
"Only support float type inputs. "
<<
input
.
name
<<
"'s type is not float"
;
VLOG
(
3
)
<<
"Only support float type inputs. "
<<
input
.
name
<<
"'s type is not float"
;
return
false
;
}
auto
d_tensor_in_p
=
executor_p_
->
get_in
(
input
.
name
);
auto
net_shape
=
d_tensor_in_p
->
shape
();
if
(
net_shape
.
size
()
!=
input
.
shape
.
size
())
{
VLOG
(
3
0
)
<<
" input "
<<
input
.
name
<<
"'s shape size should be equal to that of net"
;
VLOG
(
3
)
<<
" input "
<<
input
.
name
<<
"'s shape size should be equal to that of net"
;
return
false
;
}
int
sum
=
1
;
...
...
@@ -105,15 +105,15 @@ bool PaddleInferenceAnakinPredictor<Target>::Run(
if
(
input
.
lod
.
size
()
>
0
)
{
if
(
input
.
lod
.
size
()
>
1
)
{
VLOG
(
3
0
)
<<
" input lod first dim should <=1, but you set "
<<
input
.
lod
.
size
();
VLOG
(
3
)
<<
" input lod first dim should <=1, but you set "
<<
input
.
lod
.
size
();
return
false
;
}
std
::
vector
<
int
>
offset
(
input
.
lod
[
0
].
begin
(),
input
.
lod
[
0
].
end
());
d_tensor_in_p
->
set_seq_offset
(
offset
);
VLOG
(
3
0
)
<<
"offset.size(): "
<<
offset
.
size
();
VLOG
(
3
)
<<
"offset.size(): "
<<
offset
.
size
();
for
(
int
i
=
0
;
i
<
offset
.
size
();
i
++
)
{
VLOG
(
3
0
)
<<
offset
[
i
];
VLOG
(
3
)
<<
offset
[
i
];
}
}
...
...
@@ -124,7 +124,7 @@ bool PaddleInferenceAnakinPredictor<Target>::Run(
if
(
cudaMemcpy
(
d_data_p
,
static_cast
<
float
*>
(
input
.
data
.
data
()),
d_tensor_in_p
->
valid_size
()
*
sizeof
(
float
),
cudaMemcpyHostToDevice
)
!=
0
)
{
VLOG
(
3
0
)
<<
"copy data from CPU to GPU error"
;
VLOG
(
3
)
<<
"copy data from CPU to GPU error"
;
return
false
;
}
}
...
...
@@ -141,7 +141,7 @@ bool PaddleInferenceAnakinPredictor<Target>::Run(
#endif
if
(
output_data
->
empty
())
{
VLOG
(
3
0
)
<<
"At least one output should be set with tensors' names."
;
VLOG
(
3
)
<<
"At least one output should be set with tensors' names."
;
return
false
;
}
for
(
auto
&
output
:
*
output_data
)
{
...
...
@@ -157,7 +157,7 @@ bool PaddleInferenceAnakinPredictor<Target>::Run(
if
(
cudaMemcpy
(
output
.
data
.
data
(),
tensor
->
mutable_data
(),
tensor
->
valid_size
()
*
sizeof
(
float
),
cudaMemcpyDeviceToHost
)
!=
0
)
{
VLOG
(
3
0
)
<<
"copy data from GPU to CPU error"
;
VLOG
(
3
)
<<
"copy data from GPU to CPU error"
;
return
false
;
}
}
...
...
@@ -181,14 +181,14 @@ anakin::Net<Target, anakin::saber::AK_FLOAT, anakin::Precision::FP32>
template
<
typename
Target
>
std
::
unique_ptr
<
PaddlePredictor
>
PaddleInferenceAnakinPredictor
<
Target
>::
Clone
()
{
VLOG
(
3
0
)
<<
"Anakin Predictor::clone"
;
VLOG
(
3
)
<<
"Anakin Predictor::clone"
;
std
::
unique_ptr
<
PaddlePredictor
>
cls
(
new
PaddleInferenceAnakinPredictor
<
Target
>
());
// construct executer from other graph
auto
anakin_predictor_p
=
dynamic_cast
<
PaddleInferenceAnakinPredictor
<
Target
>
*>
(
cls
.
get
());
if
(
!
anakin_predictor_p
)
{
VLOG
(
3
0
)
<<
"fail to call Init"
;
VLOG
(
3
)
<<
"fail to call Init"
;
return
nullptr
;
}
anakin_predictor_p
->
get_executer
().
init
(
graph_
);
...
...
@@ -206,10 +206,10 @@ template <>
std
::
unique_ptr
<
PaddlePredictor
>
CreatePaddlePredictor
<
contrib
::
AnakinConfig
,
PaddleEngineKind
::
kAnakin
>
(
const
contrib
::
AnakinConfig
&
config
)
{
VLOG
(
3
0
)
<<
"Anakin Predictor create."
;
VLOG
(
3
)
<<
"Anakin Predictor create."
;
if
(
config
.
target_type
==
contrib
::
AnakinConfig
::
NVGPU
)
{
#ifdef PADDLE_WITH_CUDA
VLOG
(
3
0
)
<<
"Anakin Predictor create on [ NVIDIA GPU ]."
;
VLOG
(
3
)
<<
"Anakin Predictor create on [ NVIDIA GPU ]."
;
std
::
unique_ptr
<
PaddlePredictor
>
x
(
new
PaddleInferenceAnakinPredictor
<
anakin
::
NV
>
(
config
));
return
x
;
...
...
@@ -218,12 +218,12 @@ CreatePaddlePredictor<contrib::AnakinConfig, PaddleEngineKind::kAnakin>(
return
nullptr
;
#endif
}
else
if
(
config
.
target_type
==
contrib
::
AnakinConfig
::
X86
)
{
VLOG
(
3
0
)
<<
"Anakin Predictor create on [ Intel X86 ]."
;
VLOG
(
3
)
<<
"Anakin Predictor create on [ Intel X86 ]."
;
std
::
unique_ptr
<
PaddlePredictor
>
x
(
new
PaddleInferenceAnakinPredictor
<
anakin
::
X86
>
(
config
));
return
x
;
}
else
{
VLOG
(
3
0
)
<<
"Anakin Predictor create on unknown platform."
;
VLOG
(
3
)
<<
"Anakin Predictor create on unknown platform."
;
return
nullptr
;
}
}
...
...
paddle/fluid/inference/tests/api/anakin_rnn1_tester.cc
浏览文件 @
3da43dca
...
...
@@ -217,9 +217,9 @@ void single_test() {
LOG
(
INFO
)
<<
"sequence_length = "
<<
seq_offset
[
seq_offset
.
size
()
-
1
];
float
*
data_o
=
static_cast
<
float
*>
(
outputs
[
0
].
data
.
data
());
VLOG
(
3
0
)
<<
"outputs[0].data.length() = "
<<
outputs
[
0
].
data
.
length
();
VLOG
(
3
)
<<
"outputs[0].data.length() = "
<<
outputs
[
0
].
data
.
length
();
for
(
size_t
j
=
0
;
j
<
outputs
[
0
].
data
.
length
();
++
j
)
{
VLOG
(
3
0
)
<<
"output["
<<
j
<<
"]: "
<<
data_o
[
j
];
VLOG
(
3
)
<<
"output["
<<
j
<<
"]: "
<<
data_o
[
j
];
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录