-
Notifications
You must be signed in to change notification settings - Fork 1
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
Convert most of np.zeros to HPy #12
base: hpy
Are you sure you want to change the base?
Conversation
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.
Looks good overall. I would prefer the implementation to be complete before merging though. How hard would it be to support like
?
char const *message) | ||
{ | ||
HPyContext *ctx = npy_get_context(); | ||
return hpy_string_converter_helper(ctx, HPy_FromPyObject(ctx, object), out, str_func, name, message); |
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.
The HPy_FromPyObject(ctx, object) handle needs to be closed
@@ -2988,32 +2988,48 @@ PyArray_CheckAxis(PyArrayObject *arr, int *axis, int flags) | |||
NPY_NO_EXPORT PyObject * | |||
PyArray_Zeros(int nd, npy_intp const *dims, PyArray_Descr *type, int is_f_order) | |||
{ | |||
PyArrayObject *ret; | |||
HPyContext *ctx = npy_get_context(); | |||
HPy_AsPyObject(ctx, HPyArray_Zeros(ctx, nd, dims, type, is_f_order)); |
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.
this handle needs to be closed
ret = (PyArrayObject *)PyArray_NewFromDescr_int( | ||
&PyArray_Type, type, | ||
ret = HPyArray_NewFromDescr_int( | ||
ctx, HPy_FromPyObject(ctx, (PyObject *)&PyArray_Type), type, |
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.
handle leak
return deferred; | ||
if (!HPy_IsNull(h_typecode)) { | ||
// HPY TODO: needs PyArray_Descr porting | ||
PyObject* py_typecode = HPy_AsPyObject(ctx, h_typecode); |
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.
h_typecode should be closed here, I think
} | ||
} | ||
if (HPyArray_OrderConverter(ctx, h_order, &order) != NPY_SUCCEED) { |
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.
h_order needs to be closed
goto fail; | ||
} | ||
|
||
if (!HPy_IsNull(h_like)) { |
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.
h_like needs to be closed
@@ -354,6 +354,9 @@ | |||
'PyDataMem_SetHandler': (304,), | |||
'PyDataMem_GetHandler': (305,), | |||
# End 1.21 API | |||
|
|||
# HPy API: | |||
'HPyArray_Zeros': (307,), |
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.
I think we shouldn't add HPy functions to the API, but rather, eventually, have a separate function table for the HPy API.
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.
Yes, agreed. I want to play with this a bit to move forward quicker: we'd like to prototype integration with Matplotlib port too. However, new table will be the way to go longer term.
PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames) | ||
HPyDef_METH(array_zeros, "zeros", array_zeros_impl, HPyFunc_KEYWORDS) | ||
static HPy | ||
array_zeros_impl(HPyContext *ctx, HPy NPY_UNUSED(ignored), HPy *args, HPy_ssize_t nargs, HPy kw) |
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.
Hmm, we should probably have const HPy *args
in the signature, to match CPython...
{ | ||
HPy_ssize_t nd; | ||
npy_intp i; | ||
HPy op, err; |
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.
err
is unused
Yes, I'll take a look. I am also trying to port |
Merge in ~STEPAN.SINDELAR_ORACLE.COM/numpy-hpy from fa/hpy_global to labs-hpy-port * commit '4f2d3de9229a9c7d2ae6a978cda04ab2262209a8': Use HPyGlobal for global type vars
This PR seems to have been quiet for a while. Are there any updates on the numpy hpy project? |
Hi @WilliamGazeley, yes, there are updates. In fact, we are actively working on that. It's just that this PR was basically just the initial effort. In order to see our full work, checkout branches graal-team/hpy and graal-team/hpy-0.0.5. Branch We also updated the I encourage you and everyone else to try it out and I'm happy to help in case of problems. |
No description provided.