MLIR 23.0.0git
VerificationUtils.cpp
Go to the documentation of this file.
1//===- VerificationUtils.cpp - Common verification utilities --------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11using namespace mlir;
12
13LogicalResult mlir::verifyDynamicDimensionCount(Operation *op, ShapedType type,
14 ValueRange dynamicSizes) {
15 int64_t expectedCount = type.getNumDynamicDims();
16 int64_t actualCount = dynamicSizes.size();
17 if (expectedCount != actualCount) {
18 return op->emitOpError("incorrect number of dynamic sizes, has ")
19 << actualCount << ", expected " << expectedCount;
20 }
21 return success();
22}
return success()
Operation is the basic unit of execution within MLIR.
Definition Operation.h:88
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
This class provides an abstraction over the different types of ranges over Values.
Definition ValueRange.h:387
Include the generated interface declarations.
LogicalResult verifyDynamicDimensionCount(Operation *op, ShapedType type, ValueRange dynamicSizes)
Verify that the number of dynamic size operands matches the number of dynamic dimensions in the shape...