Thanks for sharing! Why does CuPy switch to float64 in this case? Is it a bug?
You could get away using a double to only accumulate the sum, but it's a pain to write such mixed-precision (slow) function in C and then wrap it in Python, esp. for something like this.
(See, https://github.com/numpy/numpy/blob/v1.17.0/numpy/lib/functi...)