-
Notifications
You must be signed in to change notification settings - Fork 48
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
comb-to-cggi: fix secret cast lowerings to handle multi-dimensional tensors #810
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
copybara-service
bot
force-pushed
the
test_655160200
branch
3 times, most recently
from
July 24, 2024 15:15
1cdba19
to
95b2d36
Compare
copybara-service
bot
force-pushed
the
test_655160200
branch
3 times, most recently
from
July 25, 2024 20:31
2a426b8
to
094743c
Compare
copybara-service bot
pushed a commit
that referenced
this pull request
Jul 26, 2024
…ginal result type. In the case of yosys-optimizing a generic with a memref result type, we want to match the allocation for the result bits to match the original shape. Before this fix, we would always allocate a flattened bit representation. For e.g. if the result shape was memref<2xi4> we would allocate memref<8xi1>. This would result in a secret.cast that was hard to handle and we couldn't fold away casting the flattened memref to the desired shape. Instead, we allocate the memref according to the original shape. This way we can still easily fold away stores into the flattened view of the memref and casts back to the original shape. Note that this CL is complimentary to #810 - that PR resolves the secret.cast's while this PR allows all the memref.stores generated by yosys optimizer for the result bits to be load/stored from the original desired shape. This way our final IR doesn't have any `memref.collapse_shape/expand_shape/reinterpret_cast`'s leftover. PiperOrigin-RevId: 656418355
copybara-service bot
pushed a commit
that referenced
this pull request
Jul 26, 2024
…ginal result type. In the case of yosys-optimizing a generic with a memref result type, we want to match the allocation for the result bits to match the original shape. Before this fix, we would always allocate a flattened bit representation. For e.g. if the result shape was memref<2xi4> we would allocate memref<8xi1>. This would result in a secret.cast that was hard to handle and we couldn't fold away casting the flattened memref to the desired shape. Instead, we allocate the memref according to the original shape. This way we can still easily fold away stores into the flattened view of the memref and casts back to the original shape. Note that this CL is complimentary to #810 - that PR resolves the secret.cast's while this PR allows all the memref.stores generated by yosys optimizer for the result bits to be load/stored from the original desired shape. This way our final IR doesn't have any `memref.collapse_shape/expand_shape/reinterpret_cast`'s leftover. PiperOrigin-RevId: 656418355
copybara-service bot
pushed a commit
that referenced
this pull request
Jul 26, 2024
…ginal result type. In the case of yosys-optimizing a generic with a memref result type, we want to match the allocation for the result bits to match the original shape. Before this fix, we would always allocate a flattened bit representation. For e.g. if the result shape was memref<2xi4> we would allocate memref<8xi1>. This would result in a secret.cast that was hard to handle and we couldn't fold away casting the flattened memref to the desired shape. Instead, we allocate the memref according to the original shape. This way we can still easily fold away stores into the flattened view of the memref and casts back to the original shape. Note that this CL is complimentary to #810 - that PR resolves the secret.cast's while this PR allows all the memref.stores generated by yosys optimizer for the result bits to be load/stored from the original desired shape. This way our final IR doesn't have any `memref.collapse_shape/expand_shape/reinterpret_cast`'s leftover. PiperOrigin-RevId: 656418355
copybara-service bot
pushed a commit
that referenced
this pull request
Jul 26, 2024
…ginal result type. In the case of yosys-optimizing a generic with a memref result type, we want to match the allocation for the result bits to match the original shape. Before this fix, we would always allocate a flattened bit representation. For e.g. if the result shape was memref<2xi4> we would allocate memref<8xi1>. This would result in a secret.cast that was hard to handle and we couldn't fold away casting the flattened memref to the desired shape. Instead, we allocate the memref according to the original shape. This way we can still easily fold away stores into the flattened view of the memref and casts back to the original shape. Note that this CL is complimentary to #810 - that PR resolves the secret.cast's while this PR allows all the memref.stores generated by yosys optimizer for the result bits to be load/stored from the original desired shape. This way our final IR doesn't have any `memref.collapse_shape/expand_shape/reinterpret_cast`'s leftover. PiperOrigin-RevId: 656418355
code-perspective
approved these changes
Jul 26, 2024
copybara-service
bot
force-pushed
the
test_655160200
branch
2 times, most recently
from
July 29, 2024 20:17
e704e26
to
d055a2c
Compare
…ensors Testcase describes how this appears in the tosa-to-boolean-tfhe pipeline. I just have to decide whether to resolve the result shapes by allocating the memref of the correct shape in the RTLIL Importer instead of expand_shape op. It doesn't matter for the opernad shapes and collapse_shape because --fold-memref-alias-ops will get rid of the load/stores from the flat tensor. But it can't "remove" the flat allocated result tensor. PiperOrigin-RevId: 657307963
copybara-service
bot
force-pushed
the
test_655160200
branch
from
July 29, 2024 20:31
d055a2c
to
172275e
Compare
copybara-service bot
pushed a commit
that referenced
this pull request
Jul 30, 2024
…ginal result type. In the case of yosys-optimizing a generic with a memref result type, we want to match the allocation for the result bits to match the original shape. Before this fix, we would always allocate a flattened bit representation. For e.g. if the result shape was memref<2xi4> we would allocate memref<8xi1>. This would result in a secret.cast that was hard to handle and we couldn't fold away casting the flattened memref to the desired shape. Instead, we allocate the memref according to the original shape. This way we can still easily fold away stores into the flattened view of the memref and casts back to the original shape. Note that this CL is complimentary to #810 - that PR resolves the secret.cast's while this PR allows all the memref.stores generated by yosys optimizer for the result bits to be load/stored from the original desired shape. This way our final IR doesn't have any `memref.collapse_shape/expand_shape/reinterpret_cast`'s leftover. PiperOrigin-RevId: 656418355
copybara-service bot
pushed a commit
that referenced
this pull request
Jul 31, 2024
…ginal result type. In the case of yosys-optimizing a generic with a memref result type, we want to match the allocation for the result bits to match the original shape. Before this fix, we would always allocate a flattened bit representation. For e.g. if the result shape was memref<2xi4> we would allocate memref<8xi1>. This would result in a secret.cast that was hard to handle and we couldn't fold away casting the flattened memref to the desired shape. Instead, we allocate the memref according to the original shape. This way we can still easily fold away stores into the flattened view of the memref and casts back to the original shape. Note that this CL is complimentary to #810 - that PR resolves the secret.cast's while this PR allows all the memref.stores generated by yosys optimizer for the result bits to be load/stored from the original desired shape. This way our final IR doesn't have any `memref.collapse_shape/expand_shape/reinterpret_cast`'s leftover. PiperOrigin-RevId: 656418355
copybara-service bot
pushed a commit
that referenced
this pull request
Jul 31, 2024
…ginal result type. In the case of yosys-optimizing a generic with a memref result type, we want to match the allocation for the result bits to match the original shape. Before this fix, we would always allocate a flattened bit representation. For e.g. if the result shape was memref<2xi4> we would allocate memref<8xi1>. This would result in a secret.cast that was hard to handle and we couldn't fold away casting the flattened memref to the desired shape. Instead, we allocate the memref according to the original shape. This way we can still easily fold away stores into the flattened view of the memref and casts back to the original shape. Note that this CL is complimentary to #810 - that PR resolves the secret.cast's while this PR allows all the memref.stores generated by yosys optimizer for the result bits to be load/stored from the original desired shape. This way our final IR doesn't have any `memref.collapse_shape/expand_shape/reinterpret_cast`'s leftover. PiperOrigin-RevId: 656418355
copybara-service bot
pushed a commit
that referenced
this pull request
Jul 31, 2024
…ginal result type. In the case of yosys-optimizing a generic with a memref result type, we want to match the allocation for the result bits to match the original shape. Before this fix, we would always allocate a flattened bit representation. For e.g. if the result shape was memref<2xi4> we would allocate memref<8xi1>. This would result in a secret.cast that was hard to handle and we couldn't fold away casting the flattened memref to the desired shape. Instead, we allocate the memref according to the original shape. This way we can still easily fold away stores into the flattened view of the memref and casts back to the original shape. Note that this CL is complimentary to #810 - that PR resolves the secret.cast's while this PR allows all the memref.stores generated by yosys optimizer for the result bits to be load/stored from the original desired shape. This way our final IR doesn't have any `memref.collapse_shape/expand_shape/reinterpret_cast`'s leftover. PiperOrigin-RevId: 658128669
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
comb-to-cggi: fix secret cast lowerings to handle multi-dimensional tensors
Testcase describes how this appears in the tosa-to-boolean-tfhe pipeline.
I just have to decide whether to resolve the result shapes by allocating the memref of the correct shape in the RTLIL Importer instead of expand_shape op. It doesn't matter for the opernad shapes and collapse_shape because --fold-memref-alias-ops will get rid of the load/stores from the flat tensor. But it can't "remove" the flat allocated result tensor.