PaddleCAPI.h 2.7 KB
Newer Older
Y
Yu Yang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

#ifndef PADDLECAPI_H_
#define PADDLECAPI_H_
Y
Yu Yang 已提交
17 18 19 20 21 22 23
#include <stdbool.h>
#include <stdint.h>
#include "config.h"
#ifdef __cplusplus
extern "C" {
#endif

Y
Yu Yang 已提交
24
typedef enum {
Y
Yu Yang 已提交
25 26 27 28 29
  kPD_NO_ERROR = 0,
  kPD_NULLPTR = 1,
  kPD_OUT_OF_RANGE = 2,
  kPD_PROTOBUF_ERROR = 3,
  kPD_UNDEFINED_ERROR = -1,
Y
Yu Yang 已提交
30
} PD_Error;
Y
Yu Yang 已提交
31

Y
Yu Yang 已提交
32
typedef void* PD_IVector;
Y
Yu Yang 已提交
33

Y
Yu Yang 已提交
34
int PDIVecCreateNone(PD_IVector* ivec);
Y
Yu Yang 已提交
35

Y
Yu Yang 已提交
36
int PDIVecDestroy(PD_IVector ivec);
Y
Yu Yang 已提交
37

Y
Yu Yang 已提交
38
int PDIVectorGet(PD_IVector ivec, int** buffer);
Y
Yu Yang 已提交
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

typedef void* PD_Matrix;

int PDMatCreate(PD_Matrix* mat, uint64_t height, uint64_t width, bool useGpu);

int PDMatDestroy(PD_Matrix mat);

int PDMatCopyToRow(PD_Matrix mat, uint64_t rowID, pd_real* rowArray);

int PDMatGetRow(PD_Matrix mat, uint64_t rowID, pd_real** rawRowBuffer);

int PDMatCreateNone(PD_Matrix* mat);

int PDMatGetShape(PD_Matrix mat, uint64_t* height, uint64_t* width);

typedef void* PD_Arguments;

int PDArgsCreateNone(PD_Arguments* args);

int PDArgsDestroy(PD_Arguments args);

int PDArgsGetSize(PD_Arguments args, uint64_t* size);

int PDArgsResize(PD_Arguments args, uint64_t size);

int PDArgsSetValue(PD_Arguments args, uint64_t ID, PD_Matrix mat);

int PDArgsGetValue(PD_Arguments args, uint64_t ID, PD_Matrix mat);

Y
Yu Yang 已提交
68 69
int PDArgsGetIds(PD_Arguments args, uint64_t ID, PD_IVector ids);

Y
Yu Yang 已提交
70 71 72 73 74 75
typedef void* PD_GradiemtMachine;

int PDGradientMachineCreateForPredict(PD_GradiemtMachine* machine,
                                      void* modelConfigProtobuf,
                                      int size);

Y
Yu Yang 已提交
76 77 78 79 80 81 82 83 84 85 86 87 88
int PDGradientMachineLoadParameterFromDisk(PD_GradiemtMachine machine,
                                           const char* path);

int PDGradientMachineForward(PD_GradiemtMachine machine,
                             PD_Arguments inArgs,
                             PD_Arguments outArgs,
                             bool isTrain);

int PDGradientMachineCreateSharedParam(PD_GradiemtMachine origin,
                                       void* modelConfigProtobuf,
                                       int size,
                                       PD_GradiemtMachine* slave);

Y
Yu Yang 已提交
89 90 91 92
int PDGradientMachineDestroy(PD_GradiemtMachine machine);

int PDInit(int argc, char** argv);

Y
Yu Yang 已提交
93 94 95
#ifdef __cplusplus
}
#endif
Y
Yu Yang 已提交
96 97

#endif  // PADDLECAPI_H_