diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/StableHLOToStableHLO.cpp b/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/StableHLOToStableHLO.cpp index 15692381bfb8..65864bd0a4e4 100644 --- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/StableHLOToStableHLO.cpp +++ b/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/StableHLOToStableHLO.cpp @@ -1607,7 +1607,9 @@ struct IotaSortSliceIsTopK final : OpRewritePattern { // Treat the first slice as inputs, the second as indices. if (idx == 0) { topV = sliceOp.getResult(); - k = sliceOp.getLimitIndices().getValues()[1]; + SmallVector limitIndices = + llvm::to_vector(sliceOp.getLimitIndices().getValues()); + k = limitIndices.back(); } else { topI = sliceOp.getResult(); }