I have a code which I got from Numpy repeat for 2d array
Below one works fine with numpy array but throws
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() when using with cupy arrays.
For the line ret_val[mask] = cp.repeat(arr.ravel(), rep.ravel()
I have tried to use logical operations already existing in cupy but they still throw errors.
def repeat2dvect(arr, rep):
lens = cp.array(rep.sum(axis=-1))
maxlen = lens.max()
ret_val = cp.zeros((arr.shape[0], int(maxlen)))
mask = (lens[:,None]>cp.arange(maxlen))
ret_val[mask] = cp.repeat(arr.ravel(), rep.ravel())
return ret_val