Skip to content

Commit

Permalink
[inductor] Decompose boolean min/max into all/any (#110311)
Browse files Browse the repository at this point in the history
Pull Request resolved: #110311
Approved by: https://github.com/lezcano
ghstack dependencies: #110310
  • Loading branch information
peterbell10 authored and pytorchmergebot committed Oct 24, 2023
1 parent 46e80ce commit 1dd5708
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions torch/_inductor/decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,20 @@ def fmax(self, other):
return torch.where(torch.isnan(other) | (other < self), self, other)


@register_decomposition(aten.amax)
def amax(self, dim=None, keepdim=False):
if self.dtype == torch.bool:
return torch.any(self, dim=dim, keepdim=keepdim)
return NotImplemented


@register_decomposition(aten.amin)
def amin(self, dim=None, keepdim=False):
if self.dtype == torch.bool:
return torch.all(self, dim=dim, keepdim=keepdim)
return NotImplemented


@register_decomposition([aten.narrow_copy])
def narrow_copy(self, dim, start, length):
return torch.narrow(self, dim, start, length).clone()
Expand Down

0 comments on commit 1dd5708

Please sign in to comment.