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

Mehdi Amini llvmlistbot at llvm.org
Thu Feb 15 16:22:44 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>()) {
----------------
joker-eph wrote:

In general dropping is the "safe" thing to do when we transform code and we don't know if the transformation can preserve the semantics of the encoding.

Now there may be a specific argument here you'd want to make, but it should be made explicit, about why propagating "blindly" an opaque encoding would be correct in the absolute? If my attribute does not implement the "VerifiableTensorEncoding", you can't ensure that it is correct to just propagate it right?

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


More information about the Mlir-commits mailing list