[mlir] Declare reshapeLikeShapesAreCompatible before verifyReshapeLikeTypes (#245432) `verifyReshapeLikeTypes` is a function template that calls `reshapeLikeShapesAreCompatible`, which is only declared further down the header. The call is dependent, so it resolves at instantiation through ADL on the lambda's enclosing namespace, which newer compilers accept. Clang 7 does not (it predates the DR1690 lookup rules for local classes) and fails with "call to function 'reshapeLikeShapesAreCompatible' that is neither visible in the template definition nor found by argument-dependent lookup" while building TensorOps.cpp. Move the declaration above the template so ordinary lookup finds it.
diff --git a/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h b/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h index 4df9a05d..35d862a 100644 --- a/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h +++ b/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h
@@ -149,6 +149,16 @@ return nullptr; } +/// Verify that shapes of the reshaped types using following rule: +/// if a dimension in the collapsed type is static, then the corresponding +/// dimensions in the expanded shape should be +/// a) static +/// b) the product should be same as the collaped shape. +LogicalResult reshapeLikeShapesAreCompatible( + function_ref<LogicalResult(const Twine &)> emitError, + ArrayRef<int64_t> collapsedShape, ArrayRef<int64_t> expandedShape, + ArrayRef<ReassociationIndices> reassociationMaps, bool isExpandingReshape); + /// Common verifier for reshape-like types. Fills `expandedType` and ///`collapsedType` with the proper `src` or `result` type. template <typename Op, typename T> @@ -186,16 +196,6 @@ op.getReassociationIndices(), isExpansion); } -/// Verify that shapes of the reshaped types using following rule: -/// if a dimension in the collapsed type is static, then the corresponding -/// dimensions in the expanded shape should be -/// a) static -/// b) the product should be same as the collaped shape. -LogicalResult reshapeLikeShapesAreCompatible( - function_ref<LogicalResult(const Twine &)> emitError, - ArrayRef<int64_t> collapsedShape, ArrayRef<int64_t> expandedShape, - ArrayRef<ReassociationIndices> reassociationMaps, bool isExpandingReshape); - /// Returns true iff the type is a MemRefType and has a non-identity layout. bool hasNonIdentityLayout(Type type);