warn when numpy and cupy are used together
@@ -41,6 +41,10 @@ class EmbedIDFunction(function.Function):
return xp.where(
mask[..., None], 0, W.take(xp.where(mask, 0, x), axis=0)),
+ if not issubclass(type(W), type(x)):
+ raise ValueError('numpy and cupy must not be used together\n'
+ 'type(W): %s, type(x): %s' % (type(W), type(x)))
+
return W.take(x, axis=0),
def backward(self, inputs, grad_outputs):
