Open seberg opened 2 months ago
For comparison, this is how we're currently doing basic type-delegation in scipy.ndimage
: https://github.com/scipy/scipy/blob/main/scipy/ndimage/_support_alternative_backends.py, https://github.com/scipy/scipy/blob/main/scipy/ndimage/_dispatchers.py.
FWIW, this is a branch in skimage: https://github.com/scikit-image/scikit-image/compare/main...seberg:backend-cucim-try that uses the state here. I added a backend for cucim there (for filters.median and filters.gaussian), that has to live in cucim and be auto-generated of course. Difference in speed for a 1000x1000 NumPy vs. CuPy array is, 114us vs. 31ms on the machine I tried.
This is an early (and very dirty) start, in case it is useful to get going. (Ping @eriknw)
The "example" is just the
prototype_*
modules, with the_example
one being executable. I did not look into the entry-points, and of course this is all very raw:cucim
may want to only kick in for cupy arrays, but understandnumpy
arrays. A better example maybe adask.array
backend which can understand cupy/numpy, but will never be picked for those.WillNotHandle()
return class to pass out information for rejection, since I liked that idea:inspect
, which I really like for simplicity. We need the signature fetching for it, but otherwise we can always optimize it.Anyway, sharing in the hoping it might help. But please feel free to ignore if you have another start and are pushing forward there!