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

ian Bearman llvmlistbot at llvm.org
Fri Feb 9 16:06: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>()) {
----------------
manbearian wrote:

Hi @joker-eph thanks for your response. I think there may be a misunderstanding, as i don't think what you're saying will work, but i'm not sure if its on my part or yours.

>From what i read in the code, the previous behavior drops the encoding (not propagated) for all cases when creating a new type. I'm changing this to reuse the encoding on the newly created type. However, the special case test here is that for this particular encoding (the `VerifiabletensorEncoding`), the encoding may not be possible to propagate, since it is dimensionality specific.

I believe the best possible approach would be to update the encoding based on the new dimensionality, but as this isn't an area of the compiler i'm familiar with and that we don't use in our code base, i'm instead falling back to the exiting behavior of dropping the encoding.

Does this make sense?

I'm happy to discuss more if this approach is not what folks want to see.

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


More information about the Mlir-commits mailing list