Skip to content

Commit

Permalink
Fix bug in TopK pattern matching that sets K as 2nd dim rather than l…
Browse files Browse the repository at this point in the history
…ast. (#14041)

Test cases coming in following PR, this is just a quick fix while it's
out for review.
  • Loading branch information
NatashaKnk committed Jun 9, 2023
1 parent c4e01e9 commit fa3a220
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,9 @@ struct IotaSortSliceIsTopK final : OpRewritePattern<mlir::stablehlo::SortOp> {
// Treat the first slice as inputs, the second as indices.
if (idx == 0) {
topV = sliceOp.getResult();
k = sliceOp.getLimitIndices().getValues<int64_t>()[1];
SmallVector<int64_t> limitIndices =
llvm::to_vector(sliceOp.getLimitIndices().getValues<int64_t>());
k = limitIndices.back();
} else {
topI = sliceOp.getResult();
}
Expand Down

0 comments on commit fa3a220

Please sign in to comment.