Check datasize
@@ -171,6 +171,9 @@ class coo_matrix(sparse_data._data_matrix):
"""
if self._has_canonical_format:
return
+ if self.data.size == 0:
+ self._has_canonical_format = True
+ return
keys = cupy.stack([self.row, self.col])
order = cupy.lexsort(keys)
src_data = self.data[order]
