[MLIR][Tensor] Remove assert in PadOp builder
authorLorenzo Chelini <l.chelini@icloud.com>
Wed, 19 Oct 2022 15:31:22 +0000 (17:31 +0200)
committerLorenzo Chelini <l.chelini@icloud.com>
Wed, 19 Oct 2022 16:02:50 +0000 (18:02 +0200)
The assert is misplaced as the result type is allowed to be null. A few
lines below the result type is inferred if it is passed a nullptr.
Besides, this behavior is described in the documentation of the builder.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D136262

mlir/lib/Dialect/Tensor/IR/TensorOps.cpp

index 0ee79a6..dd92ef2 100644 (file)
@@ -2407,7 +2407,6 @@ void PadOp::build(OpBuilder &b, OperationState &result, Type resultType,
                   Value source, ArrayRef<OpFoldResult> low,
                   ArrayRef<OpFoldResult> high, bool nofold,
                   ArrayRef<NamedAttribute> attrs) {
-  assert(resultType.isa<RankedTensorType>());
   auto sourceType = source.getType().cast<RankedTensorType>();
   SmallVector<Value, 4> dynamicLow, dynamicHigh;
   SmallVector<int64_t, 4> staticLow, staticHigh;