-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #942 from xmos/feature/int16-sum
Feature/int16 sum
- Loading branch information
Showing
38 changed files
with
257 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MAX_ABS_ERROR: 1.0 |
Binary file not shown.
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,5 @@ | ||
func.func @main(%arg0: tensor<1x5x8x16x!quant.uniform<i8:f32, 0.0078426999971270561:-1>> {tf_saved_model.index_path = ["input_2"]}) -> (tensor<1x5x1x16x!quant.uniform<i8:f32, 0.0078426999971270561:-1>> {tf_saved_model.index_path = ["tf.mean_1"]}) attributes {tf.entry_function = {inputs = "serving_default_input_2:0", outputs = "PartitionedCall:0"}, tf_saved_model.exported_names = ["serving_default"]} { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<1xi32>, value = dense<2> : tensor<1xi32>} : () -> tensor<1xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = true} : (tensor<1x5x8x16x!quant.uniform<i8:f32, 0.0078426999971270561:-1>>, tensor<1xi32>) -> tensor<1x5x1x16x!quant.uniform<i8:f32, 0.0078426999971270561:-1>> | ||
return %1 : tensor<1x5x1x16x!quant.uniform<i8:f32, 0.0078426999971270561:-1>> | ||
} |
Binary file not shown.
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,6 @@ | ||
// This test reduces the 2nd and 3rd axes of a 4D tensor with consecutive axes and keep_dims = true. | ||
func.func @main(%arg0: tensor<8x5x10x12x!quant.uniform<i8:f32, 0.008:2>>) -> (tensor<8x1x1x12x!quant.uniform<i8:f32, 0.008:2>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<2xi32>, value = dense<[1, 2]> : tensor<2xi32>} : () -> tensor<2xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = true} : (tensor<8x5x10x12x!quant.uniform<i8:f32, 0.008:2>>, tensor<2xi32>) -> tensor<8x1x1x12x!quant.uniform<i8:f32, 0.008:2>> | ||
return %1 : tensor<8x1x1x12x!quant.uniform<i8:f32, 0.008:2>> | ||
} |
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
integration_tests/models/16x8/test_mean/test_mean_10_int16.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,6 @@ | ||
// This test reduces the 2nd and 3rd axes of a 4D tensor with consecutive axes and keep_dims = true. | ||
func.func @main(%arg0: tensor<8x5x10x12x!quant.uniform<i16:f32, 0.008>>) -> (tensor<8x1x1x12x!quant.uniform<i16:f32, 0.008>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<2xi32>, value = dense<[1, 2]> : tensor<2xi32>} : () -> tensor<2xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = true} : (tensor<8x5x10x12x!quant.uniform<i16:f32, 0.008>>, tensor<2xi32>) -> tensor<8x1x1x12x!quant.uniform<i16:f32, 0.008>> | ||
return %1 : tensor<8x1x1x12x!quant.uniform<i16:f32, 0.008>> | ||
} |
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,6 @@ | ||
// This test reduces the 2nd and 3rd axes of a 4D tensor with consecutive axes and keep_dims = true. | ||
func.func @main(%arg0: tensor<8x5x10x12x!quant.uniform<i8:f32, 0.008:2>>) -> (tensor<8x1x1x12x!quant.uniform<i8:f32, 0.008:2>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<2xi32>, value = dense<[1, 2]> : tensor<2xi32>} : () -> tensor<2xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = true} : (tensor<8x5x10x12x!quant.uniform<i8:f32, 0.008:2>>, tensor<2xi32>) -> tensor<8x1x1x12x!quant.uniform<i8:f32, 0.008:2>> | ||
return %1 : tensor<8x1x1x12x!quant.uniform<i8:f32, 0.008:2>> | ||
} |
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
integration_tests/models/16x8/test_mean/test_mean_11_int16.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,6 @@ | ||
// This test reduces the 2nd and 3rd axes of a 4D tensor with consecutive axes and keep_dims = true. | ||
func.func @main(%arg0: tensor<8x5x10x12x!quant.uniform<i16:f32, 0.008>>) -> (tensor<8x1x1x12x!quant.uniform<i16:f32, 0.008>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<2xi32>, value = dense<[1, 2]> : tensor<2xi32>} : () -> tensor<2xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = true} : (tensor<8x5x10x12x!quant.uniform<i16:f32, 0.008>>, tensor<2xi32>) -> tensor<8x1x1x12x!quant.uniform<i16:f32, 0.008>> | ||
return %1 : tensor<8x1x1x12x!quant.uniform<i16:f32, 0.008>> | ||
} |
5 changes: 5 additions & 0 deletions
5
integration_tests/models/16x8/test_mean/test_mean_1_int16.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,5 @@ | ||
func.func @main(%arg0: tensor<1x5x8x16x!quant.uniform<i16:f32, 0.0078426999971270561>> {tf_saved_model.index_path = ["input_2"]}) -> (tensor<1x5x1x16x!quant.uniform<i16:f32, 0.0078426999971270561>> {tf_saved_model.index_path = ["tf.mean_1"]}) attributes {tf.entry_function = {inputs = "serving_default_input_2:0", outputs = "PartitionedCall:0"}, tf_saved_model.exported_names = ["serving_default"]} { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<1xi32>, value = dense<2> : tensor<1xi32>} : () -> tensor<1xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = true} : (tensor<1x5x8x16x!quant.uniform<i16:f32, 0.0078426999971270561>>, tensor<1xi32>) -> tensor<1x5x1x16x!quant.uniform<i16:f32, 0.0078426999971270561>> | ||
return %1 : tensor<1x5x1x16x!quant.uniform<i16:f32, 0.0078426999971270561>> | ||
} |
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,6 @@ | ||
// This test reduces the 3rd axis of a 4D tensor without keeping dimensions. | ||
func.func @main(%arg0: tensor<2x3x4x5x!quant.uniform<i8:f32, 0.005:-128>>) -> (tensor<2x3x5x!quant.uniform<i8:f32, 0.006:-127>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<1xi32>, value = dense<2> : tensor<1xi32>} : () -> tensor<1xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = false} : (tensor<2x3x4x5x!quant.uniform<i8:f32, 0.005:-128>>, tensor<1xi32>) -> tensor<2x3x5x!quant.uniform<i8:f32, 0.006:-127>> | ||
return %1 : tensor<2x3x5x!quant.uniform<i8:f32, 0.006:-127>> | ||
} |
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
integration_tests/models/16x8/test_mean/test_mean_2_int16.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,6 @@ | ||
// This test reduces the 3rd axis of a 4D tensor without keeping dimensions. | ||
func.func @main(%arg0: tensor<2x3x4x5x!quant.uniform<i16:f32, 0.005>>) -> (tensor<2x3x5x!quant.uniform<i16:f32, 0.006>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<1xi32>, value = dense<2> : tensor<1xi32>} : () -> tensor<1xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = false} : (tensor<2x3x4x5x!quant.uniform<i16:f32, 0.005>>, tensor<1xi32>) -> tensor<2x3x5x!quant.uniform<i16:f32, 0.006>> | ||
return %1 : tensor<2x3x5x!quant.uniform<i16:f32, 0.006>> | ||
} |
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,6 @@ | ||
// This test reduces the 2nd and 4th axes of a 5D tensor while keeping dimensions. | ||
func.func @main(%arg0: tensor<4x3x5x7x6x!quant.uniform<i8:f32, 0.0045:0>>) -> (tensor<4x1x5x1x6x!quant.uniform<i8:f32, 0.0045:0>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<2xi32>, value = dense<[1, 3]> : tensor<2xi32>} : () -> tensor<2xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = true} : (tensor<4x3x5x7x6x!quant.uniform<i8:f32, 0.0045:0>>, tensor<2xi32>) -> tensor<4x1x5x1x6x!quant.uniform<i8:f32, 0.0045:0>> | ||
return %1 : tensor<4x1x5x1x6x!quant.uniform<i8:f32, 0.0045:0>> | ||
} |
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
integration_tests/models/16x8/test_mean/test_mean_3_int16.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,6 @@ | ||
// This test reduces the 2nd and 4th axes of a 5D tensor while keeping dimensions. | ||
func.func @main(%arg0: tensor<4x3x5x7x6x!quant.uniform<i16:f32, 0.0045>>) -> (tensor<4x1x5x1x6x!quant.uniform<i16:f32, 0.0045>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<2xi32>, value = dense<[1, 3]> : tensor<2xi32>} : () -> tensor<2xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = true} : (tensor<4x3x5x7x6x!quant.uniform<i16:f32, 0.0045>>, tensor<2xi32>) -> tensor<4x1x5x1x6x!quant.uniform<i16:f32, 0.0045>> | ||
return %1 : tensor<4x1x5x1x6x!quant.uniform<i16:f32, 0.0045>> | ||
} |
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,6 @@ | ||
// This test reduces the 1st axis of a 3D tensor without keeping dimensions. | ||
func.func @main(%arg0: tensor<10x20x30x!quant.uniform<i8:f32, 0.003:-5>>) -> (tensor<20x30x!quant.uniform<i8:f32, 0.003:-5>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<1xi32>, value = dense<0> : tensor<1xi32>} : () -> tensor<1xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = false} : (tensor<10x20x30x!quant.uniform<i8:f32, 0.003:-5>>, tensor<1xi32>) -> tensor<20x30x!quant.uniform<i8:f32, 0.003:-5>> | ||
return %1 : tensor<20x30x!quant.uniform<i8:f32, 0.003:-5>> | ||
} |
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
integration_tests/models/16x8/test_mean/test_mean_4_int16.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,6 @@ | ||
// This test reduces the 1st axis of a 3D tensor without keeping dimensions. | ||
func.func @main(%arg0: tensor<10x20x30x!quant.uniform<i16:f32, 0.003>>) -> (tensor<20x30x!quant.uniform<i16:f32, 0.003>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<1xi32>, value = dense<0> : tensor<1xi32>} : () -> tensor<1xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = false} : (tensor<10x20x30x!quant.uniform<i16:f32, 0.003>>, tensor<1xi32>) -> tensor<20x30x!quant.uniform<i16:f32, 0.003>> | ||
return %1 : tensor<20x30x!quant.uniform<i16:f32, 0.003>> | ||
} |
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,6 @@ | ||
// This test reduces all axes of a 2D tensor while keeping dimensions. | ||
func.func @main(%arg0: tensor<5x7x!quant.uniform<i8:f32, 0.002:-3>>) -> (tensor<1x1x!quant.uniform<i8:f32, 0.002:-3>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<2xi32>, value = dense<[0, 1]> : tensor<2xi32>} : () -> tensor<2xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = true} : (tensor<5x7x!quant.uniform<i8:f32, 0.002:-3>>, tensor<2xi32>) -> tensor<1x1x!quant.uniform<i8:f32, 0.002:-3>> | ||
return %1 : tensor<1x1x!quant.uniform<i8:f32, 0.002:-3>> | ||
} |
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
integration_tests/models/16x8/test_mean/test_mean_5_int16.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,6 @@ | ||
// This test reduces all axes of a 2D tensor while keeping dimensions. | ||
func.func @main(%arg0: tensor<5x7x!quant.uniform<i16:f32, 0.002>>) -> (tensor<1x1x!quant.uniform<i16:f32, 0.002>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<2xi32>, value = dense<[0, 1]> : tensor<2xi32>} : () -> tensor<2xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = true} : (tensor<5x7x!quant.uniform<i16:f32, 0.002>>, tensor<2xi32>) -> tensor<1x1x!quant.uniform<i16:f32, 0.002>> | ||
return %1 : tensor<1x1x!quant.uniform<i16:f32, 0.002>> | ||
} |
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,6 @@ | ||
// This test reduces a 1D tensor to a scalar. | ||
func.func @main(%arg0: tensor<15x!quant.uniform<i8:f32, 0.009:0>>) -> (tensor<!quant.uniform<i8:f32, 0.009:0>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<1xi32>, value = dense<0> : tensor<1xi32>} : () -> tensor<1xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = false} : (tensor<15x!quant.uniform<i8:f32, 0.009:0>>, tensor<1xi32>) -> tensor<!quant.uniform<i8:f32, 0.009:0>> | ||
return %1 : tensor<!quant.uniform<i8:f32, 0.009:0>> | ||
} |
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
integration_tests/models/16x8/test_mean/test_mean_6_int16.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,6 @@ | ||
// This test reduces a 1D tensor to a scalar. | ||
func.func @main(%arg0: tensor<15x!quant.uniform<i16:f32, 0.009>>) -> (tensor<!quant.uniform<i16:f32, 0.009>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<1xi32>, value = dense<0> : tensor<1xi32>} : () -> tensor<1xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = false} : (tensor<15x!quant.uniform<i16:f32, 0.009>>, tensor<1xi32>) -> tensor<!quant.uniform<i16:f32, 0.009>> | ||
return %1 : tensor<!quant.uniform<i16:f32, 0.009>> | ||
} |
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,6 @@ | ||
// This test reduces the 2nd and 3rd axes of a 3D tensor with different input/output quantization parameters. | ||
func.func @main(%arg0: tensor<5x6x7x!quant.uniform<i8:f32, 0.004:-2>>) -> (tensor<5x!quant.uniform<i8:f32, 0.0035:-1>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<2xi32>, value = dense<[1, 2]> : tensor<2xi32>} : () -> tensor<2xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = false} : (tensor<5x6x7x!quant.uniform<i8:f32, 0.004:-2>>, tensor<2xi32>) -> tensor<5x!quant.uniform<i8:f32, 0.0035:-1>> | ||
return %1 : tensor<5x!quant.uniform<i8:f32, 0.0035:-1>> | ||
} |
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
integration_tests/models/16x8/test_mean/test_mean_7_int16.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,6 @@ | ||
// This test reduces the 2nd and 3rd axes of a 3D tensor with different input/output quantization parameters. | ||
func.func @main(%arg0: tensor<5x6x7x!quant.uniform<i16:f32, 0.004>>) -> (tensor<5x!quant.uniform<i16:f32, 0.0035>>) { | ||
%0 = "tfl.pseudo_qconst"() {qtype = tensor<2xi32>, value = dense<[1, 2]> : tensor<2xi32>} : () -> tensor<2xi32> | ||
%1 = "tfl.mean"(%arg0, %0) {keep_dims = false} : (tensor<5x6x7x!quant.uniform<i16:f32, 0.004>>, tensor<2xi32>) -> tensor<5x!quant.uniform<i16:f32, 0.0035>> | ||
return %1 : tensor<5x!quant.uniform<i16:f32, 0.0035>> | ||
} |
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,53 @@ | ||
import os | ||
import re | ||
|
||
|
||
def translate_int8_to_int16_mlir(mlir_code): | ||
""" | ||
Translates MLIR code from using int8 quantization to int16 quantization, removing any zero-point specification. | ||
Args: | ||
mlir_code (str): The original MLIR code string with int8 quantization. | ||
Returns: | ||
str: Translated MLIR code with int16 quantization. | ||
""" | ||
# Step 1: Replace int8 quantization with int16 quantization in tensor types | ||
mlir_code = re.sub( | ||
r"!quant\.uniform<i8:f32, ([^>]+)>", r"!quant.uniform<i16:f32, \1>", mlir_code | ||
) | ||
|
||
# Step 2: Remove any zero-point by eliminating it from the parameter list | ||
mlir_code = re.sub( | ||
r"!quant\.uniform<i16:f32, ([^,:]+):[^>]+>", | ||
r"!quant.uniform<i16:f32, \1>", | ||
mlir_code, | ||
) | ||
|
||
return mlir_code | ||
|
||
|
||
def process_mlir_files_in_directory(): | ||
""" | ||
Processes all .mlir files in the current directory by translating int8 quantization to int16, | ||
and saving the output to a new file with the _int16.mlir suffix. | ||
""" | ||
for filename in os.listdir("."): | ||
if not filename.endswith(".mlir") or filename.endswith("_int16.mlir"): | ||
continue | ||
with open(filename, "r") as file: | ||
mlir_code = file.read() | ||
|
||
# Translate the MLIR code | ||
translated_mlir_code = translate_int8_to_int16_mlir(mlir_code) | ||
|
||
# Save the translated code to a new file | ||
new_filename = f"{os.path.splitext(filename)[0]}_int16.mlir" | ||
with open(new_filename, "w") as new_file: | ||
new_file.write(translated_mlir_code) | ||
print(f"Processed {filename} -> {new_filename}") | ||
|
||
|
||
# Execute the script | ||
if __name__ == "__main__": | ||
process_mlir_files_in_directory() |
Submodule lib_tflite_micro
updated
5 files
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.