From d9fabddf19e134d156585a961df88dcbb0d85495 Mon Sep 17 00:00:00 2001 From: Michael Poluektov Date: Thu, 5 Sep 2024 13:32:17 +0100 Subject: [PATCH 1/7] add concat test --- .../models/8x8/test_concatenate/generate.py | 30 ++++++++++++------ .../test_concatenate_11.tflite | Bin 6320 -> 6320 bytes 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/integration_tests/models/8x8/test_concatenate/generate.py b/integration_tests/models/8x8/test_concatenate/generate.py index 8f23d5256..8396a68fb 100644 --- a/integration_tests/models/8x8/test_concatenate/generate.py +++ b/integration_tests/models/8x8/test_concatenate/generate.py @@ -4,31 +4,44 @@ i = 0 + def generate_concatenate_model(input_shapes, axis): dtype = tf.int8 - input_data = [tf.keras.Input(shape=input_shape, dtype=dtype, batch_size=1) for input_shape in input_shapes] + input_data = [ + tf.keras.Input(shape=input_shape, dtype=dtype, batch_size=1) + for input_shape in input_shapes + ] concatenated_output = tf.concat(input_data, axis=axis) model = tf.keras.Model(inputs=input_data, outputs=concatenated_output) converter = tfl.TFLiteConverter.from_keras_model(model) if dtype == tf.int8 or dtype == tf.int16: + def representative_dataset_gen(): for _ in range(100): - yield [np.random.uniform(low=-127, high=127, size=shp).astype(dtype.as_numpy_dtype) for shp in input_shapes] + yield [ + np.random.uniform(low=-127, high=127, size=shp).astype( + dtype.as_numpy_dtype + ) + for shp in input_shapes + ] + converter.optimizations = [tf.lite.Optimize.DEFAULT] converter.representative_dataset = representative_dataset_gen if dtype == tf.int8: converter.target_spec.supported_ops = [tfl.OpsSet.TFLITE_BUILTINS_INT8] else: - converter.target_spec.supported_ops = [tfl.OpsSet.EXPERIMENTAL_TFLITE_BUILTINS_ACTIVATIONS_INT16_WEIGHTS_INT8] + converter.target_spec.supported_ops = [ + tfl.OpsSet.EXPERIMENTAL_TFLITE_BUILTINS_ACTIVATIONS_INT16_WEIGHTS_INT8 + ] converter.inference_input_type = dtype converter.inference_output_type = dtype tflite_model = converter.convert() global i - model_name = f'test_concatenate_{i}.tflite' - i+=1 - with open(model_name, 'wb') as f: + model_name = f"test_concatenate_{i}.tflite" + i += 1 + with open(model_name, "wb") as f: f.write(tflite_model) - print(f'Model saved: {model_name}') + print(f"Model saved: {model_name}") generate_concatenate_model([(64), (64)], 0) # 0 @@ -42,5 +55,4 @@ def representative_dataset_gen(): generate_concatenate_model([(2, 6, 5, 2)] * 9, 3) # 6 generate_concatenate_model([(2, 6, 5, 2)] * 16, 3) # 6 generate_concatenate_model([(2, 6, 5, 2)] * 33, 3) # 6 -generate_concatenate_model([(2, 6, 5, 2)] * 40, 3) # 6 - +generate_concatenate_model([(2, 6, 5, 1)] * 40, 3) # 6 diff --git a/integration_tests/models/8x8/test_concatenate/test_concatenate_11.tflite b/integration_tests/models/8x8/test_concatenate/test_concatenate_11.tflite index 00feb23c1450fe621d7ae51d6ac89f36c8ff80a7..5afbbd78c99c49b80d5c73a9fda2d690578a8089 100644 GIT binary patch delta 253 zcmW;AD-42A07l^vD9H7JUZohB$v`j~jYel85>3u%G#E^dXtc?83z29v8jVJy(M|qS zzMUPHy42kQ&pVgFy3udR3@bFDPL4HNqqD&~j@vprd|=Yi+2a$ZU7Z8IaMsf~;Tz|X nPJtg>^mQ)y#pOWfia%Ugof7?_I>QRhNGHb{ZM<#HF`oPZoSQ#R delta 253 zcmW;AD-42A07l{IMnSJHyh<@LlYw9~8i~$CB$}MjXfT+Zk!X|c79!DTG#ZUYqnrGv zd^ttA=H98x-UrdHNSN!41>J;dW)G3x|#yS~RXv1xNj^XqVu%JJ8 From 06455b9c65580b417dfbfd1068e58e08c4c8efd3 Mon Sep 17 00:00:00 2001 From: Michael Poluektov Date: Fri, 6 Sep 2024 16:42:13 +0100 Subject: [PATCH 2/7] broadcast tests --- .../8x8/test_broadcast/test_broadcast_6.mlir | 5 +++++ .../8x8/test_broadcast/test_broadcast_6.tflite | Bin 0 -> 944 bytes .../8x8/test_broadcast/test_broadcast_7.mlir | 5 +++++ .../8x8/test_broadcast/test_broadcast_7.tflite | Bin 0 -> 944 bytes 4 files changed, 10 insertions(+) create mode 100644 integration_tests/models/8x8/test_broadcast/test_broadcast_6.mlir create mode 100644 integration_tests/models/8x8/test_broadcast/test_broadcast_6.tflite create mode 100644 integration_tests/models/8x8/test_broadcast/test_broadcast_7.mlir create mode 100644 integration_tests/models/8x8/test_broadcast/test_broadcast_7.tflite diff --git a/integration_tests/models/8x8/test_broadcast/test_broadcast_6.mlir b/integration_tests/models/8x8/test_broadcast/test_broadcast_6.mlir new file mode 100644 index 000000000..9a6895723 --- /dev/null +++ b/integration_tests/models/8x8/test_broadcast/test_broadcast_6.mlir @@ -0,0 +1,5 @@ +func.func @main(%arg0: tensor<1x127x1x1x!quant.uniform> {tf_saved_model.index_path = ["input_2"]}) -> (tensor<1x127x127x1x!quant.uniform> {tf_saved_model.index_path = ["tf.broadcast_to_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<4xi32>, value = dense<[1, 127, 127, 1]> : tensor<4xi32>} : () -> tensor<4xi32> + %1 = "tfl.broadcast_to"(%arg0, %0) : (tensor<1x127x1x1x!quant.uniform>, tensor<4xi32>) -> tensor<1x127x127x1x!quant.uniform> + return %1 : tensor<1x127x127x1x!quant.uniform> +} diff --git a/integration_tests/models/8x8/test_broadcast/test_broadcast_6.tflite b/integration_tests/models/8x8/test_broadcast/test_broadcast_6.tflite new file mode 100644 index 0000000000000000000000000000000000000000..9e4f538a4ad68778bcc9a3009bae42b533008e4c GIT binary patch literal 944 zcmZXT&q^FY5XNicxUO+AhKLy0!ya<*Ad4CT5zzR{4c}CCb=Oy4SNC+x?9>8o(}TQ-KORLzJb0aF!{ku0FBJ#1zuM<-!S8vt8hxn;ePE!G zI2NE4rPKh_d?JjJEG#COOGa^c5*Onn&+J!KhaPS9Ui7F}5Bl=H|L#LqseIm8sBnqX$<^y9OYX)B{ZPoS z|2*S)HpLz2JLNzxxp#T4m8DZR;6guI@YzRg?6hA^Z}ob#-V$g1M`(jy(h5drs&n9Z lBRm!Ez1^^SbN`)> {tf_saved_model.index_path = ["input_2"]}) -> (tensor<1x127x127x2x!quant.uniform> {tf_saved_model.index_path = ["tf.broadcast_to_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<4xi32>, value = dense<[1, 127, 127, 2]> : tensor<4xi32>} : () -> tensor<4xi32> + %1 = "tfl.broadcast_to"(%arg0, %0) : (tensor<1x127x1x2x!quant.uniform>, tensor<4xi32>) -> tensor<1x127x127x2x!quant.uniform> + return %1 : tensor<1x127x127x2x!quant.uniform> +} diff --git a/integration_tests/models/8x8/test_broadcast/test_broadcast_7.tflite b/integration_tests/models/8x8/test_broadcast/test_broadcast_7.tflite new file mode 100644 index 0000000000000000000000000000000000000000..e5e87e7865d7b47307edbae15ea07a49c733cb8d GIT binary patch literal 944 zcmZXS&uSDw5XNhDvPpEw9}?mUd)R}A9KsSKLXe!I2*L`Yo^r@IW@eLt*_klg8*)lO z#23g5c=r`Nc^03*2kYM8Bnc4f7!zb(3x4;&xV=K0&f?p zWnq$(XK8*M#>ps}X3p262Ocz_klF>sYN^Ot1+xS~m?9U5n zemZsGj;}e@n*7(Qs^FOu;5a`j%H-WiR3`EBA|Iv4${o}k^xm+;tN6k47lp=L8eORb9XYh1Dzs8u$>*1@neW}uUm&5~Q zmUKtgH@2kAuCOKa1!hJ+Fpkn(&TE1fZOjgjp?On_-||Bex*6^ncJ2sG@HBPQVyt;D z_q`8%%_la@F5%qQe9abHn~GU81Nt-TH&N+Qr$5)Mqbz$yzUgtP7|`dDIJ!6XwDhKw z@Bi(B=h+r_pzn+Wy=c41^Gj7?Y{3ODT8KGEZ~SatZST45u1>Z6A2LmBURi9h)zrZA mLU<_Ldb?r$=KlLPdZD4?Cq`dh%JrSGU;k!B%s&P?g}#4d@OK6P literal 0 HcmV?d00001 From 7380c180a25e6a9c92f93c333b8c608186f968ee Mon Sep 17 00:00:00 2001 From: Michael Poluektov Date: Fri, 6 Sep 2024 16:44:01 +0100 Subject: [PATCH 3/7] third party --- third_party/lib_nn | 2 +- third_party/lib_tflite_micro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/lib_nn b/third_party/lib_nn index 435469856..2ea56e00f 160000 --- a/third_party/lib_nn +++ b/third_party/lib_nn @@ -1 +1 @@ -Subproject commit 4354698561b399ec9f121c1774812c6d746568e5 +Subproject commit 2ea56e00f73017947d6bf40d74ad482909786481 diff --git a/third_party/lib_tflite_micro b/third_party/lib_tflite_micro index 4a55f5910..45f8b4ea8 160000 --- a/third_party/lib_tflite_micro +++ b/third_party/lib_tflite_micro @@ -1 +1 @@ -Subproject commit 4a55f5910b0e09da297a9193feed5311df4e851c +Subproject commit 45f8b4ea86583ced8c841b210495703ab8922cf2 From 9546d1290d2e76c437a80a4b8942954a8a18a34c Mon Sep 17 00:00:00 2001 From: Michael Poluektov Date: Fri, 6 Sep 2024 16:44:50 +0100 Subject: [PATCH 4/7] update third_party --- third_party/lib_tflite_micro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/lib_tflite_micro b/third_party/lib_tflite_micro index 45f8b4ea8..dab8306f1 160000 --- a/third_party/lib_tflite_micro +++ b/third_party/lib_tflite_micro @@ -1 +1 @@ -Subproject commit 45f8b4ea86583ced8c841b210495703ab8922cf2 +Subproject commit dab8306f12f74424c0e06e2c24861d4a151d9420 From 149c165ea493e88e7072b2da9713ec450095dd33 Mon Sep 17 00:00:00 2001 From: Michael Poluektov Date: Wed, 11 Sep 2024 11:28:55 +0100 Subject: [PATCH 5/7] multithread --- third_party/lib_tflite_micro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/lib_tflite_micro b/third_party/lib_tflite_micro index dab8306f1..a0aebee84 160000 --- a/third_party/lib_tflite_micro +++ b/third_party/lib_tflite_micro @@ -1 +1 @@ -Subproject commit dab8306f12f74424c0e06e2c24861d4a151d9420 +Subproject commit a0aebee84909140d8d881f29e6cea48ec8d7188b From 7ae2d6c8ce66963e7fac86f08d8a5a2268feae53 Mon Sep 17 00:00:00 2001 From: Michael Poluektov Date: Wed, 11 Sep 2024 11:32:59 +0100 Subject: [PATCH 6/7] concat device test --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 8017e00f2..3ff85e485 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,6 +18,8 @@ def dailyDeviceTest = { sh "pytest examples/app_mobilenetv2" } runPytestDevice("8x8/test_broadcast", "-n 1 --tc 1", "broadcast_1") + runPytestDevice("8x8/test_concatenate", "-n 1 --tc 1", "concat_1") + runPytestDevice("8x8/test_concatenate", "-n 1 --tc 5", "concat_5") runPytestDevice("8x8/test_mean", "-n 1 --tc 1", "mean_1") runPytestDevice("8x8/test_lstm", "-n 1 --tc 1", "lstm_1") runPytestDevice("8x8/test_lstm", "-n 1", "lstm_5") From dbd9ffff62d37ab2b2edc6b2a0348c661788d99e Mon Sep 17 00:00:00 2001 From: panickal-xmos Date: Wed, 11 Sep 2024 22:07:11 +0100 Subject: [PATCH 7/7] Update submodule --- third_party/lib_nn | 2 +- third_party/lib_tflite_micro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/lib_nn b/third_party/lib_nn index 2ea56e00f..07438c2e0 160000 --- a/third_party/lib_nn +++ b/third_party/lib_nn @@ -1 +1 @@ -Subproject commit 2ea56e00f73017947d6bf40d74ad482909786481 +Subproject commit 07438c2e0becde869c52f0d66394e3103780db04 diff --git a/third_party/lib_tflite_micro b/third_party/lib_tflite_micro index a0aebee84..103945fea 160000 --- a/third_party/lib_tflite_micro +++ b/third_party/lib_tflite_micro @@ -1 +1 @@ -Subproject commit a0aebee84909140d8d881f29e6cea48ec8d7188b +Subproject commit 103945fea9a3cc5630414c9e5fd39863f43a40c6