[Mlir-commits] [mlir] [MLIR] Preserve Encoding During TensorOp Creation (PR #80871)
ian Bearman
llvmlistbot at llvm.org
Fri Feb 16 10:59:01 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:
I admit, i'm unfamiliar with `VerifiableTensorEncoding` and its intended use. (I think i originally wrote up this code before it existed)
> you can't ensure that it is correct to just propagate it right?
My thinking (before this discussion) that the Encoding attribute was opaque, so the code shouldn't know anything about them. The encodings used in my compiler are not specific to the shape of the tensor and i need to propagate them in all cases.
I suppose it comes down to the default behavior desired here. Currently default is: "don't propagate encoding" and the intent of my change was to change the default to: "always propagate if possible".
I think your suggesting two things:
- don't change the default, but instead, only transfer the encoding if it can be proved to be transferable (via the VerifiableTensorEncoding interface).
- make sure to query verifyEncoding before propagating
Please let me know if i'm getting this correct. I'm okay with doing one or both or neither of these, so please let me know what you think is best.
https://github.com/llvm/llvm-project/pull/80871
More information about the Mlir-commits
mailing list