[Mlir-commits] [mlir] [MLIR] Preserve Encoding During TensorOp Creation (PR #80871)
Mehdi Amini
llvmlistbot at llvm.org
Fri Feb 16 13:20:22 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:
> My thinking (before this discussion) that the Encoding attribute was opaque, so the code shouldn't know anything about them
But when something is "opaque" we have two approaches:
1) We don't do the transformation (because we risk making an incorrect transformation)
2) We drop the opaque attribute (we don't guarantee propagation, these attributes have to be droppable).
This come down to the guarantee we intend to provide with this attribute though.
> don't change the default, but instead, only transfer the encoding if it can be proved to be transferable (via the VerifiableTensorEncoding interface).
Yes: basically we could consider that an attribute which implements `VerifiableTensorEncoding` is "opt in" into being propagated as long as it verifies.
But even this is sketchy: the "verifier" aspect does not guarantee that the transformation is semantic preserving!
https://github.com/llvm/llvm-project/pull/80871
More information about the Mlir-commits
mailing list