Skip to content

Commit

Permalink
Fix issue in the verifier of StreamReadOp
Browse files Browse the repository at this point in the history
  • Loading branch information
hanchenye committed Feb 23, 2024
1 parent b1922b8 commit 84f820d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
4 changes: 3 additions & 1 deletion lib/Dialect/HLS/IR/HLSOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ static LogicalResult verifyTripCountsAndSteps(Operation *op, Value channel) {
llvm::zip(channelType.getIterTripCounts(), channelType.getIterSteps()),
[](auto tuple) { return std::get<0>(tuple) != 1; });

if (llvm::any_of(llvm::zip(stripedLoopInfo, stripedIterInfo), [](auto tuple) {
if (std::distance(stripedLoopInfo.begin(), stripedLoopInfo.end()) !=
std::distance(stripedIterInfo.begin(), stripedIterInfo.end()) ||
llvm::any_of(llvm::zip(stripedLoopInfo, stripedIterInfo), [](auto tuple) {
return std::get<0>(tuple) != std::get<1>(tuple);
})) {
auto diag = op->emitOpError("loop trip counts or steps doesn't align with "
Expand Down
8 changes: 4 additions & 4 deletions lib/Dialect/HLS/Transforms/LowerDataflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ struct ConvertTaskToNode : public OpRewritePattern<TaskOp> {
rewriter.setInsertionPoint(task);
auto node = rewriter.create<NodeOp>(rewriter.getUnknownLoc(), inputs,
outputs, params);
node->setAttrs(task->getAttrs());
auto nodeBlock = rewriter.createBlock(&node.getBody());

auto inputArgs = nodeBlock->addArguments(ValueRange(inputs), inputLocs);
Expand Down Expand Up @@ -165,14 +166,13 @@ struct LowerDataflow : public LowerDataflowBase<LowerDataflow> {

// Convert dispatch, task, and to_memref operations.
ConversionTarget target(*context);
target
.addIllegalOp<DispatchOp, TaskOp, YieldOp, bufferization::ToMemrefOp>();
target.addLegalOp<ScheduleOp, NodeOp, ConstBufferOp>();
target.addIllegalOp<DispatchOp, TaskOp, YieldOp>();
target.addLegalOp<ScheduleOp, NodeOp>();

mlir::RewritePatternSet patterns(context);
patterns.add<ConvertDispatchToSchedule>(context);
patterns.add<ConvertTaskToNode>(context);
patterns.add<ConvertConstantToConstBuffer>(context);
// patterns.add<ConvertConstantToConstBuffer>(context);
if (failed(applyPartialConversion(func, target, std::move(patterns))))
return signalPassFailure();
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Pipelines/Pipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ void scalehls::addComprehensiveBufferizePasses(OpPassManager &pm) {
// can be deleted by canonicalizer. We have to run it again because the
// memrefs are unified in CSE pass, so we can truely remove redundant memcpy.
pm.addPass(mlir::createCanonicalizerPass());
pm.addPass(memref::createFoldMemRefAliasOpsPass());
pm.addPass(hls::createRaiseSCFToAffinePass());
pm.addPass(mlir::createCanonicalizerPass());
// pm.addPass(memref::createFoldMemRefAliasOpsPass());
// pm.addPass(hls::createRaiseSCFToAffinePass());
// pm.addPass(mlir::createCanonicalizerPass());
}

void scalehls::addConvertDataflowToFuncPasses(OpPassManager &pm) {
Expand Down
9 changes: 5 additions & 4 deletions lib/Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ scalehls::constructLoops(ArrayRef<int64_t> tripCounts, ArrayRef<int64_t> steps,
SmallVector<scf::ForOp> scalehls::getSurroundingLoops(Operation *target,
Block *sourceBlock) {
SmallVector<scf::ForOp> reversedLoops;
while (auto loop = target->getParentOfType<scf::ForOp>()) {
reversedLoops.push_back(loop);
target = loop;
if (sourceBlock == loop->getBlock())
while (auto parent = target->getParentOp()) {
if (auto loop = dyn_cast<scf::ForOp>(parent))
reversedLoops.push_back(loop);
target = parent;
if (sourceBlock == parent->getBlock())
break;
}
return {reversedLoops.rbegin(), reversedLoops.rend()};
Expand Down

0 comments on commit 84f820d

Please sign in to comment.