-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
304 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,61 @@ | ||
#include "PaddleCAPI.h" | ||
#include "PaddleCAPIPrivate.h" | ||
|
||
#define cast(v) paddle::capi::cast<paddle::capi::CArguments>(v) | ||
using paddle::capi::cast; | ||
|
||
#define castArg(v) cast<paddle::capi::CArguments>(v) | ||
#define castIVec(v) cast<paddle::capi::CIVector>(v) | ||
|
||
extern "C" { | ||
int PDArgsCreateNone(PD_Arguments* args) { | ||
auto ptr = new paddle::capi::CArguments(); | ||
*args = ptr; | ||
return PD_NO_ERROR; | ||
return kPD_NO_ERROR; | ||
} | ||
|
||
int PDArgsDestroy(PD_Arguments args) { | ||
if (args == nullptr) return PD_NULLPTR; | ||
delete cast(args); | ||
return PD_NO_ERROR; | ||
if (args == nullptr) return kPD_NULLPTR; | ||
delete castArg(args); | ||
return kPD_NO_ERROR; | ||
} | ||
|
||
int PDArgsGetSize(PD_Arguments args, uint64_t* size) { | ||
if (args == nullptr || size == nullptr) return PD_NULLPTR; | ||
*size = cast(args)->args.size(); | ||
return PD_NO_ERROR; | ||
if (args == nullptr || size == nullptr) return kPD_NULLPTR; | ||
*size = castArg(args)->args.size(); | ||
return kPD_NO_ERROR; | ||
} | ||
|
||
int PDArgsResize(PD_Arguments args, uint64_t size) { | ||
if (args == nullptr) return PD_NULLPTR; | ||
cast(args)->args.resize(size); | ||
return PD_NO_ERROR; | ||
if (args == nullptr) return kPD_NULLPTR; | ||
castArg(args)->args.resize(size); | ||
return kPD_NO_ERROR; | ||
} | ||
|
||
int PDArgsSetValue(PD_Arguments args, uint64_t ID, PD_Matrix mat) { | ||
if (args == nullptr || mat == nullptr) return PD_NULLPTR; | ||
if (args == nullptr || mat == nullptr) return kPD_NULLPTR; | ||
auto m = paddle::capi::cast<paddle::capi::CMatrix>(mat); | ||
if (m->mat == nullptr) return PD_NULLPTR; | ||
auto a = cast(args); | ||
if (ID >= a->args.size()) return PD_OUT_OF_RANGE; | ||
if (m->mat == nullptr) return kPD_NULLPTR; | ||
auto a = castArg(args); | ||
if (ID >= a->args.size()) return kPD_OUT_OF_RANGE; | ||
a->args[ID].value = m->mat; | ||
return PD_NO_ERROR; | ||
return kPD_NO_ERROR; | ||
} | ||
|
||
int PDArgsGetValue(PD_Arguments args, uint64_t ID, PD_Matrix mat) { | ||
if (args == nullptr || mat == nullptr) return PD_NULLPTR; | ||
if (args == nullptr || mat == nullptr) return kPD_NULLPTR; | ||
auto m = paddle::capi::cast<paddle::capi::CMatrix>(mat); | ||
auto a = cast(args); | ||
if (ID >= a->args.size()) return PD_OUT_OF_RANGE; | ||
auto a = castArg(args); | ||
if (ID >= a->args.size()) return kPD_OUT_OF_RANGE; | ||
m->mat = a->args[ID].value; | ||
return PD_NO_ERROR; | ||
return kPD_NO_ERROR; | ||
} | ||
|
||
int PDArgsGetIds(PD_Arguments args, uint64_t ID, PD_IVector ids) { | ||
if (args == nullptr || ids == nullptr) return kPD_NULLPTR; | ||
auto iv = castIVec(ids); | ||
auto a = castArg(args); | ||
if (ID >= a->args.size()) return kPD_OUT_OF_RANGE; | ||
iv->vec = a->args[ID].ids; | ||
return kPD_NO_ERROR; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.