In the current code, elements of DDim are int(32 bit) values. This design is directly ported from Majel. However, product() returns a ssize_t(64 bit) value. It's necessary because the product result of a huge tensor's dimensions can be extremly large (e.g. in word embedding). When we flatten a tensor to a vector, we are trying to assign a ssize_t value to an int value. It may cause overflow.