-
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
[Eager] publish python c api for eager #37550
[Eager] publish python c api for eager #37550
Conversation
Thanks for your contribution! |
… eager_python_c_api
… eager_python_c_api
#include "paddle/pten/core/convert_utils.h" | ||
#include "paddle/pten/core/dense_tensor.h" | ||
#include "paddle/pten/include/core.h" | ||
#pragma GCC diagnostic ignored "-Wwrite-strings" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是因为CI编译会报编译错误:
eager_properties.cc:143:50: error: ISO C++ forbids converting a string constant to 'char*' [-Werror=write-strings]
cmake/flags.cmake
Outdated
@@ -141,6 +141,7 @@ set(COMMON_FLAGS | |||
-Wno-unused-parameter | |||
-Wno-unused-function | |||
-Wno-error=literal-suffix | |||
-Wno-error=missing-field-initializers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this, remove it if not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx!
#include "paddle/pten/include/core.h" | ||
|
||
namespace paddle { | ||
namespace pybind { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about change these to a new namespace, since we will have serval api as same as imperative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得还是这个namespace更合理,所有向python暴露的代码都放在pybind文件夹下,所有代码均用pybind namespace。
#include "pybind11/stl.h" | ||
|
||
namespace paddle { | ||
namespace pybind { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same namespace issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
PyObject* arr_; | ||
}; | ||
|
||
static inline PyObject* eager_api_numpy_to_tensor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why inline here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已删除
return res; | ||
} | ||
|
||
class EagerNumpyAllocation : public paddle::memory::allocation::Allocation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz rearrange all helper class and function to above and list all api implements below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx!
|
||
setattr(core.eager.EagerTensor, "__str__", __str__) | ||
|
||
# for method_name, method in (("__str__", __str__), ("__name__", "Tensor")): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx!
self.check_to_tesnsor_and_numpy('complex128') | ||
|
||
|
||
class EagerTensorPropertiesTestCase(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add test for Grad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
翔实地描述一下。 |
* refine a test case, test=develop * publish python c api for eager, test=develop * revert modify about test_allclose_layer.py, test=develop * refine, test=develop * refine, test=develop * refine, test=develop * refine, test=develop * refine, test=develop * refine, test=develop * delete numpy includes, use pybind11 numpy.h, test=develop * refine, test=develop * refine, test=develop * refine, test=develop * suport eager error msg, and add grad test case, test=develop * refine, test=develop * refine, test=develop
PR types
New features
PR changes
Others
Describe
本PR是Eager(动态图重构项目)从C++端向Python端暴露接口的首个PR,主要提交内容如下: