New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace sox conversion macros with Tensor op #1370
Conversation
Conversion from signed integer with left shift causes UB (negative left shift)
This reverts commit 8e71263.
chunk = chunk.to(c10::ScalarType::Double); | ||
chunk *= 2147483648.; | ||
chunk.clamp_(INT32_MIN, INT32_MAX); | ||
chunk = chunk.to(c10::ScalarType::Int); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that this will guarantee that chunk is contiguous afterwards. I'd call into "contiguous" anyway to be sure. Same applies for the other cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool. will update
SOX_SIGNED_16BIT_TO_SAMPLE
andSOX_SIGNED_32BIT_TO_SAMPLE
uses left shift on signed integers, which is UB.This PR replaces them (and other sox macros for
uint8
andfloat
as well) with Tensor operations.