[mlir] Canonicalize dynamic tensor.pad ops with constant inputs
authorGeorge Petterson <gpetters@protonmail.com>
Fri, 3 Feb 2023 21:43:45 +0000 (16:43 -0500)
committerGeorge Petterson <gpetters@protonmail.com>
Fri, 3 Feb 2023 21:43:45 +0000 (16:43 -0500)
commitbe58d484cb315028049255d9bb29ce2c7bffc983
treecde78f505f96403e4a6fa595094592d70a35ff55
parent2919ec041f071c5dab4ad17480af697aaf42d707
[mlir] Canonicalize dynamic tensor.pad ops with constant inputs

This commit adds a canonicalization pattern for tensor.pad which changes the output type to static at each dimension where the input shape is static and the high and low operands are constants. This corrects an issue arising in Torch-MLIR where pad ops would sometimes introduce dynamic shapes unnecessarily.

Reviewed By: raikonenfnu

Differential Revision: https://reviews.llvm.org/D143135
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
mlir/test/Dialect/Tensor/canonicalize.mlir