Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
2fe032a1
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
2fe032a1
编写于
2月 25, 2020
作者:
L
liu zhengxi
提交者:
GitHub
2月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix CPU C inference API compile bug (#22702) (#22752)
Co-authored-by:
N
flame
<
fuchang1991@gmail.com
>
上级
78716128
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
30 addition
and
27 deletion
+30
-27
go/paddle/common.go
go/paddle/common.go
+0
-8
go/paddle/config.go
go/paddle/config.go
+8
-0
go/paddle/predictor.go
go/paddle/predictor.go
+2
-2
go/paddle/tensor.go
go/paddle/tensor.go
+4
-4
paddle/fluid/inference/CMakeLists.txt
paddle/fluid/inference/CMakeLists.txt
+14
-11
paddle/fluid/inference/capi/CMakeLists.txt
paddle/fluid/inference/capi/CMakeLists.txt
+2
-2
未找到文件。
go/paddle/common.go
浏览文件 @
2fe032a1
...
@@ -21,14 +21,6 @@ package paddle
...
@@ -21,14 +21,6 @@ package paddle
import
"C"
import
"C"
import
"fmt"
import
"fmt"
type
Precision
C
.
Precision
const
(
kFloat32
Precision
=
C
.
kFloat32
kInt8
Precision
=
C
.
kInt8
kHalf
Precision
=
C
.
kHalf
)
func
ConvertCBooleanToGo
(
b
C
.
bool
)
bool
{
func
ConvertCBooleanToGo
(
b
C
.
bool
)
bool
{
var
c_false
C
.
bool
var
c_false
C
.
bool
if
b
!=
c_false
{
if
b
!=
c_false
{
...
...
go/paddle/config.go
浏览文件 @
2fe032a1
...
@@ -24,6 +24,14 @@ import "C"
...
@@ -24,6 +24,14 @@ import "C"
import
"runtime"
import
"runtime"
import
"unsafe"
import
"unsafe"
type
Precision
C
.
Precision
const
(
Precision_FLOAT32
Precision
=
C
.
kFloat32
Precision_INT8
Precision
=
C
.
kInt8
Precision_HALF
Precision
=
C
.
kHalf
)
type
AnalysisConfig
struct
{
type
AnalysisConfig
struct
{
c
*
C
.
PD_AnalysisConfig
c
*
C
.
PD_AnalysisConfig
}
}
...
...
go/paddle/predictor.go
浏览文件 @
2fe032a1
...
@@ -102,12 +102,12 @@ func (predictor *Predictor) SetZeroCopyInput(tensor *ZeroCopyTensor) {
...
@@ -102,12 +102,12 @@ func (predictor *Predictor) SetZeroCopyInput(tensor *ZeroCopyTensor) {
func
(
predictor
*
Predictor
)
GetZeroCopyOutput
(
tensor
*
ZeroCopyTensor
)
{
func
(
predictor
*
Predictor
)
GetZeroCopyOutput
(
tensor
*
ZeroCopyTensor
)
{
C
.
PD_GetZeroCopyOutput
(
predictor
.
c
,
tensor
.
c
)
C
.
PD_GetZeroCopyOutput
(
predictor
.
c
,
tensor
.
c
)
tensor
.
name
=
C
.
GoString
(
tensor
.
c
.
name
)
tensor
.
name
=
C
.
GoString
(
tensor
.
c
.
name
)
var
shape
[]
int32
var
shape
[]
int32
shape_hdr
:=
(
*
reflect
.
SliceHeader
)(
unsafe
.
Pointer
(
&
shape
))
shape_hdr
:=
(
*
reflect
.
SliceHeader
)(
unsafe
.
Pointer
(
&
shape
))
shape_hdr
.
Data
=
uintptr
(
unsafe
.
Pointer
(
tensor
.
c
.
shape
.
data
))
shape_hdr
.
Data
=
uintptr
(
unsafe
.
Pointer
(
tensor
.
c
.
shape
.
data
))
shape_hdr
.
Len
=
int
(
tensor
.
c
.
shape
.
length
/
C
.
sizeof_int
)
shape_hdr
.
Len
=
int
(
tensor
.
c
.
shape
.
length
/
C
.
sizeof_int
)
shape_hdr
.
Cap
=
int
(
tensor
.
c
.
shape
.
length
/
C
.
sizeof_int
)
shape_hdr
.
Cap
=
int
(
tensor
.
c
.
shape
.
length
/
C
.
sizeof_int
)
tensor
.
Reshape
(
shape
)
tensor
.
Reshape
(
shape
)
}
}
func
(
predictor
*
Predictor
)
ZeroCopyRun
()
{
func
(
predictor
*
Predictor
)
ZeroCopyRun
()
{
...
...
go/paddle/tensor.go
浏览文件 @
2fe032a1
...
@@ -137,16 +137,16 @@ func (tensor *ZeroCopyTensor) SetValue(value interface{}) {
...
@@ -137,16 +137,16 @@ func (tensor *ZeroCopyTensor) SetValue(value interface{}) {
tensor
.
c
.
data
.
length
=
length
tensor
.
c
.
data
.
length
=
length
switch
dtype
{
switch
dtype
{
case
PaddleDType
(
UINT8
)
:
case
PaddleDType
(
UINT8
)
:
data
:=
val
.
Interface
()
.
([]
uint8
)
data
:=
val
.
Interface
()
.
([]
uint8
)
C
.
memcpy
(
tensor
.
c
.
data
.
data
,
unsafe
.
Pointer
(
&
data
[
0
]),
length
)
C
.
memcpy
(
tensor
.
c
.
data
.
data
,
unsafe
.
Pointer
(
&
data
[
0
]),
length
)
case
PaddleDType
(
INT32
)
:
case
PaddleDType
(
INT32
)
:
data
:=
val
.
Interface
()
.
([]
int32
)
data
:=
val
.
Interface
()
.
([]
int32
)
C
.
memcpy
(
tensor
.
c
.
data
.
data
,
unsafe
.
Pointer
(
&
data
[
0
]),
length
)
C
.
memcpy
(
tensor
.
c
.
data
.
data
,
unsafe
.
Pointer
(
&
data
[
0
]),
length
)
case
PaddleDType
(
INT64
)
:
case
PaddleDType
(
INT64
)
:
data
:=
val
.
Interface
()
.
([]
int64
)
data
:=
val
.
Interface
()
.
([]
int64
)
C
.
memcpy
(
tensor
.
c
.
data
.
data
,
unsafe
.
Pointer
(
&
data
[
0
]),
length
)
C
.
memcpy
(
tensor
.
c
.
data
.
data
,
unsafe
.
Pointer
(
&
data
[
0
]),
length
)
case
PaddleDType
(
FLOAT32
)
:
case
PaddleDType
(
FLOAT32
)
:
data
:=
val
.
Interface
()
.
([]
float32
)
data
:=
val
.
Interface
()
.
([]
float32
)
C
.
memcpy
(
tensor
.
c
.
data
.
data
,
unsafe
.
Pointer
(
&
data
[
0
]),
length
)
C
.
memcpy
(
tensor
.
c
.
data
.
data
,
unsafe
.
Pointer
(
&
data
[
0
]),
length
)
}
}
...
...
paddle/fluid/inference/CMakeLists.txt
浏览文件 @
2fe032a1
...
@@ -39,6 +39,20 @@ get_property(fluid_modules GLOBAL PROPERTY FLUID_MODULES)
...
@@ -39,6 +39,20 @@ get_property(fluid_modules GLOBAL PROPERTY FLUID_MODULES)
get_property
(
cuda_modules GLOBAL PROPERTY CUDA_MODULES
)
get_property
(
cuda_modules GLOBAL PROPERTY CUDA_MODULES
)
add_subdirectory
(
api
)
add_subdirectory
(
api
)
# Create static inference library if needed
# All static libs in inference/api
set
(
STATIC_INFERENCE_API paddle_inference_api analysis_predictor zero_copy_tensor reset_tensor_array
analysis_config paddle_pass_builder activation_functions
${
mkldnn_quantizer_cfg
}
)
create_static_lib
(
paddle_fluid
${
fluid_modules
}
${
STATIC_INFERENCE_API
}
)
if
(
NOT APPLE
)
# TODO(liuyiqu: Temporarily disable the link flag because it is not support on Mac.
set
(
LINK_FLAGS
"-Wl,--retain-symbols-file
${
CMAKE_CURRENT_SOURCE_DIR
}
/paddle_fluid.sym"
)
set_target_properties
(
paddle_fluid PROPERTIES LINK_FLAGS
"
${
LINK_FLAGS
}
"
)
endif
()
# C inference API
add_subdirectory
(
capi
)
add_subdirectory
(
capi
)
if
(
WITH_TESTING
)
if
(
WITH_TESTING
)
...
@@ -53,17 +67,6 @@ if(NOT ON_INFER)
...
@@ -53,17 +67,6 @@ if(NOT ON_INFER)
return
()
return
()
endif
()
endif
()
# Create static inference library if needed
# All static libs in inference/api
set
(
STATIC_INFERENCE_API paddle_inference_api analysis_predictor zero_copy_tensor reset_tensor_array
analysis_config paddle_pass_builder activation_functions
${
mkldnn_quantizer_cfg
}
)
create_static_lib
(
paddle_fluid
${
fluid_modules
}
${
STATIC_INFERENCE_API
}
)
if
(
NOT APPLE
)
# TODO(liuyiqu: Temporarily disable the link flag because it is not support on Mac.
set
(
LINK_FLAGS
"-Wl,--retain-symbols-file
${
CMAKE_CURRENT_SOURCE_DIR
}
/paddle_fluid.sym"
)
set_target_properties
(
paddle_fluid PROPERTIES LINK_FLAGS
"
${
LINK_FLAGS
}
"
)
endif
()
set
(
SHARED_INFERENCE_SRCS
set
(
SHARED_INFERENCE_SRCS
io.cc
io.cc
${
CMAKE_CURRENT_SOURCE_DIR
}
/../framework/data_feed.cc
${
CMAKE_CURRENT_SOURCE_DIR
}
/../framework/data_feed.cc
...
...
paddle/fluid/inference/capi/CMakeLists.txt
浏览文件 @
2fe032a1
...
@@ -15,14 +15,14 @@
...
@@ -15,14 +15,14 @@
set
(
C_API_SRCS pd_config.cc pd_predictor.cc pd_tensor.cc c_api.cc
)
set
(
C_API_SRCS pd_config.cc pd_predictor.cc pd_tensor.cc c_api.cc
)
cc_library
(
paddle_fluid_c SRCS
${
C_API_SRCS
}
DEPS
${
fluid_modules
}
analysis_predictor
)
cc_library
(
paddle_fluid_c SRCS
${
C_API_SRCS
}
DEPS
paddle_fluid
)
if
(
NOT ON_INFER
)
if
(
NOT ON_INFER
)
return
()
return
()
endif
()
endif
()
# Create inference capi shared library
# Create inference capi shared library
cc_library
(
paddle_fluid_c_shared SHARED SRCS
${
C_API_SRCS
}
DEPS
${
fluid_modules
}
analysis_predictor
)
cc_library
(
paddle_fluid_c_shared SHARED SRCS
${
C_API_SRCS
}
DEPS
paddle_fluid
)
set_target_properties
(
paddle_fluid_c_shared PROPERTIES OUTPUT_NAME paddle_fluid_c
)
set_target_properties
(
paddle_fluid_c_shared PROPERTIES OUTPUT_NAME paddle_fluid_c
)
if
(
WIN32
)
if
(
WIN32
)
target_link_libraries
(
paddle_fluid_c_shared shlwapi.lib
)
target_link_libraries
(
paddle_fluid_c_shared shlwapi.lib
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录