Skip to content

cupy_array[:] = numpy_array does not work #593

@kohr-h

Description

@kohr-h

It would be nice if __setitem__ worked with Numpy arrays as right-hand side. Currently one gets the error

    Traceback (most recent call last):
      File "cupy/core/core.pyx", line 1575, in cupy.core.core.ndarray.__setitem__
      File "cupy/core/core.pyx", line 3043, in cupy.core.core._scatter_op
      File "cupy/core/core.pyx", line 442, in cupy.core.core.ndarray.fill
    ValueError: non-scalar numpy.ndarray cannot be used for fill

A straightforward implementation could first cast to a cupy array and then do the usual setitem. An optimization for same dtype and size (assuming contiguous memory) would be to just use cudaMemcpy cupy_array.data.copy_from_host, but that may not be very relevant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions