diff --git a/thinc/backends/cupy_ops.py b/thinc/backends/cupy_ops.py index ec70cf72e..9f420fcd6 100644 --- a/thinc/backends/cupy_ops.py +++ b/thinc/backends/cupy_ops.py @@ -59,29 +59,20 @@ def gemm(self, x, y, out=None, trans1=False, trans2=False): return out def asarray(self, data, dtype=None): - # This is sort of frustrating, but we can't easily otherwise pass - # forward "unset". - dtype = {"dtype": dtype} if dtype is not None else {} - # We'll try to perform a zero-copy conversion if possible. - array = None - cast_array = False if is_cupy_array(data): - array = self.xp.asarray(data, **dtype) + array = data elif is_torch_gpu_array(data): array = torch2xp(data) - cast_array = True elif is_tensorflow_gpu_array(data): array = tensorflow2xp(data) - cast_array = True elif is_mxnet_gpu_array(data): array = mxnet2xp(data) - cast_array = True else: - array = self.xp.array(data, **dtype) + array = self.xp.array(data) - if cast_array and dtype != {}: - array = array.astype(dtype["dtype"]) + if dtype is not None: + array = array.astype(dtype=dtype, copy=False) return array