viable/strict/1790062257: Fix `torch.asarray` for buffer-protocol objects with no dtype (#188784)
- PyTorch: 1328 events in the last 90 days
- PyTorch: 1313th Release in the last 90 days
- Previous: earlier the same day · viable/strict/1790060510: flex_gemm: accept 1-D captured tensors (#196183)
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