transformers
a20852a0 - Cast pixel values to the patch embedding dtype in DeepSeek-OCR-2 (#48632)

Commit
61 days ago
Cast pixel values to the patch embedding dtype in DeepSeek-OCR-2 (#48632) * Cast pixel values to the patch embedding dtype in DeepSeek-OCR-2 The released checkpoint is bfloat16 but the image processor emits float32 `pixel_values`, so the very first convolution raises RuntimeError: Input type (float) and bias type (c10::BFloat16) should be the same This makes the usage example in the model documentation fail as written, on any device. Cast the input to the projection weight dtype, the same way `CLIPVisionEmbeddings` and `SiglipVisionEmbeddings` already do. * Fix the dtype in the DeepSeek-OCR-2 doc examples instead of casting in the model Revert the cast in DeepseekOcr2SamPatchEmbeddings.forward and cast the processor output in the docs instead, as suggested in review. The integration tests already do .to(model.device, dtype=torch.bfloat16), so the docs were simply out of sync with the model's own convention.
Author
Parents
Loading