forked from OSchip/llvm-project
Add convenience function for checking arrays of shapes compatible.
Expand existing one to handle the common case for verifying compatible is existing and inferred. This considers arrays equivalent if they they have the same size and pairwise compatible elements.
This commit is contained in:
parent
8af0ccf5a4
commit
acaf85f700
|
@ -55,6 +55,11 @@ LogicalResult verifyCompatibleShape(ArrayRef<int64_t> shape1,
|
|||
/// does not matter.
|
||||
LogicalResult verifyCompatibleShape(Type type1, Type type2);
|
||||
|
||||
/// Returns success if the given two arrays have the same number of elements and
|
||||
/// each pair wise entries have compatible shape.
|
||||
LogicalResult verifyCompatibleShapes(ArrayRef<Type> types1,
|
||||
ArrayRef<Type> types2);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Utility Iterators
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -86,6 +86,18 @@ LogicalResult mlir::verifyCompatibleShape(Type type1, Type type2) {
|
|||
return verifyCompatibleShape(sType1.getShape(), sType2.getShape());
|
||||
}
|
||||
|
||||
/// Returns success if the given two arrays have the same number of elements and
|
||||
/// each pair wise entries have compatible shape.
|
||||
LogicalResult mlir::verifyCompatibleShapes(ArrayRef<Type> types1,
|
||||
ArrayRef<Type> types2) {
|
||||
if (types1.size() != types2.size())
|
||||
return failure();
|
||||
for (auto it : zip_first(types1, types2))
|
||||
if (failed(verifyCompatibleShape(std::get<0>(it), std::get<1>(it))))
|
||||
return failure();
|
||||
return success();
|
||||
}
|
||||
|
||||
OperandElementTypeIterator::OperandElementTypeIterator(
|
||||
Operation::operand_iterator it)
|
||||
: llvm::mapped_iterator<Operation::operand_iterator, Type (*)(Value)>(
|
||||
|
|
Loading…
Reference in New Issue