Skip to content

Commit

Permalink
Bucketize fix to include number and tensor inputs (pytorch#133652)
Browse files Browse the repository at this point in the history
Fixes pytorch#132222

Pull Request resolved: pytorch#133652
Approved by: https://github.com/ezyang
  • Loading branch information
Lazarus42 authored and pytorchmergebot committed Aug 28, 2024
1 parent bb22132 commit 3e42f21
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion torch/_refs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5917,7 +5917,7 @@ def triu_indices(
@register_decomposition(aten.bucketize)
@out_wrapper(exact_dtype=True)
def bucketize(
a: TensorLikeType,
a: TensorOrNumberLikeType,
boundaries: TensorLikeType,
*,
out_int32: bool = False,
Expand All @@ -5928,6 +5928,7 @@ def bucketize(
lambda: f"boundaries tensor must be 1 dimension but got dim({boundaries.dim()})",
)

a = a if isinstance(a, torch.Tensor) else torch.tensor(a)
out_dtype = torch.int32 if out_int32 else torch.int64
n_boundaries = boundaries.shape[-1]
if n_boundaries == 0:
Expand Down

0 comments on commit 3e42f21

Please sign in to comment.