Skip to content

Commit

Permalink
[inductor] Decompose boolean min/max into all/any
Browse files Browse the repository at this point in the history
ghstack-source-id: 0d4d312222b73d52880d599139eb0fcfb15b1046
Pull Request resolved: #110311
  • Loading branch information
peterbell10 committed Oct 13, 2023
1 parent 8d5704b commit c651337
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 @@ -294,6 +294,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 c651337

Please sign in to comment.