← Back to events
ActiveAIRelease

viable/strict/1790062257: Fix `torch.asarray` for buffer-protocol objects with no dtype (#188784)

Photo: PyTorch Releases

What happened

Fixes #188128 When no dtype is given, read the buffer's declared format (via PyBUF_FORMAT | PyBUF_STRIDES ) and map it to the matching ScalarType instead of guessing. The mapping lives in a new helper, scalar_type_from_buffer_format . It's a small, self-contained parser, but hand-rolled so the buffer path keeps working in USE_NUMPY=0 builds. It handles every PEP-3118 scalar code that has a corresponding torch dtype…

Summary assembled by rule from the sources below

Why it's spreading

Sources