cupy / cupy

NumPy & SciPy for GPU

Home Page:https://cupy.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong cast in uint * int product

BrunoLiegiBastonLiegi opened this issue · comments

Description

Multiplying a cp.array of unsigned int and another cp.array of int produces an array of floats.

To Reproduce

import cupy as cp

i = cp.array(2, dtype=int)
z = cp.ones(4, dtype=cp.uint)
print((i * z).dtype)
# this gives dtype('float64')

Installation

Wheel (pip install cupy-***)

Environment

OS                           : Linux-5.15.0-89-generic-x86_64-with-glibc2.35
Python Version               : 3.10.12
CuPy Version                 : 12.2.0
CuPy Platform                : NVIDIA CUDA
NumPy Version                : 1.24.4
SciPy Version                : 1.11.3
Cython Build Version         : 0.29.36
Cython Runtime Version       : None
CUDA Root                    : /usr/local/cuda
nvcc PATH                    : /usr/local/cuda/bin/nvcc
CUDA Build Version           : 12020
CUDA Driver Version          : 12020
CUDA Runtime Version         : 12020
cuBLAS Version               : (available)
cuFFT Version                : 11008
cuRAND Version               : 10303
cuSOLVER Version             : (11, 5, 2)
cuSPARSE Version             : (available)
NVRTC Version                : (12, 2)
Thrust Version               : 200101
CUB Build Version            : 200101
Jitify Build Version         : <unknown>
cuDNN Build Version          : (not loaded; try `import cupy.cuda.cudnn` first)
cuDNN Version                : (not loaded; try `import cupy.cuda.cudnn` first)
NCCL Build Version           : None
NCCL Runtime Version         : None
cuTENSOR Version             : None
cuSPARSELt Build Version     : None
Device 0 Name                : NVIDIA RTX A6000
Device 0 Compute Capability  : 86
Device 0 PCI Bus ID          : 0000:C5:00.0

Additional Information

No response

@BrunoLiegiBastonLiegi CuPy does not guarantee type promotion compatibility for zero-dimensional arrays. Please refer to the following document for more details.
https://docs.cupy.dev/en/stable/user_guide/difference.html#type-promotion