Skip to content
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

Fix ConditionalSpeculatability implementation for DynamicReshape #2261

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

mlevesquedion
Copy link
Contributor

Both the input and the shape must be fully known statically. Whether the output is dynamic or not does not matter.

Indeed, consider e.g.:

func.func @foo(%arg0: tensor<?x?xf64>) {
    %constant_shape = stablehlo.constant dense<[2, 3]> : tensor<2xi32>
    %0 = stablehlo.dynamic_reshape %arg0, %constant_shape : (tensor<?x?xf64>, tensor<2xi32>) -> tensor<?x?xf64>
    return
}

The input is dynamic, so it could turn out to have e.g. 10 elements instead of the expected 6. Similarly, if the shape is unknown:

func.func @foo(%arg0: tensor<2x3xf64>, %unknown_shape: tensor<2xi32>) {
    %0 = stablehlo.dynamic_reshape %arg0, %unknown_shape : (tensor<2x3xf64>, tensor<2xi32>) -> tensor<?x?xf64>
    return
}

Again, the shape could turn out to be e.g. [2, 5] at runtime and so the reshape's behavior would be undefined.

Both the input and the shape must be fully known statically. Whether the output is dynamic or not does not matter.

Indeed, consider e.g.:

```
func.func @foo(%arg0: tensor<?x?xf64>) {
    %constant_shape = stablehlo.constant dense<[2, 3]> : tensor<2xi32>
    %0 = stablehlo.dynamic_reshape %arg0, %constant_shape : (tensor<?x?xf64>, tensor<2xi32>) -> tensor<?x?xf64>
    return
}
```

The input is dynamic, so it could turn out to have e.g. 10 elements
instead of the expected 6. Similarly, if the shape is unknown:

```
func.func @foo(%arg0: tensor<2x3xf64>, %unknown_shape: tensor<2xi32>) {
    %0 = stablehlo.dynamic_reshape %arg0, %unknown_shape : (tensor<2x3xf64>, tensor<2xi32>) -> tensor<?x?xf64>
    return
}
```

Again, the shape could turn out to be e.g. `[2, 5]` at runtime and so
the reshape's behavior would be undefined.
@mlevesquedion mlevesquedion merged commit 7d95a16 into openxla:main Apr 29, 2024
10 checks passed
@mlevesquedion mlevesquedion deleted the fix-dyn-reshape-cs branch April 29, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants