forked from tensorflow/tensorflow
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lite:stablehlo: add serialization for stablehlo add, multiply, divide…
… and maximum op PiperOrigin-RevId: 555305030
- Loading branch information
1 parent
b6f9258
commit 9b5e827
Showing
9 changed files
with
132 additions
and
18 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
48 changes: 42 additions & 6 deletions
48
tensorflow/compiler/mlir/lite/tests/flatbuffer2mlir/stablehlo.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 |
---|---|---|
@@ -1,16 +1,52 @@ | ||
// RUN: flatbuffer_translate -mlir-to-tflite-flatbuffer %s -o - | flatbuffer_translate --tflite-flatbuffer-to-mlir - -o - | FileCheck %s | ||
// test stablehlo roundtrip | ||
|
||
module { | ||
func.func @main(%arg0: tensor<1x1x1x96xf32>) -> tensor<1x1x1x96xf32> { | ||
%0 = stablehlo.logistic %arg0 : tensor<1x1x1x96xf32> | ||
func.return %0 : tensor<1x1x1x96xf32> | ||
} | ||
|
||
// CHECK:func.func @main(%arg0: tensor<1x1x1x96xf32>) -> tensor<1x1x1x96xf32> attributes {tf.entry_function = {inputs = "arg0", outputs = "stablehlo.logistic"}} { | ||
// CHECK: %0 = stablehlo.logistic %arg0 : tensor<1x1x1x96xf32> | ||
// CHECK: return %0 : tensor<1x1x1x96xf32> | ||
// CHECK:} | ||
|
||
func.func @add(%arg0: tensor<1xf32>, %arg1: tensor<1xf32>) -> tensor<1xf32> { | ||
%0 = stablehlo.add %arg0, %arg1 : tensor<1xf32> | ||
func.return %0 : tensor<1xf32> | ||
} | ||
|
||
// CHECK:func.func private @add(%arg0: tensor<1xf32>, %arg1: tensor<1xf32>) -> tensor<1xf32> { | ||
// CHECK: %0 = stablehlo.add %arg0, %arg1 : tensor<1xf32> | ||
// CHECK: return %0 : tensor<1xf32> | ||
// CHECK:} | ||
|
||
func.func @multiply(%arg0: tensor<1xf32>, %arg1: tensor<1xf32>) -> tensor<1xf32> { | ||
%0 = stablehlo.multiply %arg0, %arg1 : tensor<1xf32> | ||
func.return %0 : tensor<1xf32> | ||
} | ||
|
||
// CHECK:func.func private @multiply(%arg0: tensor<1xf32>, %arg1: tensor<1xf32>) -> tensor<1xf32> { | ||
// CHECK: %0 = stablehlo.multiply %arg0, %arg1 : tensor<1xf32> | ||
// CHECK: return %0 : tensor<1xf32> | ||
// CHECK:} | ||
|
||
func.func @divide(%arg0: tensor<1xf32>, %arg1: tensor<1xf32>) -> tensor<1xf32> { | ||
%0 = stablehlo.divide %arg0, %arg1 : tensor<1xf32> | ||
func.return %0 : tensor<1xf32> | ||
} | ||
|
||
// CHECK:func.func private @divide(%arg0: tensor<1xf32>, %arg1: tensor<1xf32>) -> tensor<1xf32> { | ||
// CHECK: %0 = stablehlo.divide %arg0, %arg1 : tensor<1xf32> | ||
// CHECK: return %0 : tensor<1xf32> | ||
// CHECK:} | ||
|
||
func.func @maximum(%arg0: tensor<1xf32>, %arg1: tensor<1xf32>) -> tensor<1xf32> { | ||
%0 = stablehlo.maximum %arg0, %arg1 : tensor<1xf32> | ||
func.return %0 : tensor<1xf32> | ||
} | ||
|
||
// CHECK:module attributes {tfl.description = "MLIR Converted.", tfl.schema_version = 3 : i32} { | ||
// CHECK: func.func @main(%arg0: tensor<1x1x1x96xf32>) -> tensor<1x1x1x96xf32> attributes {tf.entry_function = {inputs = "arg0", outputs = "stablehlo.logistic"}} { | ||
// CHECK: %0 = stablehlo.logistic %arg0 : tensor<1x1x1x96xf32> | ||
// CHECK: return %0 : tensor<1x1x1x96xf32> | ||
// CHECK: } | ||
// CHECK:func.func private @maximum(%arg0: tensor<1xf32>, %arg1: tensor<1xf32>) -> tensor<1xf32> { | ||
// CHECK: %0 = stablehlo.maximum %arg0, %arg1 : tensor<1xf32> | ||
// CHECK: return %0 : tensor<1xf32> | ||
// CHECK:} |
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
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