Updates to shape functions enabling reuse from MHLO #1918
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The upstream change #1869 in StableHLO updates various API related to shape inference. MHLO shape inference functions in hlo_ops.cc uses those APIs. The PR updates the visibility and signature of those API for a clearer integration.
Specifically, the PR does the followings:
updates
getAccumulatorTypes
to return a error status when the input regions is empty: This function is used in type inference of various reduction based operations (eg). This functions enables infering type based on the reduction block of the operation, which is something proposed in RFC. However, there could be instances when type inference can be called with empty region in which case we would like to report a meaningful diagnostic message.Allow
hlo::inferAllReduceOp
to accept multiple operands information: In stableHLO,all_reduce
op have a single operand (e.g.), whereas in MHLO the op can take multiple operand (e.g.. Thehlo::inferAllReduceOp
signature is updated to accommodate both cases.Remove unused arguments to functions
verifyReduceOpInputsAndInferShape
andinferReduceOp
.