Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine indirectly defined constant for clamp op #2268

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mmanzoorTT
Copy link
Contributor

Ticket

closes #2185

Problem description

stablehlo.clamp is lowered to either 1) ttir.clamp or 2) ttir.maximum followed by ttir.minimum op.
However, tt-metal does not support implicit broadcast for maximum and minimum ops. These two
ops fail if the operand shapes does not match and broadcast is required.

What's changed

  1. Broadcast min/max value(s) if the shape of min/max does not match with input operand.
  2. If a constant op is indirectly used in the stablehlo.clamp op (e.g. constant is converted/reshaped and then used in clamp op), then determine the constant value of min/max and use it in ttir.clamp conversion.

Checklist

  • New/Existing tests provide coverage for changes

@mmanzoorTT mmanzoorTT force-pushed the mmanzoor/clamp-reshape-input branch 4 times, most recently from 62fd183 to ac19198 Compare February 27, 2025 12:21
Constant can be converted/reshaped/broadcasted and then used in stablehlo.clamp
op. Determine the base constant value for min/max and use them in ttir.clamp op.
@mmanzoorTT mmanzoorTT force-pushed the mmanzoor/clamp-reshape-input branch from ac19198 to 5ebaa5e Compare February 27, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stablehlo.clamp conversion bug
2 participants