[Mlir-commits] [mlir] [mlir] Convert TensorType and BaseMemRefType to interfaces (PR #133053)

Andrei Golubev llvmlistbot at llvm.org
Wed Mar 26 04:37:14 PDT 2025


================
@@ -77,9 +77,9 @@ struct CastOpInterface
     // Case 3: Ranked tensor -> ranked tensor. The offsets and strides do not
     // change.
     auto rankedResultType = cast<RankedTensorType>(castOp.getType());
-    return MemRefType::get(
+    return llvm::cast<BaseMemRefType>(MemRefType::get(
----------------
andrey-golubev wrote:

well, turns out there's no free lunch here...
so even with the operators in place we get issues when doing: `MemRefType` -> `FailureOr<BaseMemRefType>`. I vaguely remember some corner of C++ standard saying something along the lines of "one cannot have two consecutive user-specified conversions in an expression".
which i guess is what happens here: there's a conversion from MemRefType to BaseMemRefType (user-specified) and then a call to ctor FailureOr<BaseMemRefType> (also user-specified)?

I guess for the case in question to work, we also need an extra ctor (SFINAE-guarded likely) that does roughly: `template<typename U> FailureOr(const U& u) : FailureOr(T(u)) {}` but i'm not sure it's a good idea to extend this PR for that, i'd rather have it in the follow-up (it may turn out there's some other problem once this is done...).

https://github.com/llvm/llvm-project/pull/133053


More information about the Mlir-commits mailing list