-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paddle Multiple Language API/SDK #849
Comments
关于API接口封装,有个很重要的问题,就是异常情况如何处理。 对于这个问题,比较主流的方法是返回一个错误状态(bool/int),并且带上错误信息(string)。封装的语言需要主动对api调用结果进行检查并提取错误信息。 有两个问题需要确定:
|
1、强烈不建议使用Exception,除非有特殊的理由。原因如下
2、直接把error结构体作为返回值应该就可以了吧? typedef struct tagError {
const char* msg;
int32_t code;
} Error;
Error api.forward(inArg1, inArg2, &outArg); |
我也觉得用exception不太合适,所以这点可以确定了,后面的status差不多就是这个样子了 |
for the Possible Python API Demos above,
is mainly realized in python with the wrapper of c_api, for example there should be some thing like
what about parameter server, what is the best way to wrap ps |
Developing Roadmap #959 |
Use PyBind11 for refactoring |
Paddle is a standalone application now, which cannot customize training progress conveniently. The current API of Paddle only support the model inference.
We consider to rewrite current API now and make Paddle as a standard Python library and could easily port to another programming language.
There are several agreements and todos for this feature.
Using standard C99 API instead of SWIG
SWIG API is excellent for Python binding, but it seems not work smoothly for other languages, such as Julia, Go. Make Paddle integrated to other systems easily is an essential requirement for Paddle API.
Only expose GradientMachine.
The GradientMachine is an abstraction class of neural network, which can perform forward/backward on multiple local devices(CPU cores, GPU cards). In the cluster environment, we should provide the same abstraction with some additional configurations about node count, etc.
The GradientMachine will always act as a single thread program. We won't provide API about how to sending data from one GPU to another, how to use many CPUs, etc. We think that API is too low-level, and is not necessary to be exposed.
And there are few rules about GradientMachine-API:
Wrap C-API into a standard Python library.
Python is used widely in neural network domains. We will write a standard Python library as the first language binding.
However, Python library can be considered as a demo only; other language bindings are welcome to contribute.
Possible Python API Demos
Here is a possible Python usage in current design. It would be flux.
Tasks
Step 1. Single Machine Development.
To implement this feature, several tasks should be done.
Remove all global variables in Paddle. Most of them are command line flags.
Find a way not to core-dump when
log(FATAL)
orCHECK
error.Expose C-API about
Python Library [should be parallel with C-API exposion]
* exchange data with NumPy.
Step 2. Cluster development.
TBD
The text was updated successfully, but these errors were encountered: