-
Notifications
You must be signed in to change notification settings - Fork 490
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[StableHLO] Port TF bounded dynamism MHLO fixes to StableHLO.
PiperOrigin-RevId: 718425491
- Loading branch information
1 parent
e795171
commit e9db0f5
Showing
14 changed files
with
294 additions
and
75 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
26 changes: 26 additions & 0 deletions
26
xla/hlo/translate/hlo_to_mhlo/tests/import_bounded_dynamism.hlo
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// RUN: xla-translate -hlo-text-to-mlir-hlo -hlo-import-all-computations -split-input-file %s -o - | FileCheck %s | ||
|
||
|
||
HloModule main, entry_computation_layout={(pred[<=1801,1]{1,0})->pred[<=1801,1]{1,0}} | ||
|
||
ENTRY %convert_with_predicate (Arg_0.1: pred[<=1801,1]) -> pred[<=1801,1] { | ||
// CHECK: [[CST:%.*]] = mhlo.constant dense<false> : tensor<1801x1xi1> | ||
// CHECK-NEXT: [[GDS:%.*]] = "mhlo.get_dimension_size"(%arg0) <{dimension = 0 : i64}> : (tensor<?x1xi1, #mhlo.type_extensions<bounds = [1801, ?]>>) -> tensor<i32> | ||
// CHECK-NEXT: [[SDS:%.*]] = "mhlo.set_dimension_size"([[CST]], [[GDS]]) <{dimension = 0 : i64}> : (tensor<1801x1xi1>, tensor<i32>) -> tensor<?x1xi1, #mhlo.type_extensions<bounds = [1801, ?]>> | ||
// CHECK-NEXT: [[CMP:%.*]] = mhlo.compare NE, %arg0, [[SDS]] : (tensor<?x1xi1, #mhlo.type_extensions<bounds = [1801, ?]>>, tensor<?x1xi1, #mhlo.type_extensions<bounds = [1801, ?]>>) -> tensor<?x1xi1, #mhlo.type_extensions<bounds = [1801, ?]>> | ||
// CHECK-NEXT: return [[CMP]] : tensor<?x1xi1, #mhlo.type_extensions<bounds = [1801, ?]>> | ||
%Arg_0.1 = pred[<=1801,1] parameter(0) | ||
ROOT %convert_pred = pred[<=1801,1] convert(%Arg_0.1) | ||
} | ||
|
||
// ----- | ||
|
||
HloModule main, entry_computation_layout={(f32[<=1801,1]{1,0})->f32[<=1801,1]{1,0}} | ||
|
||
ENTRY %convert_with_f32icate (Arg_0.1: f32[<=1801,1]) -> f32[<=1801,1] { | ||
// CHECK: [[CVT:%.*]] = mhlo.convert %arg0 : tensor<?x1xf32, #mhlo.type_extensions<bounds = [1801, ?]>> | ||
// CHECK-NEXT: return [[CVT]] : tensor<?x1xf32, #mhlo.type_extensions<bounds = [1801, ?]>> | ||
%Arg_0.1 = f32[<=1801,1] parameter(0) | ||
ROOT %convert_f32 = f32[<=1801,1] convert(%Arg_0.1) | ||
} | ||
|
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
17 changes: 17 additions & 0 deletions
17
xla/hlo/translate/mhlo_to_hlo/tests/export_bounded_dynamism.mlir
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: xla-translate --print-sugar=false -split-input-file -mlir-hlo-to-hlo-text -verify-diagnostics %s | FileCheck %s | ||
|
||
// CHECK-LITERAL: HloModule main | ||
func.func @main(%arg0: tensor<1x1x?xf32, #mhlo.type_extensions<bounds = [?, ?, 1801]>>) -> tensor<1x16x1x?xf32, #mhlo.type_extensions<bounds = [?, ?, ?, 1801]>> { | ||
// CHECK: ROOT {{.*}} = f32[1,16,1,<=1801] broadcast | ||
%0 = "mhlo.broadcast_in_dim"(%arg0) <{broadcast_dimensions = dense<[0, 2, 3]> : tensor<3xi64>}> : (tensor<1x1x?xf32, #mhlo.type_extensions<bounds = [?, ?, 1801]>>) -> tensor<1x16x1x?xf32, #mhlo.type_extensions<bounds = [?, ?, ?, 1801]>> | ||
return %0 : tensor<1x16x1x?xf32, #mhlo.type_extensions<bounds = [?, ?, ?, 1801]>> | ||
} | ||
|
||
// ----- | ||
|
||
// CHECK-LITERAL: HloModule main | ||
func.func @main(%arg0: tensor<1x?x512xf32, #mhlo.type_extensions<bounds = [?, 1800, ?]>>, %arg1: tensor<i32>) -> tensor<1x?x512xf32, #mhlo.type_extensions<bounds = [?, 1800, ?]>> { | ||
// CHECK: ROOT {{.*}} = f32[1,<=1800,512] set-dimension-size | ||
%0 = "mhlo.set_dimension_size"(%arg0, %arg1) <{dimension = 1 : i64}> : (tensor<1x?x512xf32, #mhlo.type_extensions<bounds = [?, 1800, ?]>>, tensor<i32>) -> tensor<1x?x512xf32, #mhlo.type_extensions<bounds = [?, 1800, ?]>> | ||
return %0 : tensor<1x?x512xf32, #mhlo.type_extensions<bounds = [?, 1800, ?]>> | ||
} |
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
Oops, something went wrong.