forked from tensorflow/tensorflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lite] Fix for signature def export in TFLiteConverter to handle case…
…s when output was deduplicated and multiple outputs point to same output buffer/tensor. PiperOrigin-RevId: 366908259 Change-Id: I58b231e316419d89bd98a8cfb7a577c4e50f67fd
- Loading branch information
1 parent
be1238c
commit 258528e
Showing
2 changed files
with
116 additions
and
3 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
107 changes: 107 additions & 0 deletions
107
tensorflow/compiler/mlir/lite/tests/mlir2flatbuffer/signature_def_output_override.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,107 @@ | ||
// RUN: flatbuffer_translate -mlir-to-tflite-flatbuffer %s -o - | flatbuffer_to_string - | FileCheck %s | ||
|
||
// CHECK: { | ||
// CHECK-NEXT: version: 3, | ||
// CHECK-NEXT: operator_codes: [ { | ||
// CHECK-NEXT: deprecated_builtin_code: 9, | ||
// CHECK-NEXT: version: 1, | ||
// CHECK-NEXT: builtin_code: FULLY_CONNECTED | ||
// CHECK-NEXT: } ], | ||
// CHECK-NEXT: subgraphs: [ { | ||
// CHECK-NEXT: tensors: [ { | ||
// CHECK-NEXT: shape: [ 1, 3 ], | ||
// CHECK-NEXT: buffer: 1, | ||
// CHECK-NEXT: name: "serving_default_input2:0", | ||
// CHECK-NEXT: quantization: { | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: shape_signature: [ -1, 3 ] | ||
// CHECK-NEXT: }, { | ||
// CHECK-NEXT: shape: [ 1, 3 ], | ||
// CHECK-NEXT: buffer: 2, | ||
// CHECK-NEXT: name: "serving_default_input1:0", | ||
// CHECK-NEXT: quantization: { | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: shape_signature: [ -1, 3 ] | ||
// CHECK-NEXT: }, { | ||
// CHECK-NEXT: shape: [ 5 ], | ||
// CHECK-NEXT: buffer: 3, | ||
// CHECK-NEXT: name: "std.constant", | ||
// CHECK-NEXT: quantization: { | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: }, { | ||
// CHECK-NEXT: shape: [ 5, 3 ], | ||
// CHECK-NEXT: buffer: 4, | ||
// CHECK-NEXT: name: "std.constant1", | ||
// CHECK-NEXT: quantization: { | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: }, { | ||
// CHECK-NEXT: shape: [ 1, 5 ], | ||
// CHECK-NEXT: buffer: 5, | ||
// CHECK-NEXT: name: "StatefulPartitionedCall:1", | ||
// CHECK-NEXT: quantization: { | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: shape_signature: [ -1, 5 ] | ||
// CHECK-NEXT: } ], | ||
// CHECK-NEXT: inputs: [ 0, 1 ], | ||
// CHECK-NEXT: outputs: [ 4, 4 ], | ||
// CHECK-NEXT: operators: [ { | ||
// CHECK-NEXT: inputs: [ 0, 3, 2 ], | ||
// CHECK-NEXT: outputs: [ 4 ], | ||
// CHECK-NEXT: builtin_options_type: FullyConnectedOptions, | ||
// CHECK-NEXT: builtin_options: { | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: } ], | ||
// CHECK-NEXT: name: "main" | ||
// CHECK-NEXT: } ], | ||
// CHECK-NEXT: description: "MLIR Converted.", | ||
// CHECK-NEXT: buffers: [ { | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: }, { | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: }, { | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: }, { | ||
// CHECK-NEXT: data: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] | ||
// CHECK-NEXT: }, { | ||
// CHECK-NEXT: data: [ 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63 ] | ||
// CHECK-NEXT: }, { | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: }, { | ||
// CHECK-NEXT: data: [ 49, 46, 53, 46, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] | ||
// CHECK-NEXT: } ], | ||
// CHECK-NEXT: metadata: [ { | ||
// CHECK-NEXT: name: "min_runtime_version", | ||
// CHECK-NEXT: buffer: 6 | ||
// CHECK-NEXT: } ], | ||
// CHECK-NEXT: signature_defs: [ { | ||
// CHECK-NEXT: inputs: [ { | ||
// CHECK-NEXT: name: "input1", | ||
// CHECK-NEXT: tensor_index: 1 | ||
// CHECK-NEXT: }, { | ||
// CHECK-NEXT: name: "input2" | ||
// CHECK-NEXT: } ], | ||
// CHECK-NEXT: outputs: [ { | ||
// CHECK-NEXT: name: "end_logits", | ||
// CHECK-NEXT: tensor_index: 4 | ||
// CHECK-NEXT: }, { | ||
// CHECK-NEXT: name: "start_logits", | ||
// CHECK-NEXT: tensor_index: 4 | ||
// CHECK-NEXT: } ], | ||
// CHECK-NEXT: method_name: "serving_default", | ||
// CHECK-NEXT: key: "" | ||
// CHECK-NEXT: } ] | ||
// CHECK-NEXT:} | ||
module attributes {tf.versions = {bad_consumers = [], min_consumer = 12 : i32, producer = 554 : i32}, tf_saved_model.semantics} { | ||
func @main(%arg0: tensor<?x3xf32> {tf_saved_model.index_path = ["input2"]}, %arg1: tensor<?x3xf32> {tf_saved_model.index_path = ["input1"]}) -> (tensor<?x5xf32> {tf_saved_model.index_path = ["start_logits"]}, tensor<?x5xf32> {tf_saved_model.index_path = ["end_logits"]}) attributes {tf.entry_function = {control_outputs = "", inputs = "serving_default_input2:0,serving_default_input1:0", outputs = "StatefulPartitionedCall:1,StatefulPartitionedCall:0"}, tf_saved_model.exported_names = ["serving_default"]} { | ||
%cst = constant dense<0.000000e+00> : tensor<5xf32> | ||
%cst_0 = constant dense<1.0> : tensor<5x3xf32> | ||
%0 = "tfl.fully_connected"(%arg0, %cst_0, %cst) {fused_activation_function = "NONE", keep_num_dims = false, weights_format = "DEFAULT"} : (tensor<?x3xf32>, tensor<5x3xf32>, tensor<5xf32>) -> tensor<?x5xf32> | ||
return %0, %0 : tensor<?x5xf32>, tensor<?x5xf32> | ||
} | ||
} |