Repository navigation
Support dynamic mhlo.torch_index_select and add test. - #2598
Conversation
|
Add ShapeBuilder of mhlo TorchIndexSelectOp, that support dynamic shape TorchIndexSelectOp. |
stellaraccident
left a comment
There was a problem hiding this comment.
Thanks! Looks good overall with some small comments.
| torchIndexSelectOp.input().getType().cast<RankedTensorType>(); | ||
| auto indicesType = | ||
| torchIndexSelectOp.index().getType().cast<RankedTensorType>(); | ||
| if (!paramsType || !indicesType) { |
There was a problem hiding this comment.
Since you are checking for nullptr, what you want above is dyncast<>, not cast<>. cast will never return nullptr and will assert fail on a mismatched type.
| int64_t indicesRank = indicesType.getRank(); | ||
|
|
||
| std::vector<int64_t> shape(paramsType.getShape()); | ||
| int64_t axisValue = *(axis.getRawData()); |
There was a problem hiding this comment.
I think you want axis.getSExtValue() here and on the next line.
| GENERATE_RANKED_DIM_OP(paramsShapeValue, i); | ||
| } | ||
| } else { | ||
| if (resultShapeRank != paramsRank + indicesRank - 1 - batchDimValue) { |
There was a problem hiding this comment.
Nit: can you add parens around the rhs?
| @@ -0,0 +1,58 @@ | |||
| // RUN: iree-run-mlir %s -iree-hal-target-backends=llvm-ir -input-value="2x2xi32=[6, 7] [8, 9]" -input-value="2x2x2x2xi32=[[[0, 1] [1, 0]] [[0, 0] [1, 1]]] [[[1, 1] [0, 0]] [[0, 1] [1, 0]]]" | IreeFileCheck %s | |||
There was a problem hiding this comment.
Can you point me to (or add a test) where we are testing the wrap-around (negative index) behavior?
There was a problem hiding this comment.
In tensorflow, axis and batch_dims can be negative.
But the function TorchIndexSelectOpConversion in HLOToLinalgOnBuffers.cpp disable the nagtive, so modify the code and add the negative case.
c4caf57 to
97eb1b8
Compare
97eb1b8 to
ced3b0d
Compare
|
@googlebot I signed it! |
Support dynamic mhlo.torch_index_select and add test.