Skip to content

Commit 150e202

Browse files
[Dynamism][LNL] UngroupBoundedBuffersPass - support SwKernelOps with multiple outputs; and other fixes (#42)
1 parent aa3d23a commit 150e202

20 files changed

+66
-24
lines changed

src/vpux_compiler/src/dialect/VPUIP/transforms/passes/ungroup_bounded_buffer.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ mlir::LogicalResult UngroupSwKernelOp::matchAndRewrite(VPUIP::SwKernelOp origOp,
105105
}
106106
}
107107

108-
VPUX_THROW_WHEN(origOp.getOutputBuffs().size() != 1 || origOp.getOutputs().size() != 1,
109-
"UngroupBoundedBuffers pass supports SwKernelOp with single output for now");
110-
111108
SmallVector<mlir::Value> swKernelOutputBuffs;
112109
SmallVector<mlir::Value> swKernelDynamicOutputShapes;
113110
SmallVector<int32_t> swKernelDynamicOutputShapesMap;
@@ -134,20 +131,17 @@ mlir::LogicalResult UngroupSwKernelOp::matchAndRewrite(VPUIP::SwKernelOp origOp,
134131
auto args = kernelArgsRange(origOp);
135132
initSwKernel(swKernelOp, swKernelOperands, swKernelOutputBuffs, args, _log.nest());
136133

137-
for (auto result : origOp.getResults()) {
138-
if (result.getType().isa<VPUIP::BoundedBufferType>()) {
139-
// if result is BoundedBufferType, then it is guaranteed to have swKernelDynamicOutputShapes not empty
140-
// Tracking number [E#115679]
141-
// TODO: SwKernelOp's results 0 and 1 may not always be correct here, only in the case where
142-
// there is only one bounded result. Similarly, using replaceOp here when there are more than
143-
// one result will not behave as intended.
144-
auto groupOp = rewriter.create<VPUIP::GroupBoundedBufferOp>(swKernelOp.getLoc(), swKernelOp.getResult(0),
145-
swKernelOp.getResult(1));
146-
rewriter.replaceOp(origOp, groupOp.getOutput());
134+
SmallVector<mlir::Value> newResults;
135+
for (auto i : irange(origOp.getNumResults())) {
136+
if (mlir::isa<VPUIP::BoundedBufferType>(origOp.getResult(i).getType())) {
137+
auto groupOp = rewriter.create<VPUIP::GroupBoundedBufferOp>(swKernelOp.getLoc(), swKernelOp.getResult(i),
138+
swKernelOp.getDynamicOutputShapes()[i]);
139+
newResults.push_back(groupOp.getOutput());
147140
} else {
148-
rewriter.replaceOp(origOp, swKernelOp.getResults());
141+
newResults.push_back(swKernelOp.getResult(i));
149142
}
150143
}
144+
rewriter.replaceOp(origOp, newResults);
151145

152146
return mlir::success();
153147
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:7b9820e53c8e1b046fac50fa280a7ed21d291360cfafabd71a6772ae1c5e1d73
3-
size 54364
2+
oid sha256:493a994293f81eb38525fdec6d58e62eb88a8f4cf5df203dbe70eb0db58b4f01
3+
size 54332
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:2f5173e02f7ab2d7f7f4bb4211af7e7ef9aca12337e0396bdd3c1ca45f8a7e90
3-
size 54444
2+
oid sha256:bb6697592a8bd9cb867be4dc2d55659515bbdd1b39c45a0704519c3d63701cd4
3+
size 54396
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:493226913355517e0a7b504b9caf71d058782ccec0e806cb2e1957772430480c
3-
size 55116
2+
oid sha256:1593ecaeca176873a1a64990b2bb446cff89ebcfe8484109ea12ecafc602138d
3+
size 56124
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:3f57ed9b6cdfcc3a74b4c302d4d9fa450a7b02123b46b43a367a4ef9cc32a9d4
3+
size 3412
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:fb77a3c70bb477ca5d939223a05428d65200cb70c2721ca56d30e33e8816ac68
3-
size 8288
2+
oid sha256:2858cca7dc5279decdc10bd91ce02a3a95d9cf6b3e67d8d06d05197556034983
3+
size 3200
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:cbbb9184e800d0cff27e0fe79a3cafe1f99c3f6d60c45205d3fcddc0be68d1f1
3+
size 820
Binary file not shown.

sw_runtime_kernels/kernels/prebuild/act_shave_bin/sk.dynamic_reshape.4000xx.data

Whitespace-only changes.
Binary file not shown.

0 commit comments

Comments
 (0)