-
Notifications
You must be signed in to change notification settings - Fork 652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[i1] Remove command line option to enable packed storage #19528
base: main
Are you sure you want to change the base?
Conversation
3099d0b
to
419ee6b
Compare
9159d90
to
e27a766
Compare
d26a392
to
7ac00fe
Compare
e27a766
to
7f752a4
Compare
This is a successor, improving PR to #19354 |
bd53c95
to
b17ea2f
Compare
The diff is off. There are some changes from #19354. E.g., the below is not part of this PR, right? ![]() Can you rebase and fix it? |
a6f4a4c
to
6468ea1
Compare
Note that changes that are not in this PR: #19618 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First round of the review comments, thanks for pushing on this!
#packed = #iree_encoding.packed_storage | ||
func.func @i1_type_slice() { | ||
%input = util.unfoldable_constant dense<[0, 255, 0]> : tensor<3xi8> | ||
%flat_input_all = flow.tensor.bitcast %input : tensor<3xi8> -> tensor<24xi1, #packed> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with how flow.tensor.bitcast
works. Is the encoding dropped in the TensorExportBufferViewOpPattern
pattern? How does it become a tensor_export_buffer_view op? I think we need some input from Ben about the change and the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The encoding dropped while it is calculating streamOp's allocated sizes.
flow.tensor.bitcast
is just an omni-potent caster here to cast a tensor to another tensor with #packed_storage
attribute.
c1711b1
to
fa8e6d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update! Please also add a test to https://github.com/iree-org/iree/blob/main/compiler/src/iree/compiler/Codegen/Common/test/type_propagation_packing.mlir
compiler/src/iree/compiler/Dialect/Encoding/IR/EncodingAttrs.td
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Dialect/HAL/Conversion/StreamToHAL/Patterns.cpp
Outdated
Show resolved
Hide resolved
@@ -1512,7 +1517,7 @@ LogicalResult TensorCloneOp::verify() { | |||
// information. | |||
auto sourceEncoding = llvm::cast<RankedTensorType>(op.getSourceEncoding()); | |||
auto resultEncoding = llvm::cast<RankedTensorType>(op.getResultEncoding()); | |||
if (sourceEncoding.getEncoding() != resultEncoding.getEncoding()) { | |||
if (getEncodingAttr(sourceEncoding) != getEncodingAttr(resultEncoding)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required by flow.tensor.bitcast
lowering? I.e., the op is lowered to flow.tensor.clone and you need to bypass the check?
I'm not convinced that the change is correct. Because the getEncodingAttr
checks if the tensor type has IREE::Encoding::EncodingAttr
attribute. There could be other encodings and it is a bug if we introduce new encodings. E.g., tensor<3x4xi32, #whatever_other_encoding_with_padding_semantic>
can not be cloned to tensor<3x4xi32>
. I think we need to have a stronger restriction. Perhaps just relax the check for packed_storage encoding?
iree/compiler/src/iree/compiler/Dialect/Encoding/IR/EncodingAttrs.cpp
Lines 278 to 280 in 27e7a90
EncodingAttr getEncodingAttr(RankedTensorType type) { | |
return dyn_cast_or_null<EncodingAttr>(type.getEncoding()); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little tricky. And yes this is required by flow.tensor.bitcast
, and we would sometimes cast from a tensor without attribute to another tensor with packed attribute. In such case, we shouldn't check if both the source and result matches packed attribute.
I have slightly updated it to exclude packed attribute comparison. Suggestions are welcome.
compiler/src/iree/compiler/Dialect/Stream/Transforms/ConvertToStream.cpp
Show resolved
Hide resolved
compiler/src/iree/compiler/Dialect/Encoding/IR/EncodingAttrs.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Dialect/Encoding/IR/EncodingAttrs.cpp
Outdated
Show resolved
Hide resolved
09316fa
to
6f232c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder: the test is not added yet. #19528 (review)
compiler/src/iree/compiler/Dialect/Encoding/IR/EncodingAttrs.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Dialect/HAL/Conversion/StreamToHAL/Patterns.cpp
Show resolved
Hide resolved
compiler/src/iree/compiler/Dialect/HAL/Conversion/StreamToHAL/Patterns.cpp
Outdated
Show resolved
Hide resolved
if (sourceEncoding.getEncoding() != resultEncoding.getEncoding() && | ||
!IREE::Encoding::hasPackedStorageAttr(sourceEncoding) && | ||
!IREE::Encoding::hasPackedStorageAttr(resultEncoding)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks better to me. I think we need some input from @benvanik
The previous comment is not tracked in the review mode. Here was the previous comment: #19528 (comment)
TLDR is that we use flow.tensor.bitcast to prepare packed data for e2e testing. The op becomes TensorClone op during the lowering. So we want to relax the verification here.
%flat_input_all = flow.tensor.bitcast %input : tensor<3xi8> -> tensor<24xi1, #packed>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benvanik Do you have opinions on this?
aad9619
to
2e8d28b
Compare
f4b5379
to
4a626d6
Compare
@hanhanW I've added a test to test type propagation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few final nits. LGTM except the TensorCloneOp::verify
part. Please coordinate with @benvanik about it.
compiler/src/iree/compiler/Codegen/Common/test/type_propagation_packing.mlir
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Dialect/Encoding/IR/EncodingAttrs.cpp
Outdated
Show resolved
Hide resolved
51d3f0f
to
1a6f454
Compare
* only use `#iree_encoding.packed_storage` to designate if an `i1` tensor is of packed memory layout. * remove `iree-experimental-packed-i1-storage` command line option. * teach type converters to allow casting into packed tensor types Signed-off-by: Alan Li <[email protected]>
dbcaa0a
to
0e60383
Compare
df53753
to
6e9fa41
Compare
#iree_encoding.packed_storage
to designate if ani1
tensor is of packed memory layout.iree-experimental-packed-i1-storage
command line option.