Skip to content

Commit 790cdaa

Browse files
committed
fix: support more dtypes in pad_nd function
- Removes hardcoded dtype exclusion list from pad_nd() - Enables torch.nn.functional.pad for bool and integer dtypes - Try-except fallback to numpy still handles unsupported combinations - Fixes #7842 Signed-off-by: skdas20 <skdas5405@gmail.com>
1 parent edb58f1 commit 790cdaa

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

monai/transforms/croppad/functional.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,7 @@ def pad_nd(
9696
return _np_pad(img, pad_width=to_pad, mode=mode, **kwargs)
9797
try:
9898
_pad = _np_pad
99-
if mode in {"constant", "reflect", "edge", "replicate", "wrap", "circular"} and img.dtype not in {
100-
torch.int16,
101-
torch.int64,
102-
torch.bool,
103-
torch.uint8,
104-
}:
99+
if mode in {"constant", "reflect", "edge", "replicate", "wrap", "circular"}:
105100
_pad = _pt_pad
106101
return _pad(img, pad_width=to_pad, mode=mode, **kwargs)
107102
except (ValueError, TypeError, RuntimeError) as err:

0 commit comments

Comments
 (0)