@@ -14,220 +14,19 @@ limitations under the License. */
1414
1515#ifndef PADDLECAPI_H_
1616#define PADDLECAPI_H_
17- #include <stdbool.h>
18- #include <stdint.h>
19- #include "config.h"
20- #include "error.h"
21- #include "matrix.h"
22- #include "vector.h"
23-
24- #ifdef __cplusplus
25- extern "C" {
26- #endif
2717
2818/**
2919 * Paddle C API. It will replace SWIG as Multiple Language API for model
3020 * training & inference. Currently it is only used in model infernece.
3121 *
3222 * NOTE: This is an experimental API, it could be changed.
3323 */
34-
35- /**
36- * Arguments functions. Each argument means layer output. Arguments means a
37- * array of arguemnt.
38- */
39- typedef void * paddle_arguments ;
40-
41- /**
42- * @brief paddle_arguments_create_none Create a array of arguments, which size
43- * is zero.
44- * @return Arguemnts
45- */
46- PD_API paddle_arguments paddle_arguments_create_none ();
47-
48- /**
49- * @brief paddle_arguments_destroy Destroy the arguments
50- * @param args arguments to destroy
51- * @return paddle_error
52- */
53- PD_API paddle_error paddle_arguments_destroy (paddle_arguments args );
54-
55- /**
56- * @brief PDArgsGetSize Get size of arguments array
57- * @param [in] args arguments array
58- * @param [out] size array size
59- * @return paddle_error
60- */
61- PD_API paddle_error paddle_arguments_size (paddle_arguments args ,
62- uint64_t * size );
63-
64- /**
65- * @brief PDArgsResize Resize a arguments array.
66- * @param args arguments array.
67- * @param size target size of array
68- * @return paddle_error
69- */
70- PD_API paddle_error paddle_arguments_resize (paddle_arguments args ,
71- uint64_t size );
72-
73- /**
74- * @brief PDArgsSetValue Set value matrix of one argument in array, which index
75- * is `ID`.
76- * @param args arguments array
77- * @param ID array index
78- * @param mat matrix pointer
79- * @return paddle_error
80- */
81- PD_API paddle_error paddle_arguments_set_value (paddle_arguments args ,
82- uint64_t ID ,
83- paddle_matrix mat );
84-
85- /**
86- * @brief PDArgsGetValue Get value matrix of one argument in array, which index
87- * is `ID`.
88- * @param [in] args arguments array
89- * @param [in] ID array index
90- * @param [out] mat matrix pointer
91- * @return paddle_error
92- */
93- PD_API paddle_error paddle_arguments_value (paddle_arguments args ,
94- uint64_t ID ,
95- paddle_matrix mat );
96-
97- /**
98- * @brief PDArgsGetIds Get the integer vector of one argument in array, which
99- * index is `ID`.
100- * @param args arguments array
101- * @param ID array index
102- * @param ids integer vector pointer
103- * @return paddle_error
104- */
105- PD_API paddle_error paddle_arguments_ids (paddle_arguments args ,
106- uint64_t ID ,
107- paddle_ivector ids );
108-
109- /**
110- * @brief PDArgsSetIds Set the integer vector of one argument in array, which
111- * index is `ID`.
112- * @param [in] args arguments array
113- * @param [in] ID array index
114- * @param [out] ids integer vector pointer
115- * @return paddle_error
116- */
117- PD_API paddle_error paddle_arguments_set_ids (paddle_arguments args ,
118- uint64_t ID ,
119- paddle_ivector ids );
120-
121- /**
122- * @brief PDArgsSetSequenceStartPos Set sequence start position vector of one
123- * argument in array, which index is `ID`.
124- * @param args arguments array
125- * @param ID array index
126- * @param seqPos sequence position array.
127- * @return paddle_error
128- */
129- PD_API paddle_error paddle_arguments_set_sequence_start_pos (
130- paddle_arguments args , uint64_t ID , paddle_ivector seqPos );
131- /**
132- * @brief PDArgsGetSequenceStartPos Get sequence start position vector of one
133- * argument in array, which index is `ID`.
134- * @param [in] args arguments array
135- * @param [in] ID array index
136- * @param [out] seqPos sequence position array
137- * @return paddle_error
138- */
139- PD_API paddle_error paddle_arguments_sequence_start_pos (paddle_arguments args ,
140- uint64_t ID ,
141- paddle_ivector seqPos );
142-
143- /**
144- * @brief PDArgsSetSubSequenceStartPos Set sub-sequence start position vector of
145- * one argument in array, which index is `ID`.
146- * @param args arguments array
147- * @param ID array index
148- * @param subSeqPos sub-sequence start position array.
149- * @return paddle_error
150- */
151- PD_API paddle_error paddle_arguments_set_sub_sequence_start_pos (
152- paddle_arguments args , uint64_t ID , paddle_ivector subSeqPos );
153-
154- /**
155- * @brief PDArgsGetSubSequenceStartPos Get sub-sequence start position vector of
156- * one argument in array, which index is `ID`.
157- * @param args arguments array
158- * @param ID array index
159- * @param subSeqPos sub-sequence start position array
160- * @return paddle_error
161- */
162- PD_API paddle_error paddle_arguments_sub_sequence_start_pos (
163- paddle_arguments args , uint64_t ID , paddle_ivector subSeqPos );
164- /**
165- * @brief GradientMachine means a neural network.
166- */
167- typedef void * PD_GradientMachine ;
168-
169- /**
170- * @brief PDGradientMachineCreateForPredict Create a gradient machine used for
171- * model inference.
172- * @param [out] machine that used for model inference.
173- * @param [in] modelConfigProtobuf
174- * @param [in] size
175- * @return paddle_error
176- */
177- PD_API paddle_error PDGradientMachineCreateForPredict (
178- PD_GradientMachine * machine , void * modelConfigProtobuf , int size );
179-
180- /**
181- * @brief PDGradientMachineLoadParameterFromDisk Load parameter from disk.
182- * @param machine Gradient Machine.
183- * @param path local directory path.
184- * @return paddle_error
185- */
186- PD_API paddle_error PDGradientMachineLoadParameterFromDisk (
187- PD_GradientMachine machine , const char * path );
188-
189- /**
190- * @brief PDGradientMachineForward Forward a gradient machine
191- * @param machine Gradient machine
192- * @param inArgs input arguments
193- * @param outArgs output arguments
194- * @param isTrain is train or not
195- * @return paddle_error
196- */
197- PD_API paddle_error PDGradientMachineForward (PD_GradientMachine machine ,
198- paddle_arguments inArgs ,
199- paddle_arguments outArgs ,
200- bool isTrain );
201-
202- /**
203- * @brief PDGradientMachineCreateSharedParam Create a gradient machine, which
204- * parameters are shared from another gradient machine.
205- * @param [in] origin gradient machine
206- * @param [in] modelConfigProtobuf model config protobuf
207- * @param [in] size of model config buffer.
208- * @param [out] slave gradient machine, the output value.
209- * @return paddle_error
210- */
211- PD_API paddle_error
212- PDGradientMachineCreateSharedParam (PD_GradientMachine origin ,
213- void * modelConfigProtobuf ,
214- int size ,
215- PD_GradientMachine * slave );
216-
217- /**
218- * @brief PDGradientMachineDestroy Destroy a gradient machine
219- * @param machine that need to destroy
220- * @return paddle_error
221- */
222- PD_API paddle_error PDGradientMachineDestroy (PD_GradientMachine machine );
223-
224- /**
225- * Initialize Paddle.
226- */
227- PD_API paddle_error PDInit (int argc , char * * argv );
228-
229- #ifdef __cplusplus
230- }
231- #endif
24+ #include "arguments.h"
25+ #include "config.h"
26+ #include "error.h"
27+ #include "gradient_machine.h"
28+ #include "main.h"
29+ #include "matrix.h"
30+ #include "vector.h"
23231
23332#endif // PADDLECAPI_H_
0 commit comments