Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
717bbc08
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看板
提交
717bbc08
编写于
3月 07, 2019
作者:
L
lidanqing
提交者:
ceci3
3月 08, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add INT32 support. INT32 in last switch case
test=develop
上级
bcd7b993
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
52 addition
and
6 deletion
+52
-6
paddle/fluid/inference/api/analysis_predictor.cc
paddle/fluid/inference/api/analysis_predictor.cc
+6
-1
paddle/fluid/inference/api/api.cc
paddle/fluid/inference/api/api.cc
+2
-0
paddle/fluid/inference/api/api_impl.cc
paddle/fluid/inference/api/api_impl.cc
+6
-1
paddle/fluid/inference/api/api_impl_tester.cc
paddle/fluid/inference/api/api_impl_tester.cc
+3
-0
paddle/fluid/inference/api/demo_ci/utils.h
paddle/fluid/inference/api/demo_ci/utils.h
+16
-2
paddle/fluid/inference/api/helper.h
paddle/fluid/inference/api/helper.h
+3
-0
paddle/fluid/inference/api/paddle_api.h
paddle/fluid/inference/api/paddle_api.h
+1
-0
paddle/fluid/inference/tests/api/tester_helper.h
paddle/fluid/inference/tests/api/tester_helper.h
+8
-1
paddle/fluid/pybind/inference_api.cc
paddle/fluid/pybind/inference_api.cc
+7
-1
未找到文件。
paddle/fluid/inference/api/analysis_predictor.cc
浏览文件 @
717bbc08
...
...
@@ -243,6 +243,8 @@ bool AnalysisPredictor::SetFeed(const std::vector<PaddleTensor> &inputs,
input_ptr
=
input
.
mutable_data
<
int64_t
>
(
ddim
,
place_
);
}
else
if
(
inputs
[
i
].
dtype
==
PaddleDType
::
FLOAT32
)
{
input_ptr
=
input
.
mutable_data
<
float
>
(
ddim
,
place_
);
}
else
if
(
inputs
[
i
].
dtype
==
PaddleDType
::
INT32
)
{
input_ptr
=
input
.
mutable_data
<
int32_t
>
(
ddim
,
place_
);
}
else
{
LOG
(
ERROR
)
<<
"unsupported feed type "
<<
inputs
[
i
].
dtype
;
return
false
;
...
...
@@ -326,8 +328,11 @@ bool AnalysisPredictor::GetFetch(std::vector<PaddleTensor> *outputs,
}
else
if
(
type
==
framework
::
proto
::
VarType
::
INT64
)
{
GetFetchOne
<
int64_t
>
(
fetch
,
output
);
output
->
dtype
=
PaddleDType
::
INT64
;
}
else
if
(
type
==
framework
::
proto
::
VarType
::
INT32
)
{
GetFetchOne
<
int32_t
>
(
fetch
,
output
);
output
->
dtype
=
PaddleDType
::
INT32
;
}
else
{
LOG
(
ERROR
)
<<
"unknown type, only support float32
and int64
now."
;
LOG
(
ERROR
)
<<
"unknown type, only support float32
, int64 and int32
now."
;
}
}
return
true
;
...
...
paddle/fluid/inference/api/api.cc
浏览文件 @
717bbc08
...
...
@@ -28,6 +28,8 @@ int PaddleDtypeSize(PaddleDType dtype) {
return
sizeof
(
float
);
case
PaddleDType
::
INT64
:
return
sizeof
(
int64_t
);
case
PaddleDType
::
INT32
:
return
sizeof
(
int32_t
);
default:
assert
(
false
);
return
-
1
;
...
...
paddle/fluid/inference/api/api_impl.cc
浏览文件 @
717bbc08
...
...
@@ -203,6 +203,8 @@ bool NativePaddlePredictor::SetFeed(const std::vector<PaddleTensor> &inputs,
input_ptr
=
input
.
mutable_data
<
int64_t
>
(
ddim
,
place_
);
}
else
if
(
inputs
[
i
].
dtype
==
PaddleDType
::
FLOAT32
)
{
input_ptr
=
input
.
mutable_data
<
float
>
(
ddim
,
place_
);
}
else
if
(
inputs
[
i
].
dtype
==
PaddleDType
::
INT32
)
{
input_ptr
=
input
.
mutable_data
<
int32_t
>
(
ddim
,
place_
);
}
else
{
LOG
(
ERROR
)
<<
"unsupported feed type "
<<
inputs
[
i
].
dtype
;
return
false
;
...
...
@@ -281,8 +283,11 @@ bool NativePaddlePredictor::GetFetch(std::vector<PaddleTensor> *outputs,
}
else
if
(
type
==
framework
::
DataTypeTrait
<
int64_t
>::
DataType
)
{
GetFetchOne
<
int64_t
>
(
fetch
,
output
);
output
->
dtype
=
PaddleDType
::
INT64
;
}
else
if
(
type
==
framework
::
DataTypeTrait
<
int32_t
>::
DataType
)
{
GetFetchOne
<
int32_t
>
(
fetch
,
output
);
output
->
dtype
=
PaddleDType
::
INT32
;
}
else
{
LOG
(
ERROR
)
<<
"unknown type, only support float32
and int64
now."
;
LOG
(
ERROR
)
<<
"unknown type, only support float32
, int64 and int32
now."
;
}
}
return
true
;
...
...
paddle/fluid/inference/api/api_impl_tester.cc
浏览文件 @
717bbc08
...
...
@@ -42,6 +42,9 @@ PaddleTensor LodTensorToPaddleTensor(framework::LoDTensor* t) {
}
else
if
(
t
->
type
()
==
framework
::
proto
::
VarType
::
FP32
)
{
pt
.
data
.
Reset
(
t
->
data
<
void
>
(),
t
->
numel
()
*
sizeof
(
float
));
pt
.
dtype
=
PaddleDType
::
FLOAT32
;
}
else
if
(
t
->
type
()
==
framework
::
proto
::
VarType
::
INT32
)
{
pt
.
data
.
Reset
(
t
->
data
<
void
>
(),
t
->
numel
()
*
sizeof
(
int32_t
));
pt
.
dtype
=
PaddleDType
::
INT32
;
}
else
{
LOG
(
FATAL
)
<<
"unsupported type."
;
}
...
...
paddle/fluid/inference/api/demo_ci/utils.h
浏览文件 @
717bbc08
...
...
@@ -88,13 +88,20 @@ void CheckOutput(const std::string& referfile, const PaddleTensor& output) {
}
break
;
}
case
PaddleDType
::
FLOAT32
:
case
PaddleDType
::
FLOAT32
:
{
for
(
size_t
i
=
0
;
i
<
numel
;
++
i
)
{
CHECK_LT
(
fabs
(
static_cast
<
float
*>
(
output
.
data
.
data
())[
i
]
-
refer
.
data
[
i
]),
1e-5
);
}
break
;
}
case
PaddleDType
::
INT32
:
{
for
(
size_t
i
=
0
;
i
<
numel
;
++
i
)
{
CHECK_EQ
(
static_cast
<
int32_t
*>
(
output
.
data
.
data
())[
i
],
refer
.
data
[
i
]);
}
break
;
}
}
}
...
...
@@ -113,11 +120,18 @@ static std::string SummaryTensor(const PaddleTensor& tensor) {
}
break
;
}
case
PaddleDType
::
FLOAT32
:
case
PaddleDType
::
FLOAT32
:
{
for
(
int
i
=
0
;
i
<
std
::
min
(
num_elems
,
10
);
i
++
)
{
ss
<<
static_cast
<
float
*>
(
tensor
.
data
.
data
())[
i
]
<<
" "
;
}
break
;
}
case
PaddleDType
::
INT32
:
{
for
(
int
i
=
0
;
i
<
std
::
min
(
num_elems
,
10
);
i
++
)
{
ss
<<
static_cast
<
int32_t
*>
(
tensor
.
data
.
data
())[
i
]
<<
" "
;
}
break
;
}
}
return
ss
.
str
();
}
...
...
paddle/fluid/inference/api/helper.h
浏览文件 @
717bbc08
...
...
@@ -202,6 +202,9 @@ static std::string DescribeTensor(const PaddleTensor &tensor,
case
PaddleDType
::
INT64
:
os
<<
"int64"
;
break
;
case
PaddleDType
::
INT32
:
os
<<
"int32"
;
break
;
default:
os
<<
"unset"
;
}
...
...
paddle/fluid/inference/api/paddle_api.h
浏览文件 @
717bbc08
...
...
@@ -36,6 +36,7 @@ namespace paddle {
enum
PaddleDType
{
FLOAT32
,
INT64
,
INT32
,
// TODO(Superjomn) support more data types if needed.
};
...
...
paddle/fluid/inference/tests/api/tester_helper.h
浏览文件 @
717bbc08
...
...
@@ -25,7 +25,6 @@
#ifdef WITH_GPERFTOOLS
#include <gperftools/profiler.h>
#endif
#include "paddle/fluid/framework/ir/fuse_pass_base.h"
#include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/inference/analysis/analyzer.h"
...
...
@@ -97,6 +96,14 @@ void CompareResult(const std::vector<PaddleTensor> &outputs,
}
break
;
}
case
PaddleDType
::
INT32
:
{
int32_t
*
pdata
=
static_cast
<
int32_t
*>
(
out
.
data
.
data
());
int32_t
*
pdata_ref
=
static_cast
<
int32_t
*>
(
ref_out
.
data
.
data
());
for
(
size_t
j
=
0
;
j
<
size
;
++
j
)
{
EXPECT_EQ
(
pdata_ref
[
j
],
pdata
[
j
]);
}
break
;
}
}
}
}
...
...
paddle/fluid/pybind/inference_api.cc
浏览文件 @
717bbc08
...
...
@@ -65,7 +65,8 @@ void BindInferenceApi(py::module *m) {
void
BindPaddleDType
(
py
::
module
*
m
)
{
py
::
enum_
<
PaddleDType
>
(
*
m
,
"PaddleDType"
)
.
value
(
"FLOAT32"
,
PaddleDType
::
FLOAT32
)
.
value
(
"INT64"
,
PaddleDType
::
INT64
);
.
value
(
"INT64"
,
PaddleDType
::
INT64
)
.
value
(
"INT32"
,
PaddleDType
::
INT32
);
}
void
BindPaddleBuf
(
py
::
module
*
m
)
{
...
...
@@ -103,6 +104,11 @@ void BindPaddleBuf(py::module *m) {
int64_t
*
data
=
static_cast
<
int64_t
*>
(
self
.
data
());
return
{
data
,
data
+
self
.
length
()
/
sizeof
(
*
data
)};
})
.
def
(
"int32_data"
,
[](
PaddleBuf
&
self
)
->
std
::
vector
<
int32_t
>
{
int32_t
*
data
=
static_cast
<
int32_t
*>
(
self
.
data
());
return
{
data
,
data
+
self
.
length
()
/
sizeof
(
*
data
)};
})
.
def
(
"length"
,
&
PaddleBuf
::
length
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录