Gets the device from a device object, an ID integer or an array object.
This is a convenient utility to select a correct device if the type of
argis unknown (i.e., one can use this function on arrays that may be on CPU or GPU). The returned device object supports the context management protocol of Python for the with statement.
Parameters: args – Values to specify a GPU device. The first device object, integer or
cupy.ndarrayobject is used to select a device. If it is a device object, it is returned. If it is an integer, the corresponding device is returned. If it is a CuPy array, the device on which this array reside is returned. If any arguments are neither integers nor CuPy arrays, a dummy device object representing CPU is returned.
Returns: Device object specified by given
cupy.cuda.Devicefor the device selection not by arrays.