fix(transforms): preserve device and dtype in squarepulse - #9005
fix(transforms): preserve device and dtype in squarepulse#9005aymuos15 wants to merge 3 commits into
Conversation
Allocate the squarepulse output on the input tensor's device (and floating dtype) so CUDA callers no longer silently get a CPU result. Integer inputs still promote to the default float dtype. Signed-off-by: Soumya Snigdha Kundu <soumya_snigdha.kundu@kcl.ac.uk>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 5 remain after this review. 📝 WalkthroughWalkthroughSquarepulse now creates its output tensor on the input device and preserves floating-point input dtype. Integer inputs retain default dtype promotion. New tests cover CPU and CUDA inputs, output shape, dtype, device placement, binary values, and reference-value matching. Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change preserves the input tensor's device and floating-point dtype while retaining existing integer promotion behavior; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
squarepulseallocated its output viatorch.zeros(t.shape), which defaults to a CPU float32 tensor regardless of the input tensor's device or dtype. This caused CUDA callers to silently receive a CPU result, breaking downstream transforms when GPU tensors were passed.This fix allocates the output on the input tensor's device, and preserves the input's floating-point dtype. Integer inputs still promote to the default float dtype (matching
torch.zerosbehavior).Diff
Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.