You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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>
```
0 commit comments