Skip to content

Commit aeb7599

Browse files
hunhoffeclaude
andcommitted
Skip leading size-1 dims when locating innermost contiguous run
verifyBDSizesStrides previously treated dim 0 as the innermost contiguous run, but a leading size-1 dim is a DMA no-op and does not constrain alignment. Walk past leading size-1 entries to find the real innermost dim before applying the granularity and stride-alignment checks. Also drop the degenerate dimensionsToStream=[(1,2),(1,1)] from the vector_reduce_max memtile designs; it lowered to a zero-effect layout that only existed to work around the old verifier and is rejected by the unified helper. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
1 parent ef4442c commit aeb7599

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

lib/Dialect/AIE/IR/AIEDialect.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,14 +2210,21 @@ mlir::LogicalResult xilinx::AIE::verifyBDSizesStrides(
22102210
return forOp->emitOpError("Size ") << i << " must be a positive integer.";
22112211
}
22122212

2213+
// The "real" innermost contiguous run is the deepest dim with size > 1; a
2214+
// leading size==1 entry (innermost in the original op) is a DMA no-op and
2215+
// does not constrain alignment.
2216+
int innermost = 0;
2217+
while (innermost < n - 1 && inputSizes[innermost] == 1)
2218+
++innermost;
2219+
22132220
// Innermost contiguous run must be a multiple of address granularity --
22142221
// hardware moves whole words; a sub-word innermost run is unrealizable.
2215-
if (inputSizes[0] * elemWidthBits % addressGranularityBits != 0) {
2222+
if (inputSizes[innermost] * elemWidthBits % addressGranularityBits != 0) {
22162223
std::stringstream msg;
22172224
msg << "Transfer sizes must be multiples of "
2218-
<< (addressGranularityBits / 8) << " bytes. " << inputSizes[0]
2225+
<< (addressGranularityBits / 8) << " bytes. " << inputSizes[innermost]
22192226
<< " elements at " << (elemWidthBits / 8) << " bytes each equal "
2220-
<< (inputSizes[0] * elemWidthBits / 8)
2227+
<< (inputSizes[innermost] * elemWidthBits / 8)
22212228
<< " bytes, which is not divisible by " << (addressGranularityBits / 8)
22222229
<< ". ";
22232230
return forOp->emitOpError(msg.str());
@@ -2235,11 +2242,11 @@ mlir::LogicalResult xilinx::AIE::verifyBDSizesStrides(
22352242
}
22362243
}
22372244

2238-
// Stride byte-alignment: innermost stride==1 is always allowed (sub-word
2239-
// packed contiguous run, paired with the granularity check above); any other
2240-
// stride must be a granularity multiple in bytes.
2245+
// Stride byte-alignment: the innermost non-degenerate dim's stride==1 is
2246+
// always allowed (sub-word packed contiguous run, paired with the granularity
2247+
// check above); any other stride must be a granularity multiple in bytes.
22412248
for (int i = 0; i < n; ++i) {
2242-
if (i == 0 && inputStrides[i] == 1)
2249+
if (i == innermost && inputStrides[i] == 1)
22432250
continue;
22442251
if (inputSizes[i] == 1)
22452252
continue;
@@ -2257,7 +2264,7 @@ mlir::LogicalResult xilinx::AIE::verifyBDSizesStrides(
22572264
// For element widths larger than the granularity (e.g. bfp blocks, i64),
22582265
// the hardware cannot encode a non-1 innermost stride; getHardwareStrides-
22592266
// Wraps would silently drop the stride. Force innermost stride == 1.
2260-
if (elemWidthBits > addressGranularityBits && inputStrides[0] != 1)
2267+
if (elemWidthBits > addressGranularityBits && inputStrides[innermost] != 1)
22612268
return forOp->emitOpError(
22622269
"For element widths larger than the address granularity (")
22632270
<< (addressGranularityBits / 8)

programming_examples/basic/vector_reduce_max/single_column_designs/vector_reduce_max_memtile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def my_reduce_max(dev, in1_size, out_size, dtype_str, trace_size):
5050
out_fifos = []
5151

5252
of_in = ObjectFifo(mem_ty, name="of_in")
53-
outC = ObjectFifo(int_ty, name="outC", dims_to_stream=[(1, 2), (1, 1)])
53+
outC = ObjectFifo(int_ty, name="outC")
5454
of_out = ObjectFifo(out_ty, name="of_out")
5555

5656
if n_cores > 1:

programming_examples/basic/vector_reduce_max/single_column_designs/vector_reduce_max_memtile_placed.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def device_body():
111111
cores[0],
112112
buffer_depth,
113113
int_ty,
114-
dimensionsToStream=[(1, O), (1, 1)],
115114
)
116115
object_fifo_link(out_fifos, outC, of_c_offsets, [])
117116

0 commit comments

Comments
 (0)