[Torch] Canonicalize aten.convolution with single int tuple params #4388
+293
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a more robust fix for the issue captured in #4380 .
Essentially,
torch.ops.aten.convolutionlowering totosa,linalgandstablehlofail ifstride,padding,dilationoroutput_paddingis a tuple with a singleton element, but convolution operates on 2 or 3 spatial dimensions.In the failing case,
torch.nn.Conv2dwithpadding= 'valid'generates atorch.ops.aten.conv2d.paddingop inExportedProgram, which is later decomposed totorch.ops.aten.convolution.defaultwith a single padding value of [0] after runningep.run_decompositions().In #4380, I attempted to fix just the
torch-to-tosapass, but I later realised that this is a more general bug in all the backends for multiple params (thanks to #4380 (comment)).Fix:
I followed #4250 to canonicalize aten.convolution if it operates on 2 or 3 spatial dims but params are singleton. For example, if
aten.convolutionis 2D butpadding == [0], we canonicalize it topadding == [0, 0]