Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
5a9987a3
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看板
提交
5a9987a3
编写于
3月 09, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bugs in lizhao's code
上级
d34322e1
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
24 addition
and
15 deletion
+24
-15
paddle/capi/Arguments.cpp
paddle/capi/Arguments.cpp
+5
-9
paddle/capi/Vector.cpp
paddle/capi/Vector.cpp
+0
-3
paddle/capi/tests/test_Arguments.cpp
paddle/capi/tests/test_Arguments.cpp
+19
-3
未找到文件。
paddle/capi/Arguments.cpp
浏览文件 @
5a9987a3
...
...
@@ -87,7 +87,6 @@ int PDArgsSetIds(PD_Arguments args, uint64_t ID, PD_IVector ids) {
int
PDArgsSetSequenceStartPos
(
PD_Arguments
args
,
uint64_t
ID
,
PD_IVector
seqPos
)
{
//! TODO(lizhao): Complete this method.
if
(
args
==
nullptr
||
seqPos
==
nullptr
)
return
kPD_NULLPTR
;
auto
iv
=
paddle
::
capi
::
cast
<
paddle
::
capi
::
CIVector
>
(
seqPos
);
if
(
iv
->
vec
==
nullptr
)
return
kPD_NULLPTR
;
...
...
@@ -101,13 +100,12 @@ int PDArgsSetSequenceStartPos(PD_Arguments args,
int
PDArgsSetSubSequenceStartPos
(
PD_Arguments
args
,
uint64_t
ID
,
PD_IVector
subSeqPos
)
{
//! TODO(lizhao): Complete this method.
if
(
args
==
nullptr
||
subSeqPos
==
nullptr
)
return
kPD_NULLPTR
;
auto
iv
=
paddle
::
capi
::
cast
<
paddle
::
capi
::
CIVector
>
(
subSeqPos
);
if
(
iv
->
vec
==
nullptr
)
return
kPD_NULLPTR
;
auto
a
=
castArg
(
args
);
if
(
ID
>=
a
->
args
.
size
())
return
kPD_OUT_OF_RANGE
;
a
->
args
[
ID
].
sequenceStartPositions
=
a
->
args
[
ID
].
s
ubS
equenceStartPositions
=
std
::
make_shared
<
paddle
::
ICpuGpuVector
>
(
iv
->
vec
);
return
kPD_NO_ERROR
;
}
...
...
@@ -115,26 +113,24 @@ int PDArgsSetSubSequenceStartPos(PD_Arguments args,
int
PDArgsGetSequenceStartPos
(
PD_Arguments
args
,
uint64_t
ID
,
PD_IVector
seqPos
)
{
//! TODO(lizhao): Complete this method.
if
(
args
==
nullptr
||
seqPos
==
nullptr
)
return
kPD_NULLPTR
;
auto
iv
=
castIVec
(
seqPos
);
auto
a
=
castArg
(
args
);
if
(
ID
>=
a
->
args
.
size
())
return
kPD_OUT_OF_RANGE
;
std
::
make_shared
<
paddle
::
ICpuGpuVector
>
(
iv
->
vec
)
=
a
->
args
[
ID
].
sequenceStartPositions
;
paddle
::
Argument
&
arg
=
a
->
args
[
ID
];
iv
->
vec
=
arg
.
sequenceStartPositions
->
getMutableVector
(
false
)
;
return
kPD_NO_ERROR
;
}
int
PDArgsGetSubSequenceStartPos
(
PD_Arguments
args
,
uint64_t
ID
,
PD_IVector
subSeqPos
)
{
//! TODO(lizhao): Complete this method.
if
(
args
==
nullptr
||
subSeqPos
==
nullptr
)
return
kPD_NULLPTR
;
auto
iv
=
castIVec
(
subSeqPos
);
auto
a
=
castArg
(
args
);
if
(
ID
>=
a
->
args
.
size
())
return
kPD_OUT_OF_RANGE
;
std
::
make_shared
<
paddle
::
ICpuGpuVector
>
(
iv
->
vec
)
=
a
->
args
[
ID
].
sequenceStartPositions
;
paddle
::
Argument
&
arg
=
a
->
args
[
ID
];
iv
->
vec
=
arg
.
subSequenceStartPositions
->
getMutableVector
(
false
)
;
return
kPD_NO_ERROR
;
}
}
paddle/capi/Vector.cpp
浏览文件 @
5a9987a3
...
...
@@ -27,7 +27,6 @@ int PDIVecCreateNone(PD_IVector* ivec) {
}
int
PDIVectorCreate
(
PD_IVector
*
ivec
,
int
*
array
,
uint64_t
size
,
bool
copy
)
{
//! TODO(lizhao): Complete this method.
if
(
ivec
==
nullptr
)
return
kPD_NULLPTR
;
auto
ptr
=
new
paddle
::
capi
::
CIVector
();
if
(
copy
)
{
...
...
@@ -55,7 +54,6 @@ int PDIVectorGet(PD_IVector ivec, int** buffer) {
}
int
PDIVectorResize
(
PD_IVector
ivec
,
uint64_t
size
)
{
//! TODO(lizhao): Complete this method.
if
(
ivec
==
nullptr
)
return
kPD_NULLPTR
;
auto
v
=
cast
<
paddle
::
capi
::
CIVector
>
(
ivec
);
if
(
v
->
vec
==
nullptr
)
return
kPD_NULLPTR
;
...
...
@@ -64,7 +62,6 @@ int PDIVectorResize(PD_IVector ivec, uint64_t size) {
}
int
PDIVectorGetSize
(
PD_IVector
ivec
,
uint64_t
*
size
)
{
//! TODO(lizhao): Complete this method.
if
(
ivec
==
nullptr
)
return
kPD_NULLPTR
;
auto
v
=
cast
<
paddle
::
capi
::
CIVector
>
(
ivec
);
if
(
v
->
vec
==
nullptr
)
return
kPD_NULLPTR
;
...
...
paddle/capi/tests/test_Arguments.cpp
浏览文件 @
5a9987a3
...
...
@@ -89,7 +89,8 @@ TEST(CAPIArguments, ids) {
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsDestroy
(
args
));
}
TEST
(
CAPIArguments
,
Sequence
)
{
template
<
typename
T1
,
typename
T2
>
void
testSequenceHelper
(
T1
setter
,
T2
getter
)
{
PD_Arguments
args
;
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsCreateNone
(
&
args
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsResize
(
args
,
1
));
...
...
@@ -97,12 +98,27 @@ TEST(CAPIArguments, Sequence) {
PD_IVector
ivec
;
int
array
[
3
]
=
{
1
,
2
,
3
};
ASSERT_EQ
(
kPD_NO_ERROR
,
PDIVectorCreate
(
&
ivec
,
array
,
3
,
true
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsSetSequenceStartPos
(
args
,
0
,
ivec
));
ASSERT_EQ
(
kPD_NO_ERROR
,
setter
(
args
,
0
,
ivec
));
PD_IVector
val
;
ASSERT_EQ
(
kPD_NO_ERROR
,
PDIVecCreateNone
(
&
val
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsGetSequenceStartPos
(
args
,
0
,
val
));
ASSERT_EQ
(
kPD_NO_ERROR
,
getter
(
args
,
0
,
val
));
uint64_t
size
;
ASSERT_EQ
(
kPD_NO_ERROR
,
PDIVectorGetSize
(
val
,
&
size
));
int
*
rawBuf
;
ASSERT_EQ
(
kPD_NO_ERROR
,
PDIVectorGet
(
val
,
&
rawBuf
));
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
ASSERT_EQ
(
array
[
i
],
rawBuf
[
i
]);
}
ASSERT_EQ
(
kPD_NO_ERROR
,
PDIVecDestroy
(
ivec
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDIVecDestroy
(
val
));
ASSERT_EQ
(
kPD_NO_ERROR
,
PDArgsDestroy
(
args
));
}
TEST
(
CAPIArguments
,
Sequence
)
{
testSequenceHelper
(
PDArgsSetSequenceStartPos
,
PDArgsGetSequenceStartPos
);
testSequenceHelper
(
PDArgsSetSubSequenceStartPos
,
PDArgsGetSubSequenceStartPos
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录