Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
0afd5c30
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0afd5c30
编写于
3月 21, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stash
上级
b5288289
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
92 addition
and
82 deletion
+92
-82
paddle/capi/Arguments.cpp
paddle/capi/Arguments.cpp
+29
-20
paddle/capi/GradientMachine.cpp
paddle/capi/GradientMachine.cpp
+2
-2
paddle/capi/PaddleCAPI.h
paddle/capi/PaddleCAPI.h
+33
-33
paddle/capi/tests/test_Arguments.cpp
paddle/capi/tests/test_Arguments.cpp
+20
-19
paddle/capi/tests/test_GradientMachine.cpp
paddle/capi/tests/test_GradientMachine.cpp
+8
-8
未找到文件。
paddle/capi/Arguments.cpp
浏览文件 @
0afd5c30
...
...
@@ -21,27 +21,31 @@ using paddle::capi::cast;
#define castIVec(v) cast<paddle::capi::CIVector>(v)
extern
"C"
{
PD_Arguments
PDArgsCreateNone
()
{
return
new
paddle
::
capi
::
CArguments
();
}
paddle_arguments
paddle_arguments_create_none
()
{
return
new
paddle
::
capi
::
CArguments
();
}
paddle_error
PDArgsDestroy
(
PD_A
rguments
args
)
{
paddle_error
paddle_arguments_destroy
(
paddle_a
rguments
args
)
{
if
(
args
==
nullptr
)
return
kPD_NULLPTR
;
delete
castArg
(
args
);
return
kPD_NO_ERROR
;
}
paddle_error
PDArgsGetSize
(
PD_A
rguments
args
,
uint64_t
*
size
)
{
paddle_error
paddle_arguments_size
(
paddle_a
rguments
args
,
uint64_t
*
size
)
{
if
(
args
==
nullptr
||
size
==
nullptr
)
return
kPD_NULLPTR
;
*
size
=
castArg
(
args
)
->
args
.
size
();
return
kPD_NO_ERROR
;
}
paddle_error
PDArgsResize
(
PD_A
rguments
args
,
uint64_t
size
)
{
paddle_error
paddle_arguments_resize
(
paddle_a
rguments
args
,
uint64_t
size
)
{
if
(
args
==
nullptr
)
return
kPD_NULLPTR
;
castArg
(
args
)
->
args
.
resize
(
size
);
return
kPD_NO_ERROR
;
}
paddle_error
PDArgsSetValue
(
PD_Arguments
args
,
uint64_t
ID
,
paddle_matrix
mat
)
{
paddle_error
paddle_arguments_set_value
(
paddle_arguments
args
,
uint64_t
ID
,
paddle_matrix
mat
)
{
if
(
args
==
nullptr
||
mat
==
nullptr
)
return
kPD_NULLPTR
;
auto
m
=
paddle
::
capi
::
cast
<
paddle
::
capi
::
CMatrix
>
(
mat
);
if
(
m
->
mat
==
nullptr
)
return
kPD_NULLPTR
;
...
...
@@ -51,7 +55,9 @@ paddle_error PDArgsSetValue(PD_Arguments args, uint64_t ID, paddle_matrix mat) {
return
kPD_NO_ERROR
;
}
paddle_error
PDArgsGetValue
(
PD_Arguments
args
,
uint64_t
ID
,
paddle_matrix
mat
)
{
paddle_error
paddle_arguments_value
(
paddle_arguments
args
,
uint64_t
ID
,
paddle_matrix
mat
)
{
if
(
args
==
nullptr
||
mat
==
nullptr
)
return
kPD_NULLPTR
;
auto
m
=
paddle
::
capi
::
cast
<
paddle
::
capi
::
CMatrix
>
(
mat
);
auto
a
=
castArg
(
args
);
...
...
@@ -60,7 +66,9 @@ paddle_error PDArgsGetValue(PD_Arguments args, uint64_t ID, paddle_matrix mat) {
return
kPD_NO_ERROR
;
}
paddle_error
PDArgsGetIds
(
PD_Arguments
args
,
uint64_t
ID
,
paddle_ivector
ids
)
{
paddle_error
paddle_arguments_ids
(
paddle_arguments
args
,
uint64_t
ID
,
paddle_ivector
ids
)
{
if
(
args
==
nullptr
||
ids
==
nullptr
)
return
kPD_NULLPTR
;
auto
iv
=
castIVec
(
ids
);
auto
a
=
castArg
(
args
);
...
...
@@ -69,7 +77,9 @@ paddle_error PDArgsGetIds(PD_Arguments args, uint64_t ID, paddle_ivector ids) {
return
kPD_NO_ERROR
;
}
paddle_error
PDArgsSetIds
(
PD_Arguments
args
,
uint64_t
ID
,
paddle_ivector
ids
)
{
paddle_error
paddle_arguments_set_ids
(
paddle_arguments
args
,
uint64_t
ID
,
paddle_ivector
ids
)
{
//! TODO(lizhao): Complete this method.
if
(
args
==
nullptr
||
ids
==
nullptr
)
return
kPD_NULLPTR
;
auto
iv
=
paddle
::
capi
::
cast
<
paddle
::
capi
::
CIVector
>
(
ids
);
...
...
@@ -80,9 +90,9 @@ paddle_error PDArgsSetIds(PD_Arguments args, uint64_t ID, paddle_ivector ids) {
return
kPD_NO_ERROR
;
}
paddle_error
PDArgsSetSequenceStartPos
(
PD_A
rguments
args
,
uint64_t
ID
,
paddle_ivector
seqPos
)
{
paddle_error
paddle_arguments_set_sequence_start_pos
(
paddle_a
rguments
args
,
uint64_t
ID
,
paddle_ivector
seqPos
)
{
if
(
args
==
nullptr
||
seqPos
==
nullptr
)
return
kPD_NULLPTR
;
auto
iv
=
paddle
::
capi
::
cast
<
paddle
::
capi
::
CIVector
>
(
seqPos
);
if
(
iv
->
vec
==
nullptr
)
return
kPD_NULLPTR
;
...
...
@@ -93,9 +103,8 @@ paddle_error PDArgsSetSequenceStartPos(PD_Arguments args,
return
kPD_NO_ERROR
;
}
paddle_error
PDArgsSetSubSequenceStartPos
(
PD_Arguments
args
,
uint64_t
ID
,
paddle_ivector
subSeqPos
)
{
paddle_error
paddle_arguments_set_sub_sequence_start_pos
(
paddle_arguments
args
,
uint64_t
ID
,
paddle_ivector
subSeqPos
)
{
if
(
args
==
nullptr
||
subSeqPos
==
nullptr
)
return
kPD_NULLPTR
;
auto
iv
=
paddle
::
capi
::
cast
<
paddle
::
capi
::
CIVector
>
(
subSeqPos
);
if
(
iv
->
vec
==
nullptr
)
return
kPD_NULLPTR
;
...
...
@@ -106,9 +115,9 @@ paddle_error PDArgsSetSubSequenceStartPos(PD_Arguments args,
return
kPD_NO_ERROR
;
}
paddle_error
PDArgsGetSequenceStartPos
(
PD_A
rguments
args
,
uint64_t
ID
,
paddle_ivector
seqPos
)
{
paddle_error
paddle_arguments_sequence_start_pos
(
paddle_a
rguments
args
,
uint64_t
ID
,
paddle_ivector
seqPos
)
{
if
(
args
==
nullptr
||
seqPos
==
nullptr
)
return
kPD_NULLPTR
;
auto
iv
=
castIVec
(
seqPos
);
auto
a
=
castArg
(
args
);
...
...
@@ -118,9 +127,9 @@ paddle_error PDArgsGetSequenceStartPos(PD_Arguments args,
return
kPD_NO_ERROR
;
}
paddle_error
PDArgsGetSubSequenceStartPos
(
PD_A
rguments
args
,
uint64_t
ID
,
paddle_ivector
subSeqPos
)
{
paddle_error
paddle_arguments_sub_sequence_start_pos
(
paddle_a
rguments
args
,
uint64_t
ID
,
paddle_ivector
subSeqPos
)
{
if
(
args
==
nullptr
||
subSeqPos
==
nullptr
)
return
kPD_NULLPTR
;
auto
iv
=
castIVec
(
subSeqPos
);
auto
a
=
castArg
(
args
);
...
...
paddle/capi/GradientMachine.cpp
浏览文件 @
0afd5c30
...
...
@@ -70,8 +70,8 @@ paddle_error PDGradientMachineLoadParameterFromDisk(PD_GradientMachine machine,
}
paddle_error
PDGradientMachineForward
(
PD_GradientMachine
machine
,
PD_A
rguments
inArgs
,
PD_A
rguments
outArgs
,
paddle_a
rguments
inArgs
,
paddle_a
rguments
outArgs
,
bool
isTrain
)
{
auto
m
=
cast
(
machine
);
auto
in
=
paddle
::
capi
::
cast
<
paddle
::
capi
::
CArguments
>
(
inArgs
);
...
...
paddle/capi/PaddleCAPI.h
浏览文件 @
0afd5c30
...
...
@@ -36,20 +36,21 @@ extern "C" {
* Arguments functions. Each argument means layer output. Arguments means a
* array of arguemnt.
*/
typedef
void
*
PD_A
rguments
;
typedef
void
*
paddle_a
rguments
;
/**
* @brief PDArgsCreateNone Create a array of arguments, which size is zero.
* @brief paddle_arguments_create_none Create a array of arguments, which size
* is zero.
* @return Arguemnts
*/
PD_API
PD_Arguments
PDArgsCreateN
one
();
PD_API
paddle_arguments
paddle_arguments_create_n
one
();
/**
* @brief
PDArgsD
estroy Destroy the arguments
* @brief
paddle_arguments_d
estroy Destroy the arguments
* @param args arguments to destroy
* @return paddle_error
*/
PD_API
paddle_error
PDArgsDestroy
(
PD_A
rguments
args
);
PD_API
paddle_error
paddle_arguments_destroy
(
paddle_a
rguments
args
);
/**
* @brief PDArgsGetSize Get size of arguments array
...
...
@@ -57,7 +58,8 @@ PD_API paddle_error PDArgsDestroy(PD_Arguments args);
* @param [out] size array size
* @return paddle_error
*/
PD_API
paddle_error
PDArgsGetSize
(
PD_Arguments
args
,
uint64_t
*
size
);
PD_API
paddle_error
paddle_arguments_size
(
paddle_arguments
args
,
uint64_t
*
size
);
/**
* @brief PDArgsResize Resize a arguments array.
...
...
@@ -65,7 +67,8 @@ PD_API paddle_error PDArgsGetSize(PD_Arguments args, uint64_t* size);
* @param size target size of array
* @return paddle_error
*/
PD_API
paddle_error
PDArgsResize
(
PD_Arguments
args
,
uint64_t
size
);
PD_API
paddle_error
paddle_arguments_resize
(
paddle_arguments
args
,
uint64_t
size
);
/**
* @brief PDArgsSetValue Set value matrix of one argument in array, which index
...
...
@@ -75,9 +78,9 @@ PD_API paddle_error PDArgsResize(PD_Arguments args, uint64_t size);
* @param mat matrix pointer
* @return paddle_error
*/
PD_API
paddle_error
PDArgsSetValue
(
PD_A
rguments
args
,
uint64_t
ID
,
paddle_matrix
mat
);
PD_API
paddle_error
paddle_arguments_set_value
(
paddle_a
rguments
args
,
uint64_t
ID
,
paddle_matrix
mat
);
/**
* @brief PDArgsGetValue Get value matrix of one argument in array, which index
...
...
@@ -87,9 +90,9 @@ PD_API paddle_error PDArgsSetValue(PD_Arguments args,
* @param [out] mat matrix pointer
* @return paddle_error
*/
PD_API
paddle_error
PDArgsGetValue
(
PD_A
rguments
args
,
uint64_t
ID
,
paddle_matrix
mat
);
PD_API
paddle_error
paddle_arguments_value
(
paddle_a
rguments
args
,
uint64_t
ID
,
paddle_matrix
mat
);
/**
* @brief PDArgsGetIds Get the integer vector of one argument in array, which
...
...
@@ -99,9 +102,9 @@ PD_API paddle_error PDArgsGetValue(PD_Arguments args,
* @param ids integer vector pointer
* @return paddle_error
*/
PD_API
paddle_error
PDArgsGetIds
(
PD_A
rguments
args
,
uint64_t
ID
,
paddle_ivector
ids
);
PD_API
paddle_error
paddle_arguments_ids
(
paddle_a
rguments
args
,
uint64_t
ID
,
paddle_ivector
ids
);
/**
* @brief PDArgsSetIds Set the integer vector of one argument in array, which
...
...
@@ -111,9 +114,9 @@ PD_API paddle_error PDArgsGetIds(PD_Arguments args,
* @param [out] ids integer vector pointer
* @return paddle_error
*/
PD_API
paddle_error
PDArgsSetIds
(
PD_A
rguments
args
,
uint64_t
ID
,
paddle_ivector
ids
);
PD_API
paddle_error
paddle_arguments_set_ids
(
paddle_a
rguments
args
,
uint64_t
ID
,
paddle_ivector
ids
);
/**
* @brief PDArgsSetSequenceStartPos Set sequence start position vector of one
...
...
@@ -123,9 +126,8 @@ PD_API paddle_error PDArgsSetIds(PD_Arguments args,
* @param seqPos sequence position array.
* @return paddle_error
*/
PD_API
paddle_error
PDArgsSetSequenceStartPos
(
PD_Arguments
args
,
uint64_t
ID
,
paddle_ivector
seqPos
);
PD_API
paddle_error
paddle_arguments_set_sequence_start_pos
(
paddle_arguments
args
,
uint64_t
ID
,
paddle_ivector
seqPos
);
/**
* @brief PDArgsGetSequenceStartPos Get sequence start position vector of one
* argument in array, which index is `ID`.
...
...
@@ -134,9 +136,9 @@ PD_API paddle_error PDArgsSetSequenceStartPos(PD_Arguments args,
* @param [out] seqPos sequence position array
* @return paddle_error
*/
PD_API
paddle_error
PDArgsGetSequenceStartPos
(
PD_A
rguments
args
,
uint64_t
ID
,
paddle_ivector
seqPos
);
PD_API
paddle_error
paddle_arguments_sequence_start_pos
(
paddle_a
rguments
args
,
uint64_t
ID
,
paddle_ivector
seqPos
);
/**
* @brief PDArgsSetSubSequenceStartPos Set sub-sequence start position vector of
...
...
@@ -146,9 +148,8 @@ PD_API paddle_error PDArgsGetSequenceStartPos(PD_Arguments args,
* @param subSeqPos sub-sequence start position array.
* @return paddle_error
*/
PD_API
paddle_error
PDArgsSetSubSequenceStartPos
(
PD_Arguments
args
,
uint64_t
ID
,
paddle_ivector
subSeqPos
);
PD_API
paddle_error
paddle_arguments_set_sub_sequence_start_pos
(
paddle_arguments
args
,
uint64_t
ID
,
paddle_ivector
subSeqPos
);
/**
* @brief PDArgsGetSubSequenceStartPos Get sub-sequence start position vector of
...
...
@@ -158,9 +159,8 @@ PD_API paddle_error PDArgsSetSubSequenceStartPos(PD_Arguments args,
* @param subSeqPos sub-sequence start position array
* @return paddle_error
*/
PD_API
paddle_error
PDArgsGetSubSequenceStartPos
(
PD_Arguments
args
,
uint64_t
ID
,
paddle_ivector
subSeqPos
);
PD_API
paddle_error
paddle_arguments_sub_sequence_start_pos
(
paddle_arguments
args
,
uint64_t
ID
,
paddle_ivector
subSeqPos
);
/**
* @brief GradientMachine means a neural network.
*/
...
...
@@ -195,8 +195,8 @@ PD_API paddle_error PDGradientMachineLoadParameterFromDisk(
* @return paddle_error
*/
PD_API
paddle_error
PDGradientMachineForward
(
PD_GradientMachine
machine
,
PD_A
rguments
inArgs
,
PD_A
rguments
outArgs
,
paddle_a
rguments
inArgs
,
paddle_a
rguments
outArgs
,
bool
isTrain
);
/**
...
...
paddle/capi/tests/test_Arguments.cpp
浏览文件 @
0afd5c30
...
...
@@ -28,27 +28,27 @@ static std::vector<pd_real> randomBuffer(size_t bufSize) {
}
TEST
(
CAPIArguments
,
create
)
{
PD_Arguments
args
=
PDArgsCreateN
one
();
paddle_arguments
args
=
paddle_arguments_create_n
one
();
uint64_t
size
;
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsGetS
ize
(
args
,
&
size
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_s
ize
(
args
,
&
size
));
ASSERT_EQ
(
0UL
,
size
);
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsD
estroy
(
args
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_d
estroy
(
args
));
}
TEST
(
CAPIArguments
,
value
)
{
PD_Arguments
args
=
PDArgsCreateN
one
();
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsR
esize
(
args
,
1
));
paddle_arguments
args
=
paddle_arguments_create_n
one
();
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_r
esize
(
args
,
1
));
paddle_matrix
mat
=
paddle_matrix_create
(
128
,
64
,
false
);
for
(
size_t
i
=
0
;
i
<
128
;
++
i
)
{
std
::
vector
<
pd_real
>
sampleBuf
=
randomBuffer
(
64
);
paddle_matrix_set_row
(
mat
,
i
,
sampleBuf
.
data
());
}
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsSetV
alue
(
args
,
0
,
mat
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_set_v
alue
(
args
,
0
,
mat
));
paddle_matrix
val
=
paddle_matrix_create_none
();
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsGetV
alue
(
args
,
0
,
val
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_v
alue
(
args
,
0
,
val
));
for
(
size_t
i
=
0
;
i
<
128
;
++
i
)
{
pd_real
*
row1
;
...
...
@@ -63,29 +63,29 @@ TEST(CAPIArguments, value) {
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_ivector_destroy
(
ivec
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_matrix_destroy
(
val
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_matrix_destroy
(
mat
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsD
estroy
(
args
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_d
estroy
(
args
));
}
TEST
(
CAPIArguments
,
ids
)
{
PD_Arguments
args
=
PDArgsCreateN
one
();
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsR
esize
(
args
,
1
));
paddle_arguments
args
=
paddle_arguments_create_n
one
();
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_r
esize
(
args
,
1
));
paddle_ivector
ivec
;
int
array
[
3
]
=
{
1
,
2
,
3
};
ivec
=
paddle_ivector_create
(
array
,
3
,
true
,
false
);
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsSetI
ds
(
args
,
0
,
ivec
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_set_i
ds
(
args
,
0
,
ivec
));
paddle_ivector
val
=
paddle_ivector_create_none
();
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsGetI
ds
(
args
,
0
,
val
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_i
ds
(
args
,
0
,
val
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_ivector_destroy
(
ivec
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_ivector_destroy
(
val
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsD
estroy
(
args
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_d
estroy
(
args
));
}
template
<
typename
T1
,
typename
T2
>
void
testSequenceHelper
(
T1
setter
,
T2
getter
)
{
PD_Arguments
args
=
PDArgsCreateN
one
();
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsR
esize
(
args
,
1
));
paddle_arguments
args
=
paddle_arguments_create_n
one
();
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_r
esize
(
args
,
1
));
paddle_ivector
ivec
;
int
array
[
3
]
=
{
1
,
2
,
3
};
...
...
@@ -105,11 +105,12 @@ void testSequenceHelper(T1 setter, T2 getter) {
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_ivector_destroy
(
ivec
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_ivector_destroy
(
val
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsD
estroy
(
args
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_d
estroy
(
args
));
}
TEST
(
CAPIArguments
,
Sequence
)
{
testSequenceHelper
(
PDArgsSetSequenceStartPos
,
PDArgsGetSequenceStartPos
);
testSequenceHelper
(
PDArgsSetSubSequenceStartPos
,
PDArgsGetSubSequenceStartPos
);
testSequenceHelper
(
paddle_arguments_set_sequence_start_pos
,
paddle_arguments_sequence_start_pos
);
testSequenceHelper
(
paddle_arguments_set_sub_sequence_start_pos
,
paddle_arguments_sub_sequence_start_pos
);
}
paddle/capi/tests/test_GradientMachine.cpp
浏览文件 @
0afd5c30
...
...
@@ -55,10 +55,10 @@ TEST(GradientMachine, testPredict) {
PDGradientMachineCreateSharedParam
(
machine
,
&
buffer
[
0
],
(
int
)
buffer
.
size
(),
&
machineSlave
));
std
::
swap
(
machineSlave
,
machine
);
PD_Arguments
outArgs
=
PDArgsCreateN
one
();
paddle_arguments
outArgs
=
paddle_arguments_create_n
one
();
PD_Arguments
inArgs
=
PDArgsCreateN
one
();
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsR
esize
(
inArgs
,
1
));
paddle_arguments
inArgs
=
paddle_arguments_create_n
one
();
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_r
esize
(
inArgs
,
1
));
paddle_matrix
mat
=
paddle_matrix_create
(
1
,
100
,
false
);
static_assert
(
std
::
is_same
<
pd_real
,
paddle
::
real
>::
value
,
""
);
...
...
@@ -67,15 +67,15 @@ TEST(GradientMachine, testPredict) {
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_matrix_get_row
(
mat
,
0
,
&
rowPtr
));
memcpy
(
rowPtr
,
data
.
data
(),
data
.
size
()
*
sizeof
(
pd_real
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsSetV
alue
(
inArgs
,
0
,
mat
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_set_v
alue
(
inArgs
,
0
,
mat
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDGradientMachineForward
(
machine
,
inArgs
,
outArgs
,
false
));
uint64_t
sz
;
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsGetS
ize
(
outArgs
,
&
sz
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_s
ize
(
outArgs
,
&
sz
));
ASSERT_EQ
(
1UL
,
sz
);
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsGetV
alue
(
outArgs
,
0
,
mat
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_v
alue
(
outArgs
,
0
,
mat
));
std
::
vector
<
paddle
::
Argument
>
paddleInArgs
;
std
::
vector
<
paddle
::
Argument
>
paddleOutArgs
;
paddleInArgs
.
resize
(
1
);
...
...
@@ -97,8 +97,8 @@ TEST(GradientMachine, testPredict) {
}
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_matrix_destroy
(
mat
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsD
estroy
(
inArgs
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsD
estroy
(
outArgs
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_d
estroy
(
inArgs
));
ASSERT_EQ
(
kPD_NO_ERROR
,
paddle_arguments_d
estroy
(
outArgs
));
std
::
swap
(
machineSlave
,
machine
);
ASSERT_EQ
(
kPD_NO_ERROR
,
PDGradientMachineDestroy
(
machineSlave
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDGradientMachineDestroy
(
machine
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录