Skip to content

add support for tensor.insert_slice in layout optimization#2335

Merged
copybara-service[bot] merged 1 commit intomainfrom
test_819886128
Oct 24, 2025
Merged

add support for tensor.insert_slice in layout optimization#2335
copybara-service[bot] merged 1 commit intomainfrom
test_819886128

Conversation

@copybara-service
Copy link
Contributor

@copybara-service copybara-service bot commented Oct 20, 2025

add support for tensor.insert_slice in layout optimization

This PR adds the following

  • layout-propagation: Rectify the slice layout with the destination operand of the tensor.insert_slice and then propagate the destination layout to the result layout
  • layout-optimization: Treat tensor.insert_slice as a LayoutHoistingOpInterface and allow hoisting convert_layout operations through insert_slice by updating the destination operand layout
  • convert-to-ciphertext-semantics: This lowers tensor.insert_slice, by first remapping the input to be compatible with the destination layout (by composing the relation from the insert slice with the destination layout) and then masking / mul / adding each ciphertext of the result and inserting into a result tensor

FIXMEs left:

  • Some assertions about the slice strides
  • convert-to-ciphertext-semantics was updated to optimize layouts in a forward pass for any ops that change layouts but that's only for insert slice so it feels like a special case right now and I want to clean that mess up.

@copybara-service copybara-service bot force-pushed the test_819886128 branch 5 times, most recently from f7c48f4 to 1e3ecbb Compare October 21, 2025 15:26
@copybara-service copybara-service bot changed the title wip: add support for insert_slice in layout optimization add support for tensor.insert_slice in layout optimization Oct 21, 2025
@copybara-service copybara-service bot force-pushed the test_819886128 branch 4 times, most recently from f0a5aa5 to df0f5dc Compare October 24, 2025 21:25
This PR adds the following
* layout-propagation: Rectify the slice layout with the destination operand of the tensor.insert_slice and then propagate the destination layout to the result layout
* layout-optimization: Treat tensor.insert_slice as a LayoutHoistingOpInterface and allow hoisting convert_layout operations through insert_slice by updating the destination operand layout
* convert-to-ciphertext-semantics: This lowers tensor.insert_slice, by first remapping the input to be compatible with the destination layout (by composing the relation from the insert slice with the destination layout) and then masking / mul / adding each ciphertext of the result and inserting into a result tensor

FIXMEs left:
* Some assertions about the slice strides
* convert-to-ciphertext-semantics was updated to optimize layouts in a forward pass for any ops that change layouts but that's only for insert slice so it feels like a special case right now and I want to clean that mess up.

PiperOrigin-RevId: 823679451
@copybara-service copybara-service bot merged commit 8b52080 into main Oct 24, 2025
@copybara-service copybara-service bot deleted the test_819886128 branch October 24, 2025 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant