numba-dpex
numba-dpex copied to clipboard
Fixed ref-counting of Python object temporaries in unboxing code
Ref-count of arrayobj was not decremented after use in case dpnp.ndarray object was being processed.
Change the flow of managing lifetime of Python temporaries in unboxing code.
This PR replaces use of obj in NRT structure with use of arrayobj, and shifts ref-count manipulation of obj into PyUSMNdArray_ARRAYOBJ.
- [x] Have you provided a meaningful PR description?
- [ ] Have you added a test, reproducer or referred to an issue with a reproducer?
- [ ] Have you tested your changes locally for CPU and GPU devices?
- [ ] Have you made sure that new changes do not introduce compiler warnings?
- [ ] If this PR is a work in progress, are you filing the PR as a draft?
Check locally with unitrace - memory leak that @adarshyoga was reporting is resolved with this PR
@oleksandr-pavlyk there are some compile time warnings after these changes.
The memory leak that was occurring with pairwise distance workload is resolved with this fix. Thanks, @oleksandr-pavlyk .
@oleksandr-pavlyk there are some compile time warnings after these changes.
Yes, I pushed a fix for them, by casting PyUSMArrayObject * pointer to PyObject * pointer, which is always safe to do.