[Mlir-commits] [mlir] Preserve Encoding During TensorOp Creation (PR #80871)

Aart Bik llvmlistbot at llvm.org
Tue Feb 6 15:14:41 PST 2024


================
@@ -1622,7 +1623,20 @@ CollapseShapeOp::inferCollapsedType(RankedTensorType type,
     currentDim += dim;
   }
 
-  return RankedTensorType::get(newShape, type.getElementType());
+  auto encoding = type.getEncoding();
+  if (auto v = encoding.dyn_cast_or_null<VerifiableTensorEncoding>()) {
+    auto ignoreError = [&] {
+      auto emitter = mlir::emitError(UnknownLoc::get(type.getContext()));
+      emitter.abandon();
+      return emitter;
+    };
+    if (failed(
----------------
aartbik wrote:

Yeah, when dimensionality changes, one would have to come up with a new encoding (e.g. a sparse matrix becomes a sparse vector or the opposite). But that indeed seems to be out of scope for this change, so reporting an error seems the right approach

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


More information about the Mlir-commits mailing list