From 97c64254568b4c68ceb778c1721e36b43e2ad5d1 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Tue, 7 Mar 2017 16:16:46 +0800 Subject: [PATCH] Add some more interfaces --- paddle/capi/Arguments.cpp | 33 +++++++++++++++++++++++++++++++++ paddle/capi/PaddleCAPI.h | 30 ++++++++++++++++++++++++++++++ paddle/capi/Vector.cpp | 13 +++++++++---- 3 files changed, 72 insertions(+), 4 deletions(-) diff --git a/paddle/capi/Arguments.cpp b/paddle/capi/Arguments.cpp index 60bdea15a..678a80ac3 100644 --- a/paddle/capi/Arguments.cpp +++ b/paddle/capi/Arguments.cpp @@ -72,4 +72,37 @@ int PDArgsGetIds(PD_Arguments args, uint64_t ID, PD_IVector ids) { iv->vec = a->args[ID].ids; return kPD_NO_ERROR; } + +int PDArgsSetIds(PD_Arguments args, uint64_t ID, PD_IVector ids) { + //! TODO(lizhao): Complete this method. + return kPD_UNDEFINED_ERROR; +} + +int PDArgsSetSequenceStartPos(PD_Arguments args, + uint64_t ID, + PD_IVector seqPos) { + //! TODO(lizhao): Complete this method. + return kPD_UNDEFINED_ERROR; +} + +int PDArgsSetSubSequenceStartPos(PD_Arguments args, + uint64_t ID, + PD_IVector subSeqPos) { + //! TODO(lizhao): Complete this method. + return kPD_UNDEFINED_ERROR; +} + +int PDArgsGetSequenceStartPos(PD_Arguments args, + uint64_t ID, + PD_IVector seqPos) { + //! TODO(lizhao): Complete this method. + return kPD_UNDEFINED_ERROR; +} + +int PDArgsGetSubSequenceStartPos(PD_Arguments args, + uint64_t ID, + PD_IVector subSeqPos) { + //! TODO(lizhao): Complete this method. + return kPD_UNDEFINED_ERROR; +} } diff --git a/paddle/capi/PaddleCAPI.h b/paddle/capi/PaddleCAPI.h index 4819be344..6eea60ef7 100644 --- a/paddle/capi/PaddleCAPI.h +++ b/paddle/capi/PaddleCAPI.h @@ -51,6 +51,19 @@ typedef void* PD_IVector; PD_API int PDIVecCreateNone(PD_IVector* ivec); +/** + * @brief PDIVectorCreate create a paddle int vector + * @param [out] ivec: output int vector. + * @param [in] array: input array. + * @param [in] size: input array size. + * @param [in] copy: memory copy or just use same memory. True if copy. + * @return PD_Error + */ +PD_API int PDIVectorCreate(PD_IVector* ivec, + int* array, + uint64_t size, + bool copy); + PD_API int PDIVecDestroy(PD_IVector ivec); PD_API int PDIVectorGet(PD_IVector ivec, int** buffer); @@ -99,6 +112,23 @@ PD_API int PDArgsGetValue(PD_Arguments args, uint64_t ID, PD_Matrix mat); PD_API int PDArgsGetIds(PD_Arguments args, uint64_t ID, PD_IVector ids); +PD_API int PDArgsSetIds(PD_Arguments args, uint64_t ID, PD_IVector ids); + +PD_API int PDArgsSetSequenceStartPos(PD_Arguments args, + uint64_t ID, + PD_IVector seqPos); + +PD_API int PDArgsGetSequenceStartPos(PD_Arguments args, + uint64_t ID, + PD_IVector seqPos); + +PD_API int PDArgsSetSubSequenceStartPos(PD_Arguments args, + uint64_t ID, + PD_IVector subSeqPos); + +PD_API int PDArgsGetSubSequenceStartPos(PD_Arguments args, + uint64_t ID, + PD_IVector subSeqPos); /** * @brief GradientMachine means a neural network. */ diff --git a/paddle/capi/Vector.cpp b/paddle/capi/Vector.cpp index eb3501fb5..a2e6f3507 100644 --- a/paddle/capi/Vector.cpp +++ b/paddle/capi/Vector.cpp @@ -26,6 +26,11 @@ int PDIVecCreateNone(PD_IVector* ivec) { return kPD_NO_ERROR; } +int PDIVectorCreate(PD_IVector* ivec, int* array, uint64_t size, bool copy) { + //! TODO(lizhao): Complete this method. + return kPD_UNDEFINED_ERROR; +} + int PDIVecDestroy(PD_IVector ivec) { if (ivec == nullptr) return kPD_NULLPTR; delete cast(ivec); @@ -41,12 +46,12 @@ int PDIVectorGet(PD_IVector ivec, int** buffer) { } int PDIVectorResize(PD_IVector ivec, uint64_t size) { - // TODO(lizhao): Complete this method. - return 0; + //! TODO(lizhao): Complete this method. + return kPD_UNDEFINED_ERROR; } int PDIVectorGetSize(PD_IVector ivec, uint64_t* size) { - // TODO(lizhao): Complete this method. - return 0; + //! TODO(lizhao): Complete this method. + return kPD_UNDEFINED_ERROR; } } -- GitLab