@@ -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