Hey! This is the fifth blog-post in my series of GSoC experience. Not much productive work has been done in last two weeks. The reason behind this being, I was not feeling well in the week before last week.
And then, since I was just fixing minor comments in the open PRs, I took this chance to get into internals of CuPy and learn something new, as this will surely help me and the community in the future by contributing to core parts of CuPy.
Seventh week
I just studied and tried to understand how functions are implemented internally in CuPy. I took a look at cupy.min
, cupy.argmin
, cupy.sum
, cupy.isclose
, cupy.nansum
, cupy.nanprod
, cupy.mean
and several more and their corresponding NumPy implementations.
I found these functions very simple to understand, only because of what lies underneath of those functions i.e, create_reduction_func
, ReductionKernel
, ElementwiseKernel
, create_ufunc
are some amazing pieces of work done by the CuPy team. It’s really amazing how easily someone can create a new function and that too works superfast using CUDA. As I was studying these functions, I also addressed some comments for the open PRs.
I then tried to implement cupy.nanmean
. It could have been easy to do if I was just to follow NumPy’s implementation, but that involved iterating over entire ndarray
twice. So, I tried to create separate preamble for getting the result in one iteration. It seemed easy at first, but I encountered many new errors related to dtypes.
Eighth week
I fixed some errors related to dtypes for cupy.nanmean
and implemented tests. I then studied cupy.var
, cupy.std
, numpy.var
and numpy.nanvar
in order to implement cupy.nanvar
and cupy.nanstd
. I am still working on it.
Then, I fixed some issues for Python and NumPy compatibility for Jenkins CI. Since my old setup was messed up, this took me whole day to setup all again from scratch.
This time most challenging work was to incorporate cupy.ndarray.__init__
and current wrapper ndarray.__init__
method into single ndarray.__init__
. I did this by implementing ndarray.__new__
method. This was not that tough, but I think it was a little hackish. I am currently working on fixing behaviour of numpy.vectorize
.
Summary
- PR #2272 got merged.
- I opened PR #2319 for
cupy.nanmean
- Modified method
ndarray.__init__
- Implemented method
ndarray.__new__
Future work
Future work includes handling numpy.vectorize
method and numpy.vectorize
object, as it currently returns numpy.ndarray
. Also, adding support for in-place operations in fallback_mode
.