Skip to content

Commit

Permalink
Fixed result pos variable initialization bug
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenchouca committed May 23, 2017
1 parent 5471e55 commit 635bb4d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lower/lower.cpp
Expand Up @@ -532,15 +532,19 @@ Stmt lower(TensorBase tensor, string funcName, set<Property> properties) {
}

// Initialize the result ptr variables
Stmt prevIteratorInit;
for (auto& indexVar : tensor.getIndexVars()) {
Iterator iter = ctx.iterators[resultPath.getStep(indexVar)];
Stmt iteratorInit = VarAssign::make(iter.getPtrVar(), iter.begin(), true);
if (iter.isSequentialAccess()) {
Expr ptr = iter.getPtrVar();
Expr ptrPrev = iter.getParent().getPtrVar();

// Emit code to initialize the result ptr variable
Stmt iteratorInit = VarAssign::make(iter.getPtrVar(), iter.begin(), true);
if (prevIteratorInit.defined()) {
body.push_back(prevIteratorInit);
prevIteratorInit = Stmt();
}
body.push_back(iteratorInit);
} else {
prevIteratorInit = iteratorInit;
}
}
taco_iassert(results.size() == 1) << "An expression can only have one result";
Expand Down

0 comments on commit 635bb4d

Please sign in to comment.