Skip to content

Commit a73b7c4

Browse files
committed
Fixed bug in Conv2D tiling constraints and reduced some code duplication. Added CI tests for 2D Float Conv with bias and reduced L1 size for non-bias test to force input tiling
1 parent cae8406 commit a73b7c4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

.github/workflows/ci-platform-siracusa-tiled.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ jobs:
4747
{"name":"Hardswish","L1":[750]},
4848
{"name":"RQHardswish","L1":[750]},
4949
{"name":"testFloatGEMM","L1":[8000]},
50-
{"name":"testFloat2DConvolution","L1":[8000]},
50+
51+
{"name":"testFloat2DConvolution","L1":[3000]},
52+
{"name":"testFloat2DConvolutionBias","L1":[8000]},
53+
{"name":"testFloat2DConvolutionZeroBias","L1":[8000]},
54+
5155
{"name":"testFloatLayerNorm","L1":[2000]},
5256
{"name":"testFloatRelu","L1":[2000]},
5357
{"name":"testFloatMaxPool","L1":[2000]},

Deeploy/Targets/PULPOpen/TileConstraints/ConvTileConstraint.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ def addGeometricalConstraint(tilerModel: TilerModel, parseDict: Dict, ctxt: Netw
312312
effectiveWidth = inputWidthVar + ((pads[1] + pads[3]) * (inputWidthVar == inputBuffer.shape[2]))
313313

314314
tilerModel.addConstraint(
315-
(outputHeightVar == (effectiveHeight - dilations[0] * (weightHeightVar - 1) - 1) // strides[0] + 1))
315+
(outputHeightVar == (effectiveHeight - dilations[0] * (weightHeightVar - 1) - 1) // strides[0]))
316316
tilerModel.addConstraint(
317-
(outputWidthVar == (effectiveWidth - dilations[1] * (weightWidthVar - 1) - 1) // strides[1] + 1))
317+
(outputWidthVar == (effectiveWidth - dilations[1] * (weightWidthVar - 1) - 1) // strides[1]))
318318

319319
# Add constraint for input channel size match
320320
# (Depends on weight output channel and conv grouping)
@@ -417,20 +417,16 @@ def computeInputCube(
417417
inputHOffset = max(outputHOffset * strideH - padTop, 0)
418418
inputWOffset = max(outputWOffset * strideW - padLeft, 0)
419419

420-
if inputDims is not None:
421-
# Compute input dimensions according to procedure described in PyTorch's Conv2D documentation
422-
# Assuming worst case (cutting of (stride - 1) elements at the end of each dimension)
423-
inputHSize = outputHSize * strideH + kernelShape[0] - (tilePadTop + tilePadBottom) - 1
424-
inputWSize = outputWSize * strideW + kernelShape[1] - (tilePadLeft + tilePadRight) - 1
420+
# Compute input dimensions according to procedure described in PyTorch's Conv2D documentation
421+
# Assuming worst case (cutting of (stride - 1) elements at the end of each dimension)
422+
inputHSize = outputHSize * strideH + (kernelShape[0] - 1) - (tilePadTop + tilePadBottom)
423+
inputWSize = outputWSize * strideW + (kernelShape[1] - 1) - (tilePadLeft + tilePadRight)
425424

425+
if inputDims is not None:
426426
# Clamp to remaining input size from the current offset
427427
# This prevents reading beyond input boundaries for edge tiles
428428
inputHSize = min(inputHSize, inputDims[1] - inputHOffset)
429429
inputWSize = min(inputWSize, inputDims[2] - inputWOffset)
430-
else:
431-
# Use previous version, compatible with RQ layers
432-
inputHSize = outputHSize * strideH + (kernelShape[0] - 1) - (tilePadTop + tilePadBottom)
433-
inputWSize = outputWSize * strideW + (kernelShape[1] - 1) - (tilePadLeft + tilePadRight)
434430

435431
InCube = HyperRectangle((outputBatchOffset, inputHOffset, inputWOffset, 0),
436432
(outputBatchSize, inputHSize, inputWSize, inputCSize))

0 commit comments

Comments
 (0)