@@ -21,31 +21,27 @@ using paddle::capi::cast;
21
21
#define castIVec (v ) cast<paddle::capi::CIVector>(v)
22
22
23
23
extern " C" {
24
- int PDArgsCreateNone (PD_Arguments* args) {
25
- auto ptr = new paddle::capi::CArguments ();
26
- *args = ptr;
27
- return kPD_NO_ERROR ;
28
- }
24
+ PD_Arguments PDArgsCreateNone () { return new paddle::capi::CArguments (); }
29
25
30
- int PDArgsDestroy (PD_Arguments args) {
26
+ PD_Error PDArgsDestroy (PD_Arguments args) {
31
27
if (args == nullptr ) return kPD_NULLPTR ;
32
28
delete castArg (args);
33
29
return kPD_NO_ERROR ;
34
30
}
35
31
36
- int PDArgsGetSize (PD_Arguments args, uint64_t * size) {
32
+ PD_Error PDArgsGetSize (PD_Arguments args, uint64_t * size) {
37
33
if (args == nullptr || size == nullptr ) return kPD_NULLPTR ;
38
34
*size = castArg (args)->args .size ();
39
35
return kPD_NO_ERROR ;
40
36
}
41
37
42
- int PDArgsResize (PD_Arguments args, uint64_t size) {
38
+ PD_Error PDArgsResize (PD_Arguments args, uint64_t size) {
43
39
if (args == nullptr ) return kPD_NULLPTR ;
44
40
castArg (args)->args .resize (size);
45
41
return kPD_NO_ERROR ;
46
42
}
47
43
48
- int PDArgsSetValue (PD_Arguments args, uint64_t ID, PD_Matrix mat) {
44
+ PD_Error PDArgsSetValue (PD_Arguments args, uint64_t ID, PD_Matrix mat) {
49
45
if (args == nullptr || mat == nullptr ) return kPD_NULLPTR ;
50
46
auto m = paddle::capi::cast<paddle::capi::CMatrix>(mat);
51
47
if (m->mat == nullptr ) return kPD_NULLPTR ;
@@ -55,7 +51,7 @@ int PDArgsSetValue(PD_Arguments args, uint64_t ID, PD_Matrix mat) {
55
51
return kPD_NO_ERROR ;
56
52
}
57
53
58
- int PDArgsGetValue (PD_Arguments args, uint64_t ID, PD_Matrix mat) {
54
+ PD_Error PDArgsGetValue (PD_Arguments args, uint64_t ID, PD_Matrix mat) {
59
55
if (args == nullptr || mat == nullptr ) return kPD_NULLPTR ;
60
56
auto m = paddle::capi::cast<paddle::capi::CMatrix>(mat);
61
57
auto a = castArg (args);
@@ -64,7 +60,7 @@ int PDArgsGetValue(PD_Arguments args, uint64_t ID, PD_Matrix mat) {
64
60
return kPD_NO_ERROR ;
65
61
}
66
62
67
- int PDArgsGetIds (PD_Arguments args, uint64_t ID, PD_IVector ids) {
63
+ PD_Error PDArgsGetIds (PD_Arguments args, uint64_t ID, PD_IVector ids) {
68
64
if (args == nullptr || ids == nullptr ) return kPD_NULLPTR ;
69
65
auto iv = castIVec (ids);
70
66
auto a = castArg (args);
@@ -73,7 +69,7 @@ int PDArgsGetIds(PD_Arguments args, uint64_t ID, PD_IVector ids) {
73
69
return kPD_NO_ERROR ;
74
70
}
75
71
76
- int PDArgsSetIds (PD_Arguments args, uint64_t ID, PD_IVector ids) {
72
+ PD_Error PDArgsSetIds (PD_Arguments args, uint64_t ID, PD_IVector ids) {
77
73
// ! TODO(lizhao): Complete this method.
78
74
if (args == nullptr || ids == nullptr ) return kPD_NULLPTR ;
79
75
auto iv = paddle::capi::cast<paddle::capi::CIVector>(ids);
@@ -84,9 +80,9 @@ int PDArgsSetIds(PD_Arguments args, uint64_t ID, PD_IVector ids) {
84
80
return kPD_NO_ERROR ;
85
81
}
86
82
87
- int PDArgsSetSequenceStartPos (PD_Arguments args,
88
- uint64_t ID,
89
- PD_IVector seqPos) {
83
+ PD_Error PDArgsSetSequenceStartPos (PD_Arguments args,
84
+ uint64_t ID,
85
+ PD_IVector seqPos) {
90
86
if (args == nullptr || seqPos == nullptr ) return kPD_NULLPTR ;
91
87
auto iv = paddle::capi::cast<paddle::capi::CIVector>(seqPos);
92
88
if (iv->vec == nullptr ) return kPD_NULLPTR ;
@@ -97,9 +93,9 @@ int PDArgsSetSequenceStartPos(PD_Arguments args,
97
93
return kPD_NO_ERROR ;
98
94
}
99
95
100
- int PDArgsSetSubSequenceStartPos (PD_Arguments args,
101
- uint64_t ID,
102
- PD_IVector subSeqPos) {
96
+ PD_Error PDArgsSetSubSequenceStartPos (PD_Arguments args,
97
+ uint64_t ID,
98
+ PD_IVector subSeqPos) {
103
99
if (args == nullptr || subSeqPos == nullptr ) return kPD_NULLPTR ;
104
100
auto iv = paddle::capi::cast<paddle::capi::CIVector>(subSeqPos);
105
101
if (iv->vec == nullptr ) return kPD_NULLPTR ;
@@ -110,9 +106,9 @@ int PDArgsSetSubSequenceStartPos(PD_Arguments args,
110
106
return kPD_NO_ERROR ;
111
107
}
112
108
113
- int PDArgsGetSequenceStartPos (PD_Arguments args,
114
- uint64_t ID,
115
- PD_IVector seqPos) {
109
+ PD_Error PDArgsGetSequenceStartPos (PD_Arguments args,
110
+ uint64_t ID,
111
+ PD_IVector seqPos) {
116
112
if (args == nullptr || seqPos == nullptr ) return kPD_NULLPTR ;
117
113
auto iv = castIVec (seqPos);
118
114
auto a = castArg (args);
@@ -122,9 +118,9 @@ int PDArgsGetSequenceStartPos(PD_Arguments args,
122
118
return kPD_NO_ERROR ;
123
119
}
124
120
125
- int PDArgsGetSubSequenceStartPos (PD_Arguments args,
126
- uint64_t ID,
127
- PD_IVector subSeqPos) {
121
+ PD_Error PDArgsGetSubSequenceStartPos (PD_Arguments args,
122
+ uint64_t ID,
123
+ PD_IVector subSeqPos) {
128
124
if (args == nullptr || subSeqPos == nullptr ) return kPD_NULLPTR ;
129
125
auto iv = castIVec (subSeqPos);
130
126
auto a = castArg (args);
0 commit comments