I know I can easily rewrite numpy dot product in cupy dot product by using corresponding API:
import numpy as np
import cupy as cp
arr1 = np.array([[1, 2], [3, 4]])
arr2 = np.array([[5, 6], [7, 8]])
np.dot(arr1, arr2)
arr1_ = cp.asarray(arr1)
arr2_ = cp.asarray(arr2)
cp.dot(arr1_, arr2_)
I read that elementwise kernels in cupy run a lot faster (over hundreds times faster than corresponding numpy dot product). So I was guessing Q1. if I can do above dot product using elementwise kernel, or its that dot product is simply not an elementwise operation?
I wanted to increase the execution speed of neural network that I coded from scratch in numpy (for academic purpose and I dont want to use pytorch or tensorflow). And most of operations in neural network computation involve dot product. Q2. So, if we cannot use cupy elementwise kernel for dot product, then for what else I can use them (in the context of neural networks involving multiclass classification)?
Q3. Is there any faster alternative in cupy for cupy.dot
? (Just want to be sure I am utilising fastest approach)