-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support of tensor types with unit dimension prefix in EvalSlice (#…
…2090) Edit: Sure, sorry for missing description. Currently our small research team experimenting with BERT model represented in number of *-hlo dialects and wants to simplify it in terms of variety of operators. This PR fixes an issue we stumbled upon: ``` %42 = stablehlo.constant dense<"..."> : tensor<1x512xi64> ... %66 = stablehlo.slice %42 [0:1, 0:128] : (tensor<1x512xi64>) -> tensor<1x128xi64> ``` Previous implementation of EvalSlice can't handle such case -- tensor type prefixed with unit dimension(s) i.e. 1x128. This PR adds support of the above case and can slice from any position, e.g. ``` %0 = stablehlo.constant dense<[[[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]]]> : tensor<1x3x2x2xi64> %1 = "stablehlo.slice"(%0) { start_indices = array<i64: 0, 1, 1, 0>, limit_indices = array<i64: 1, 2, 2, 2>, strides = array<i64: 1, 1, 1, 1> } : (tensor<1x3x2x2xi64>) -> tensor<1x1x1x2xi64> ``` is folded to ``` %1 = stablehlo.constant dense<[[[[7, 8]]]]> : tensor<1x1x1x2xi64> ```
- Loading branch information
Showing
4 changed files
with
100 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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