Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
4aeb261d
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4aeb261d
编写于
3月 07, 2019
作者:
L
lidanqing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add INT32 support. INT32 in last switch case
test=develop
上级
b0e3c024
变更
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
浏览文件 @
4aeb261d
...
@@ -243,6 +243,8 @@ bool AnalysisPredictor::SetFeed(const std::vector<PaddleTensor> &inputs,
...
@@ -243,6 +243,8 @@ bool AnalysisPredictor::SetFeed(const std::vector<PaddleTensor> &inputs,
input_ptr
=
input
.
mutable_data
<
int64_t
>
(
ddim
,
place_
);
input_ptr
=
input
.
mutable_data
<
int64_t
>
(
ddim
,
place_
);
}
else
if
(
inputs
[
i
].
dtype
==
PaddleDType
::
FLOAT32
)
{
}
else
if
(
inputs
[
i
].
dtype
==
PaddleDType
::
FLOAT32
)
{
input_ptr
=
input
.
mutable_data
<
float
>
(
ddim
,
place_
);
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
{
}
else
{
LOG
(
ERROR
)
<<
"unsupported feed type "
<<
inputs
[
i
].
dtype
;
LOG
(
ERROR
)
<<
"unsupported feed type "
<<
inputs
[
i
].
dtype
;
return
false
;
return
false
;
...
@@ -326,8 +328,11 @@ bool AnalysisPredictor::GetFetch(std::vector<PaddleTensor> *outputs,
...
@@ -326,8 +328,11 @@ bool AnalysisPredictor::GetFetch(std::vector<PaddleTensor> *outputs,
}
else
if
(
type
==
framework
::
proto
::
VarType
::
INT64
)
{
}
else
if
(
type
==
framework
::
proto
::
VarType
::
INT64
)
{
GetFetchOne
<
int64_t
>
(
fetch
,
output
);
GetFetchOne
<
int64_t
>
(
fetch
,
output
);
output
->
dtype
=
PaddleDType
::
INT64
;
output
->
dtype
=
PaddleDType
::
INT64
;
}
else
if
(
type
==
framework
::
proto
::
VarType
::
INT32
)
{
GetFetchOne
<
int32_t
>
(
fetch
,
output
);
output
->
dtype
=
PaddleDType
::
INT32
;
}
else
{
}
else
{
LOG
(
ERROR
)
<<
"unknown type, only support float32
and int64
now."
;
LOG
(
ERROR
)
<<
"unknown type, only support float32
, int64 and int32
now."
;
}
}
}
}
return
true
;
return
true
;
...
...
paddle/fluid/inference/api/api.cc
浏览文件 @
4aeb261d
...
@@ -28,6 +28,8 @@ int PaddleDtypeSize(PaddleDType dtype) {
...
@@ -28,6 +28,8 @@ int PaddleDtypeSize(PaddleDType dtype) {
return
sizeof
(
float
);
return
sizeof
(
float
);
case
PaddleDType
::
INT64
:
case
PaddleDType
::
INT64
:
return
sizeof
(
int64_t
);
return
sizeof
(
int64_t
);
case
PaddleDType
::
INT32
:
return
sizeof
(
int32_t
);
default:
default:
assert
(
false
);
assert
(
false
);
return
-
1
;
return
-
1
;
...
...
paddle/fluid/inference/api/api_impl.cc
浏览文件 @
4aeb261d
...
@@ -203,6 +203,8 @@ bool NativePaddlePredictor::SetFeed(const std::vector<PaddleTensor> &inputs,
...
@@ -203,6 +203,8 @@ bool NativePaddlePredictor::SetFeed(const std::vector<PaddleTensor> &inputs,
input_ptr
=
input
.
mutable_data
<
int64_t
>
(
ddim
,
place_
);
input_ptr
=
input
.
mutable_data
<
int64_t
>
(
ddim
,
place_
);
}
else
if
(
inputs
[
i
].
dtype
==
PaddleDType
::
FLOAT32
)
{
}
else
if
(
inputs
[
i
].
dtype
==
PaddleDType
::
FLOAT32
)
{
input_ptr
=
input
.
mutable_data
<
float
>
(
ddim
,
place_
);
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
{
}
else
{
LOG
(
ERROR
)
<<
"unsupported feed type "
<<
inputs
[
i
].
dtype
;
LOG
(
ERROR
)
<<
"unsupported feed type "
<<
inputs
[
i
].
dtype
;
return
false
;
return
false
;
...
@@ -281,8 +283,11 @@ bool NativePaddlePredictor::GetFetch(std::vector<PaddleTensor> *outputs,
...
@@ -281,8 +283,11 @@ bool NativePaddlePredictor::GetFetch(std::vector<PaddleTensor> *outputs,
}
else
if
(
type
==
framework
::
DataTypeTrait
<
int64_t
>::
DataType
)
{
}
else
if
(
type
==
framework
::
DataTypeTrait
<
int64_t
>::
DataType
)
{
GetFetchOne
<
int64_t
>
(
fetch
,
output
);
GetFetchOne
<
int64_t
>
(
fetch
,
output
);
output
->
dtype
=
PaddleDType
::
INT64
;
output
->
dtype
=
PaddleDType
::
INT64
;
}
else
if
(
type
==
framework
::
DataTypeTrait
<
int32_t
>::
DataType
)
{
GetFetchOne
<
int32_t
>
(
fetch
,
output
);
output
->
dtype
=
PaddleDType
::
INT32
;
}
else
{
}
else
{
LOG
(
ERROR
)
<<
"unknown type, only support float32
and int64
now."
;
LOG
(
ERROR
)
<<
"unknown type, only support float32
, int64 and int32
now."
;
}
}
}
}
return
true
;
return
true
;
...
...
paddle/fluid/inference/api/api_impl_tester.cc
浏览文件 @
4aeb261d
...
@@ -42,6 +42,9 @@ PaddleTensor LodTensorToPaddleTensor(framework::LoDTensor* t) {
...
@@ -42,6 +42,9 @@ PaddleTensor LodTensorToPaddleTensor(framework::LoDTensor* t) {
}
else
if
(
t
->
type
()
==
framework
::
proto
::
VarType
::
FP32
)
{
}
else
if
(
t
->
type
()
==
framework
::
proto
::
VarType
::
FP32
)
{
pt
.
data
.
Reset
(
t
->
data
<
void
>
(),
t
->
numel
()
*
sizeof
(
float
));
pt
.
data
.
Reset
(
t
->
data
<
void
>
(),
t
->
numel
()
*
sizeof
(
float
));
pt
.
dtype
=
PaddleDType
::
FLOAT32
;
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
{
}
else
{
LOG
(
FATAL
)
<<
"unsupported type."
;
LOG
(
FATAL
)
<<
"unsupported type."
;
}
}
...
...
paddle/fluid/inference/api/demo_ci/utils.h
浏览文件 @
4aeb261d
...
@@ -88,7 +88,7 @@ void CheckOutput(const std::string& referfile, const PaddleTensor& output) {
...
@@ -88,7 +88,7 @@ void CheckOutput(const std::string& referfile, const PaddleTensor& output) {
}
}
break
;
break
;
}
}
case
PaddleDType
::
FLOAT32
:
case
PaddleDType
::
FLOAT32
:
{
for
(
size_t
i
=
0
;
i
<
numel
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
numel
;
++
i
)
{
CHECK_LT
(
CHECK_LT
(
fabs
(
static_cast
<
float
*>
(
output
.
data
.
data
())[
i
]
-
refer
.
data
[
i
]),
fabs
(
static_cast
<
float
*>
(
output
.
data
.
data
())[
i
]
-
refer
.
data
[
i
]),
...
@@ -96,6 +96,13 @@ void CheckOutput(const std::string& referfile, const PaddleTensor& output) {
...
@@ -96,6 +96,13 @@ void CheckOutput(const std::string& referfile, const PaddleTensor& output) {
}
}
break
;
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,12 +120,19 @@ static std::string SummaryTensor(const PaddleTensor& tensor) {
...
@@ -113,12 +120,19 @@ static std::string SummaryTensor(const PaddleTensor& tensor) {
}
}
break
;
break
;
}
}
case
PaddleDType
::
FLOAT32
:
case
PaddleDType
::
FLOAT32
:
{
for
(
int
i
=
0
;
i
<
std
::
min
(
num_elems
,
10
);
i
++
)
{
for
(
int
i
=
0
;
i
<
std
::
min
(
num_elems
,
10
);
i
++
)
{
ss
<<
static_cast
<
float
*>
(
tensor
.
data
.
data
())[
i
]
<<
" "
;
ss
<<
static_cast
<
float
*>
(
tensor
.
data
.
data
())[
i
]
<<
" "
;
}
}
break
;
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
();
return
ss
.
str
();
}
}
...
...
paddle/fluid/inference/api/helper.h
浏览文件 @
4aeb261d
...
@@ -197,6 +197,9 @@ static std::string DescribeTensor(const PaddleTensor &tensor,
...
@@ -197,6 +197,9 @@ static std::string DescribeTensor(const PaddleTensor &tensor,
case
PaddleDType
::
INT64
:
case
PaddleDType
::
INT64
:
os
<<
"int64"
;
os
<<
"int64"
;
break
;
break
;
case
PaddleDType
::
INT32
:
os
<<
"int32"
;
break
;
default:
default:
os
<<
"unset"
;
os
<<
"unset"
;
}
}
...
...
paddle/fluid/inference/api/paddle_api.h
浏览文件 @
4aeb261d
...
@@ -36,6 +36,7 @@ namespace paddle {
...
@@ -36,6 +36,7 @@ namespace paddle {
enum
PaddleDType
{
enum
PaddleDType
{
FLOAT32
,
FLOAT32
,
INT64
,
INT64
,
INT32
,
// TODO(Superjomn) support more data types if needed.
// TODO(Superjomn) support more data types if needed.
};
};
...
...
paddle/fluid/inference/tests/api/tester_helper.h
浏览文件 @
4aeb261d
...
@@ -25,7 +25,6 @@
...
@@ -25,7 +25,6 @@
#ifdef WITH_GPERFTOOLS
#ifdef WITH_GPERFTOOLS
#include <gperftools/profiler.h>
#include <gperftools/profiler.h>
#endif
#endif
#include "paddle/fluid/framework/ir/fuse_pass_base.h"
#include "paddle/fluid/framework/ir/fuse_pass_base.h"
#include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/inference/analysis/analyzer.h"
#include "paddle/fluid/inference/analysis/analyzer.h"
...
@@ -97,6 +96,14 @@ void CompareResult(const std::vector<PaddleTensor> &outputs,
...
@@ -97,6 +96,14 @@ void CompareResult(const std::vector<PaddleTensor> &outputs,
}
}
break
;
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
浏览文件 @
4aeb261d
...
@@ -65,7 +65,8 @@ void BindInferenceApi(py::module *m) {
...
@@ -65,7 +65,8 @@ void BindInferenceApi(py::module *m) {
void
BindPaddleDType
(
py
::
module
*
m
)
{
void
BindPaddleDType
(
py
::
module
*
m
)
{
py
::
enum_
<
PaddleDType
>
(
*
m
,
"PaddleDType"
)
py
::
enum_
<
PaddleDType
>
(
*
m
,
"PaddleDType"
)
.
value
(
"FLOAT32"
,
PaddleDType
::
FLOAT32
)
.
value
(
"FLOAT32"
,
PaddleDType
::
FLOAT32
)
.
value
(
"INT64"
,
PaddleDType
::
INT64
);
.
value
(
"INT64"
,
PaddleDType
::
INT64
)
.
value
(
"INT32"
,
PaddleDType
::
INT32
);
}
}
void
BindPaddleBuf
(
py
::
module
*
m
)
{
void
BindPaddleBuf
(
py
::
module
*
m
)
{
...
@@ -103,6 +104,11 @@ void BindPaddleBuf(py::module *m) {
...
@@ -103,6 +104,11 @@ void BindPaddleBuf(py::module *m) {
int64_t
*
data
=
static_cast
<
int64_t
*>
(
self
.
data
());
int64_t
*
data
=
static_cast
<
int64_t
*>
(
self
.
data
());
return
{
data
,
data
+
self
.
length
()
/
sizeof
(
*
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
);
.
def
(
"length"
,
&
PaddleBuf
::
length
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录