Skip to content

Commit

Permalink
[Fix] slice with dynamic batch
Browse files Browse the repository at this point in the history
When the length operand of slice is -1, it means taking all elements on
that dimension. Originally, inst simplification pass attemps to replace
-1 with actual dimension size.
However, -1 is also used to represent dynamic size, so it will make the
pass keep running.
  • Loading branch information
Weiming Zhao authored and weimingzha0 committed Nov 29, 2021
1 parent 2b1f261 commit 4e6dc0d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/transforms/inst_simplify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2324,9 +2324,10 @@ std::pair<Def, Def> InstSimplify::RunOnInstruction(SliceInst* inst) {
std::vector<int> size_adj(dim);
bool new_size = false;
for (int i = 0; i != dim; ++i) {
int size_i = c_size->GetDataAsInt64(i);
if (size_i == -1) {
size_adj[i] = dst_type.GetNumOfElementsInDim(i);
int64_t size_i = c_size->GetDataAsInt64(i);
int64_t s = dst_type.GetNumOfElementsInDim(i);
if (size_i == -1 && s != -1) {
size_adj[i] = s;
new_size = true;
} else {
size_adj[i] = size_i;
Expand Down

0 comments on commit 4e6dc0d

Please sign in to comment.