• Home
  • About
    • Piyush Raikwar photo

      Piyush Raikwar

      Sophomore at ABV-IIITM, Gwalior, India

    • Learn More
    • Email
    • LinkedIn
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

First Evaluation Check..

08 Jul 2019

Reading time ~3 minutes

Hey! This is the fourth blog-post in my series of GSoC experience. That means I successfully passed first evaluation. First month was just great for me! I got to learn so many new things. Initially, it felt quite hard to get adjusted to these things. But, through constant searching and experimentation things turned out to be quite simple. And then I got this email on June, 28th. I was overjoyed and unable to contain my excitement for upcoming journey.

First Evaluation Results

Fifth week

Now, that the basic methods were implemented for fallback_mode and it worked for any NumPy method of the form res=numpy.func(*args, **kwargs), my next goal was to support fallback of methods of the form res=x.func(*args, **kwargs) where x is of type ndarray.

So, I implemented a wrapper fallback.ndarray class around cupy.ndarray which would fallback to numpy.ndarray when associated method is not yet implemented in CuPy. In this case, I think the challenging task was to wrap magic methods(methods starting and ending with '__') of cupy.ndarray as Python skip lookup of these magic methods through __getattr__. So, I had to proxy all magic methods of cupy.ndarray into fallback.ndarray. This will be automatically done when user imports cupyx.fallback_mode.

Simultaneously, I was working on creating a notification mechanism for fallback_mode similar to NumPy’s floating point error. I implemented seterr, geterr, errstate. It includes support for following 6 modes to dispatch notification:

  • warn: Print warning using warnings module.
  • print: Prints warning to stdout.
  • log: Record message in log object specified by seterrcall.
  • ignore: No action is taken.
  • raise: Raise an AttributeError.
  • call: Call function which was specified by seterrcall.

Sixth week

Until this week, fallback.ndarray was almost done. Notification support was done for all modes but call and log. Then, I had to implement seterrcall and geterrcall and integrate those with errstate. Other than that, this week was all about fixing comments and creating tests. I got meyself familiar with parameterized testing. It’s really good!

Also, there was this task of supporting isinstance(x, fallback.ndarray). As fallback.ndarray was a wrapper, so I was not suppossed to expose it. I initially felt this was going to be hard one, but guess what! Another magic method to the rescue! Python has __instancecheck__ method to override isinstance. Python is really cool and gives so much freedom to the users. I’m loving Python more than ever before!

Summary

Following objects were implemented for fallback.ndarray:

  • class ndarray
  • decorator make_method
  • method _create_magic_methods

Related work can be found in PR #2272

Following objects were implemented for Notifications:

  • method seterr
  • method geterr
  • method seterrcall
  • method geterrcall
  • context-manager errstate
  • method dispatch_notification

Related work can be found in PR #2279

Some other bug-fixes/improvements were also done:

  • method _RecursiveAttr.__doc__
  • method _RecursiveAttr.__instancecheck__
  • fix error in code of type dtype=numpy.int64

Future work

Future work will include adding support for in-place operations in fallback_mode and other improvements or bug fixes.



gsoccupy Share Tweet +1