From 365085319ff97d3fa9e24cc66ed1cd32cea1f620 Mon Sep 17 00:00:00 2001 From: Wanli Date: Wed, 17 Apr 2024 23:38:16 +0800 Subject: [PATCH 1/3] change fcn8s-heavy-pascal tests from caffe to onnx --- testdata/dnn/download_models.py | 5 +++++ testdata/dnn/segmentation_exp.png | Bin 593 -> 519 bytes 2 files changed, 5 insertions(+) diff --git a/testdata/dnn/download_models.py b/testdata/dnn/download_models.py index 246f21bd2..f1d6e205a 100755 --- a/testdata/dnn/download_models.py +++ b/testdata/dnn/download_models.py @@ -262,6 +262,11 @@ def is_archive(self): url='http://dl.caffe.berkeleyvision.org/fcn8s-heavy-pascal.caffemodel', sha='c449ea74dd7d83751d1357d6a8c323fcf4038962', filename='fcn8s-heavy-pascal.caffemodel'), + Model( + name='Fcn', + url='https://github.com/onnx/models/raw/491ce05590abb7551d7fae43c067c060eeb575a6/validated/vision/object_detection_segmentation/fcn/model/fcn-resnet50-12.onnx', + sha='1bb0c7e0034038969aecc6251166f1612a139230', + filename='onnx/models/fcn-resnet50-12.onnx'), Model( name='Ssd_vgg16', url='https://www.dropbox.com/s/8apyk3uzk2vl522/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel?dl=1', diff --git a/testdata/dnn/segmentation_exp.png b/testdata/dnn/segmentation_exp.png index d69d5ca605ab1093f3aaf402d6440a8d5ce8c644..0a99edec11dbd90a06b9d0467069138f986f4149 100644 GIT binary patch literal 519 zcmeAS@N?(olHy`uVBq!ia0vp^4Is<`Bp9BB+KDqTFrM>taSW+oJbKWvOU6^c_2BoK z$=~hs^5!sd@~&OiF-ctVtodXEPMqkoUf!`MTe|J@*q&_YUZ3~Rm2dZt(`W5ZB#Pg^ zvqv>OcF(R#=X1LvcHW${Snpb1*^?FBy|Z~OUnadz^X%JoV^`#)!+K_U(|{%{oo#CQ z{?XO5ZGRfN#m%KZHS7J`adYDQ(vPRl_Wjwyz2oL2Jgxvr?ObH(_pIxgg`{@Iw66QJ z&Yz56JnQt)^|Pd;_JT-_eVNZv)-oUZ;!p}}Q6S_HQPu8+0 z8`ZW<*Za|Y)N=|&sTH}=74 Vwv7j~oIikK*wfX|Wt~$(696G3=34*& literal 593 zcmeAS@N?(olHy`uVBq!ia0vp^4Is<`Bp9BB+KDqTFiCj2IEGX(9zDodwunK%<>39= z|Hj{MubId&%YgaSY%N0{9^u1B3`nLv3bHx1|KM?cA#m7b@?rN5zR#*PO&T-v9}2r1 z{KFxy&^I&m2SeeBoYwEc?PtO&>-7I*|FXW6{Mam&+<&MyvNanh&t;w_ zx=zsav%;O3p*vhmX6!9UH#;P{=-`{y)|*_2w;7zq!6r From 723bdf221b56e5852d27cdfe4efb71d08bafb2fe Mon Sep 17 00:00:00 2001 From: CNOCycle <24318472+CNOCycle@users.noreply.github.com> Date: Thu, 16 May 2024 01:06:33 +0800 Subject: [PATCH 2/3] Merge pull request #1168 from CNOCycle:tflite/transpose * Refine data transpose when generating testing data for tflite models * Add test cases for tflite models * Add more test cases for permutation op in tflite model * Update testing data for permutation op in tflite model --- testdata/dnn/tflite/generate.py | 67 +++++++++++++++++- testdata/dnn/tflite/permutation_3d.tflite | Bin 0 -> 784 bytes testdata/dnn/tflite/permutation_3d_inp.npy | Bin 0 -> 152 bytes .../tflite/permutation_3d_out_Identity.npy | Bin 0 -> 152 bytes .../dnn/tflite/permutation_4d_0132.tflite | Bin 0 -> 1236 bytes .../dnn/tflite/permutation_4d_0132_inp.npy | Bin 0 -> 224 bytes .../permutation_4d_0132_out_Identity.npy | Bin 0 -> 224 bytes .../dnn/tflite/permutation_4d_0213.tflite | Bin 0 -> 1248 bytes .../dnn/tflite/permutation_4d_0213_inp.npy | Bin 0 -> 224 bytes .../permutation_4d_0213_out_Identity.npy | Bin 0 -> 200 bytes .../dnn/tflite/permutation_4d_0231.tflite | Bin 0 -> 1224 bytes .../dnn/tflite/permutation_4d_0231_inp.npy | Bin 0 -> 224 bytes .../permutation_4d_0231_out_Identity.npy | Bin 0 -> 272 bytes 13 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 testdata/dnn/tflite/permutation_3d.tflite create mode 100644 testdata/dnn/tflite/permutation_3d_inp.npy create mode 100644 testdata/dnn/tflite/permutation_3d_out_Identity.npy create mode 100644 testdata/dnn/tflite/permutation_4d_0132.tflite create mode 100644 testdata/dnn/tflite/permutation_4d_0132_inp.npy create mode 100644 testdata/dnn/tflite/permutation_4d_0132_out_Identity.npy create mode 100644 testdata/dnn/tflite/permutation_4d_0213.tflite create mode 100644 testdata/dnn/tflite/permutation_4d_0213_inp.npy create mode 100644 testdata/dnn/tflite/permutation_4d_0213_out_Identity.npy create mode 100644 testdata/dnn/tflite/permutation_4d_0231.tflite create mode 100644 testdata/dnn/tflite/permutation_4d_0231_inp.npy create mode 100644 testdata/dnn/tflite/permutation_4d_0231_out_Identity.npy diff --git a/testdata/dnn/tflite/generate.py b/testdata/dnn/tflite/generate.py index 54d6acddf..ec06d8258 100644 --- a/testdata/dnn/tflite/generate.py +++ b/testdata/dnn/tflite/generate.py @@ -58,9 +58,14 @@ def save_tflite_model(model, inp, name): out = model(inp) out = np.array(out) - if len(inp.shape) == 4: + # convert NHWC to NCHW format + if inp.ndim == 4: inp = inp.transpose(0, 3, 1, 2) + inp = np.copy(inp, order='C').astype(inp.dtype) + + if out.ndim == 4: out = out.transpose(0, 3, 1, 2) + out = np.copy(out, order='C').astype(out.dtype) np.save(f'{name}_inp.npy', inp) np.save(f'{name}_out_Identity.npy', out) @@ -102,3 +107,63 @@ def split(x): inp = np.random.standard_normal((1, 2)).astype(np.float32) save_tflite_model(fully_connected, inp, 'fully_connected') + +permutation_3d = tf.keras.models.Sequential([ + tf.keras.layers.Permute((2,1)) +]) + +permutation_3d = tf.function( + permutation_3d.call, + input_signature=[tf.TensorSpec((1,2,3), tf.float32)], +) +inp = np.random.standard_normal((1, 2, 3)).astype(np.float32) +save_tflite_model(permutation_3d, inp, 'permutation_3d') + +# Temporarily disabled as TFLiteConverter produces a incorrect graph in this case +#permutation_4d_0123 = tf.keras.models.Sequential([ +# tf.keras.layers.Permute((1,2,3)), +# tf.keras.layers.Conv2D(3,1) +#]) +# +#permutation_4d_0123 = tf.function( +# permutation_4d_0123.call, +# input_signature=[tf.TensorSpec((1,2,3,4), tf.float32)], +#) +#inp = np.random.standard_normal((1, 2, 3, 4)).astype(np.float32) +#save_tflite_model(permutation_4d_0123, inp, 'permutation_4d_0123') + +permutation_4d_0132 = tf.keras.models.Sequential([ + tf.keras.layers.Permute((1,3,2)), + tf.keras.layers.Conv2D(3,1) +]) + +permutation_4d_0132 = tf.function( + permutation_4d_0132.call, + input_signature=[tf.TensorSpec((1,2,3,4), tf.float32)], +) +inp = np.random.standard_normal((1, 2, 3, 4)).astype(np.float32) +save_tflite_model(permutation_4d_0132, inp, 'permutation_4d_0132') + +permutation_4d_0213 = tf.keras.models.Sequential([ + tf.keras.layers.Permute((2,1,3)), + tf.keras.layers.Conv2D(3,1) +]) + +permutation_4d_0213 = tf.function( + permutation_4d_0213.call, + input_signature=[tf.TensorSpec((1,2,3,4), tf.float32)], +) +inp = np.random.standard_normal((1, 2, 3, 4)).astype(np.float32) +save_tflite_model(permutation_4d_0213, inp, 'permutation_4d_0213') + +permutation_4d_0231 = tf.keras.models.Sequential([ + tf.keras.layers.Permute((2,3,1)), + tf.keras.layers.Conv2D(3,1) +]) + +permutation_4d_0231 = tf.function( + permutation_4d_0231.call, + input_signature=[tf.TensorSpec((1,2,3,4), tf.float32)], +) +inp = np.random.standard_normal((1, 2, 3, 4)).astype(np.float32) +save_tflite_model(permutation_4d_0231, inp, 'permutation_4d_0231') diff --git a/testdata/dnn/tflite/permutation_3d.tflite b/testdata/dnn/tflite/permutation_3d.tflite new file mode 100644 index 0000000000000000000000000000000000000000..597c40baba1b4b5e961613a7e962a28fcdea30a8 GIT binary patch literal 784 zcmZWnJx>Bb5FHSeAVCs|QczHk&>f;^PXH4VzJeDk6GFlouDFHV9V9l^78aKN1b=`f zKgIY{Jm1?pFwwcZ%-q}Aw==U_5)u2RcUh3Kl%yyH$x9YoT2hDwT!a9=kq~JEo21Ad z{%HuM0i=M>FbwzO_yoQ+9Ncxrx831j((l;KcGGS`H*2)haUSDNgtO>vAgVXF)6Ijc00IT}K^^8smN6ZY&wyYb?1AgdyRhn4 z*15=6tWT}Fbxmq#^Y1YHtIZl{)WV451v#(4G2(u&J1(~t8hr(7W|{Q@c#+(0;;bhJ zhCFB914aP*V{Pu#(QsxjYZ6qyy(jj;dGeoUvj&33|1C#PW6zxHJwWXT^a_`tF2VI8 zFal5A?o8ogf=7gAjXK-8iJY2ua~4mPIUqoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-ItoTQ3dWi`3bhL40WOgfi|o!GKeR74aPPh;`E%^Ae_m)8vMFRg0GhHX AA^-pY literal 0 HcmV?d00001 diff --git a/testdata/dnn/tflite/permutation_3d_out_Identity.npy b/testdata/dnn/tflite/permutation_3d_out_Identity.npy new file mode 100644 index 0000000000000000000000000000000000000000..ae4e45c6e895b81c6e758a114fea4e95fa13f1f2 GIT binary patch literal 152 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+l>qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-Its=*3Pzeb3bhL40WOgfi|nT4&#^yy{LsGZpBLK22JYP#vMFRg0G6>S AA^-pY literal 0 HcmV?d00001 diff --git a/testdata/dnn/tflite/permutation_4d_0132.tflite b/testdata/dnn/tflite/permutation_4d_0132.tflite new file mode 100644 index 0000000000000000000000000000000000000000..d6fed63acc09f1ce2e23657dc8c3b6deb5e61c17 GIT binary patch literal 1236 zcmZuxOKTHR6h3KV8{3!$3>u_L1feb@G4Vn1RbyK*&^8i7wqfjybiho)%tR5vx)59$O(X?HExY#GgGhV7VbOOE3{i}%t%AM!U~8`uKg0UH3{&Es9}b-<53 z6}^!LcL5NYP}~G0>iTO+Wy@TrKrkof!+YwL^2KZU%OdXs|MXSNUndo<9|xZI6Zkr$ z!%Ku5`TG^zF^<=j&D-vW=e@-DxBG8yo?Ym_Z1na9o4td>a|=7?2Y0ql+~|$Q%AAJR z{J`^W0W%<1S1PsKV%tK^Ttm;RcQZ;k6?K#OrNEJAKfeIGz#hO{TbgNMQ@MArhxTWJ zX_yY|b5ufV7x8t80#B%1T4q#jSwnI@FEQ@N0M?c7u(qL%-zUHBoCThF7wSP&cA*d7 z&hN`E4tIe+&|xkQ0NTAe^gL`a_K9E*v%m&;zERN)44C@@qSB|&u-}Yvf5e`#=YUV( zInN!#ZgpLwSt_`;W;vap;tZ~lX@`uvsq>;JqN19Oe5kKZTL>U3S_-@Y); aa2|4j+(&%mvBr~lWm<`GH9vDombt$J`K@>W literal 0 HcmV?d00001 diff --git a/testdata/dnn/tflite/permutation_4d_0132_inp.npy b/testdata/dnn/tflite/permutation_4d_0132_inp.npy new file mode 100644 index 0000000000000000000000000000000000000000..8ccfe49b4cf5e8f156f69eaf6a8054092a816dec GIT binary patch literal 224 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+l>qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-ItnH_3Pw5##+o_`wF+bauKi|@_wZVU?>A(T-~UMQy}e~vkG*>R54&}* zn(Yktl-n-8kiG9wkf}X~^KyGtFZ=x`qC57VezL;$UIO3#cis!^8W_s=P5b`K-k!~U a|Iw7#eXcy_w$9zf`?>rW_n&&rc>n-Axkz;Y literal 0 HcmV?d00001 diff --git a/testdata/dnn/tflite/permutation_4d_0132_out_Identity.npy b/testdata/dnn/tflite/permutation_4d_0132_out_Identity.npy new file mode 100644 index 0000000000000000000000000000000000000000..af8364f43261831c5742675f8b62b3e38a5791b5 GIT binary patch literal 224 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+l>qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-Its=*3Pw5#CYm}5wF+baF20^hd!AQQY>M9&TFx(!urtx@-2e1#(|)y+ zZTt2M)Z2I0EVuvkYmJ?NllHy~bJp$a@NeGtmua)DLe+`=O{V|t-Pvc@EPl7m?(Xf_ aeb+qY_qQHcW8ctx!9L{Zn*EiBEbRfiDol$2 literal 0 HcmV?d00001 diff --git a/testdata/dnn/tflite/permutation_4d_0213.tflite b/testdata/dnn/tflite/permutation_4d_0213.tflite new file mode 100644 index 0000000000000000000000000000000000000000..4f97acf142174f11cf59d55d996a6a6259d680be GIT binary patch literal 1248 zcmZuxO=}ZT6uoIAca;ciA`0yFrn#(7-*Z2h9V+_F&XKAnS_~%s1y}( z(WQ$DF6vf9y2!#s7bO9~oj<^Z|G_R?h^XT^ZzeIMzHsvHJMX^xokT^Xcw=pTTw)TH zNg0=jguo3;5VC;t;9%bmh#UYrL6Je6xdwnM04VwDy6&(qpT)kM+t^wyY-V#CrS;Wf zW+hY1z-~y{rrzlu-Kt@htcK|rRlW2;w``+k${E~G!Cw>*;1Jtu;3cpNYyw+BEI z_y92Ps%DtjRQz@9o%iSc$r$zD$Ebu9XYh520#B%7M8;H|Sx>)hya-S}1+X6U)2R>N zcs=uaz`5X=`W-!p>RrbMcP{p*iNhlB12S{D3Gm&MKdy@{5WyEg-AP~@Jbh#CG&`dyv#Crwe9{0UD8 zu)c(+D+8=&2=l^N|KlS;4p-g!+=DKUoje&k`7lA+m|N+nUywaS)e8QR_ZdajqoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-ItnH_3Pw5##+o_`wF+bauA~2#?YCV$!Cw5%1Y4boIs3e(U)y`)f8YKy zpBwUf7(fB cuePtX(cjN;n$7N!({j6O5t94gv&-xS0J9NH{r~^~ literal 0 HcmV?d00001 diff --git a/testdata/dnn/tflite/permutation_4d_0213_out_Identity.npy b/testdata/dnn/tflite/permutation_4d_0213_out_Identity.npy new file mode 100644 index 0000000000000000000000000000000000000000..e1c6621d6b1e4db226ead0ec04a12736c473a453 GIT binary patch literal 200 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+l>qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-Its>MWTdI1P^&-&;BwDeyx;XI`~Evi3+xn9%ndZF7=%}2@)+_opDac{t17WfAF1F#Rg0``DifPSyTFZTuz z$DZ%|D1f^Fh>UA)91?ZoHKDU*t`i`b6Z7Fc^(v)>tEDRX;qoC^DmeKWCGP(iA3qCKfWRFTt3xMp#b+bHP|o@KGj5MaIiF51`9q znkQptU+;qFOzdDBDo%5;%(NnKkdx9~(9kM}g8R&s$JbfFtTsyEFr(9RIvt|3P zz5P(tI%Qu4?XJJ0psH=sKJ(_k2CL6scD#<~%@~+#R)69?xn8Fm2LJoQcxW@7hhifC VM0~L?88zT#5qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-ItnH_3Pw5##+o_`wF+bau1}sf_n(N}vj0}vr~L^zcJ`YXIQRe9;<5kP ztw(k<7aZBE_b=S;%Z2iNUni8=$FEhjJGw&Df$^-h{qBq~yFUdn`{idbJ6xG9uy2() b%l`9miu;fJZQZ9L@xZR{`jvgnTgB`F*f36v literal 0 HcmV?d00001 diff --git a/testdata/dnn/tflite/permutation_4d_0231_out_Identity.npy b/testdata/dnn/tflite/permutation_4d_0231_out_Identity.npy new file mode 100644 index 0000000000000000000000000000000000000000..c107fb7abc1d3f71ab11c8de4e6d14b65472800b GIT binary patch literal 272 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+l>qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-Its>MWTL5~P^&-&;PQ}ovwy?V?{*w=N)GqTh4#N?*t`Emn)tpq9{Tn_ zzNziko%eS?LsFcbWlXl65&ztMFSZx&cS`ZI`<1-M{>1hbd#f&f-QSlRY5%xe-{F9G z%l=Y(%>xETd+dHF_u4MLzQ}Ho0O$UBkM7udZjG=nn73umX~Wt3MdL*6wX$B=_rKBD W|4QQ8{_Rr>?c6HaZ9l)svjYJ7A7Xs~ literal 0 HcmV?d00001 From dd1fbd0717ef4d83f86899b4144fdd9bc0364a5f Mon Sep 17 00:00:00 2001 From: CNOCycle <24318472+CNOCycle@users.noreply.github.com> Date: Sat, 1 Jun 2024 00:30:15 +0800 Subject: [PATCH 3/3] Merge pull request #1180 from CNOCycle:tflite/ops * Simpify generating permutation testes for tflite * Simpify converting keras into TF for tflite tests * Add global_pool_2d tests for tflite models --- testdata/dnn/tflite/generate.py | 90 +++++++----------- .../tflite/global_average_pooling_2d.tflite | Bin 0 -> 1272 bytes .../tflite/global_average_pooling_2d_inp.npy | Bin 0 -> 1108 bytes ...global_average_pooling_2d_out_Identity.npy | Bin 0 -> 148 bytes .../dnn/tflite/global_max_pooling_2d.tflite | Bin 0 -> 1284 bytes .../dnn/tflite/global_max_pooling_2d_inp.npy | Bin 0 -> 1108 bytes .../global_max_pooling_2d_out_Identity.npy | Bin 0 -> 148 bytes 7 files changed, 35 insertions(+), 55 deletions(-) create mode 100644 testdata/dnn/tflite/global_average_pooling_2d.tflite create mode 100644 testdata/dnn/tflite/global_average_pooling_2d_inp.npy create mode 100644 testdata/dnn/tflite/global_average_pooling_2d_out_Identity.npy create mode 100644 testdata/dnn/tflite/global_max_pooling_2d.tflite create mode 100644 testdata/dnn/tflite/global_max_pooling_2d_inp.npy create mode 100644 testdata/dnn/tflite/global_max_pooling_2d_out_Identity.npy diff --git a/testdata/dnn/tflite/generate.py b/testdata/dnn/tflite/generate.py index ec06d8258..31f0e0a09 100644 --- a/testdata/dnn/tflite/generate.py +++ b/testdata/dnn/tflite/generate.py @@ -93,6 +93,14 @@ def split(x): inp = np.random.standard_normal((1, 3)).astype(np.float32) save_tflite_model(split, inp, 'split') +def keras_to_tf(model, input_shape): + tf_func = tf.function( + model.call, + input_signature=[tf.TensorSpec(input_shape, tf.float32)], + ) + inp = np.random.standard_normal((input_shape)).astype(np.float32) + + return tf_func, inp fully_connected = tf.keras.models.Sequential([ tf.keras.layers.Dense(3), @@ -100,70 +108,42 @@ def split(x): tf.keras.layers.Softmax(), ]) -fully_connected = tf.function( - fully_connected.call, - input_signature=[tf.TensorSpec((1,2), tf.float32)], -) - -inp = np.random.standard_normal((1, 2)).astype(np.float32) +fully_connected, inp = keras_to_tf(fully_connected, (1, 2)) save_tflite_model(fully_connected, inp, 'fully_connected') permutation_3d = tf.keras.models.Sequential([ - tf.keras.layers.Permute((2,1)) + tf.keras.layers.Permute((2, 1)) ]) -permutation_3d = tf.function( - permutation_3d.call, - input_signature=[tf.TensorSpec((1,2,3), tf.float32)], -) -inp = np.random.standard_normal((1, 2, 3)).astype(np.float32) +permutation_3d, inp = keras_to_tf(permutation_3d, (1, 2, 3)) save_tflite_model(permutation_3d, inp, 'permutation_3d') -# Temporarily disabled as TFLiteConverter produces a incorrect graph in this case -#permutation_4d_0123 = tf.keras.models.Sequential([ -# tf.keras.layers.Permute((1,2,3)), -# tf.keras.layers.Conv2D(3,1) -#]) -# -#permutation_4d_0123 = tf.function( -# permutation_4d_0123.call, -# input_signature=[tf.TensorSpec((1,2,3,4), tf.float32)], -#) -#inp = np.random.standard_normal((1, 2, 3, 4)).astype(np.float32) -#save_tflite_model(permutation_4d_0123, inp, 'permutation_4d_0123') - -permutation_4d_0132 = tf.keras.models.Sequential([ - tf.keras.layers.Permute((1,3,2)), - tf.keras.layers.Conv2D(3,1) -]) - -permutation_4d_0132 = tf.function( - permutation_4d_0132.call, - input_signature=[tf.TensorSpec((1,2,3,4), tf.float32)], -) -inp = np.random.standard_normal((1, 2, 3, 4)).astype(np.float32) -save_tflite_model(permutation_4d_0132, inp, 'permutation_4d_0132') - -permutation_4d_0213 = tf.keras.models.Sequential([ - tf.keras.layers.Permute((2,1,3)), - tf.keras.layers.Conv2D(3,1) +# (1, 2, 3) is temporarily disabled as TFLiteConverter produces a incorrect graph in this case +permutation_4d_list = [(1, 3, 2), (2, 1, 3), (2, 3, 1)] +for perm_axis in permutation_4d_list: + permutation_4d_model = tf.keras.models.Sequential([ + tf.keras.layers.Permute(perm_axis), + tf.keras.layers.Conv2D(3, 1) + ]) + + permutation_4d_model, inp = keras_to_tf(permutation_4d_model, (1, 2, 3, 4)) + model_name = f"permutation_4d_0{''.join(map(str, perm_axis))}" + save_tflite_model(permutation_4d_model, inp, model_name) + +global_average_pooling_2d = tf.keras.models.Sequential([ + tf.keras.layers.GlobalAveragePooling2D(keepdims=True), + tf.keras.layers.ZeroPadding2D(1), + tf.keras.layers.GlobalAveragePooling2D(keepdims=False) ]) -permutation_4d_0213 = tf.function( - permutation_4d_0213.call, - input_signature=[tf.TensorSpec((1,2,3,4), tf.float32)], -) -inp = np.random.standard_normal((1, 2, 3, 4)).astype(np.float32) -save_tflite_model(permutation_4d_0213, inp, 'permutation_4d_0213') +global_average_pooling_2d, inp = keras_to_tf(global_average_pooling_2d, (1, 7, 7, 5)) +save_tflite_model(global_average_pooling_2d, inp, 'global_average_pooling_2d') -permutation_4d_0231 = tf.keras.models.Sequential([ - tf.keras.layers.Permute((2,3,1)), - tf.keras.layers.Conv2D(3,1) +global_max_pool = tf.keras.models.Sequential([ + tf.keras.layers.GlobalMaxPool2D(keepdims=True), + tf.keras.layers.ZeroPadding2D(1), + tf.keras.layers.GlobalMaxPool2D(keepdims=True) ]) -permutation_4d_0231 = tf.function( - permutation_4d_0231.call, - input_signature=[tf.TensorSpec((1,2,3,4), tf.float32)], -) -inp = np.random.standard_normal((1, 2, 3, 4)).astype(np.float32) -save_tflite_model(permutation_4d_0231, inp, 'permutation_4d_0231') +global_max_pool, inp = keras_to_tf(global_max_pool, (1, 7, 7, 5)) +save_tflite_model(global_max_pool, inp, 'global_max_pooling_2d') diff --git a/testdata/dnn/tflite/global_average_pooling_2d.tflite b/testdata/dnn/tflite/global_average_pooling_2d.tflite new file mode 100644 index 0000000000000000000000000000000000000000..0ac15d77a129297adf92e5a410b638d02efadbcc GIT binary patch literal 1272 zcmaJ>zfTik7=BwSAU2f z*5S9Pd{b{?NVntpR=4j*UdOdwy4{`^_;MZRm%tC;GcW+&18;yM-~eFUJ;bFn0iAm( zi!lxEE+8_lxN+>LtJjpOmbFfSU`?!t=hR!NE7nH;CZVbi4L78@pO}kHtJ^j;; zJta^3GX8nHQu{f@ONEko>t0Q$-s2%hyL2WzrN1;c?NiU`D;}N$XE;9w9s!L1;&&WF zvY1*|@{1q`h*^QW+LKz+ zp`Pk3Ye{49E2D1$r@(bJ25aW53hJk4=lNkj>iz8tzaK<;R}G~va)F!{u*X^`s{6)m LL46yTGuGlCPA|1N literal 0 HcmV?d00001 diff --git a/testdata/dnn/tflite/global_average_pooling_2d_inp.npy b/testdata/dnn/tflite/global_average_pooling_2d_inp.npy new file mode 100644 index 0000000000000000000000000000000000000000..4f3964639d564cb1d14c4ba28bc3aff3717c42a4 GIT binary patch literal 1108 zcmbV={WsNj9Kb!qxa3)kgWDljT)TP9?0!G*>miJ3I7#;~k;j!hU6C~@j;XVy000xU!CB|H5A9^~>ue-X9qnCRA0)RXN2;OcEtz zbG+FcezH4<%jP6!WanhZrytJ9PE7jm2gIj|lD57mH9j+Gs~udpY!5Db@0Po{>;m@x zfYqU#rA;AsNTMbmysWD6J$-d~!<-)k>B>n~&t)3-a4%>~tV#3RhH!Z-f@}=)AXWDu zcv*Y^KfTt5$sctv!BvUID(y^J7DJpI7C;#Jl6XHTg64TI&`lesOW8UY>zXW;Toh81 zyNk#+W}%~955wwgrjoLB{Kl9q?<(yghNt%Ca0E=g%)s!Jc7!DXzlJtXI^gR!GVgPN3+(7)bqA@Vj{x!889? z_?A(a(MF%Ar)Y4tK3p)0p!xUZX!kA;eWR91 zYw<0{Ktn>qXJTO_ayu{)fvBBggAV1P@Zx)adVItioi)wD#c>c77M`SIml&g+9BF^T zG3=Q50rUBfNOYGe&9a`s@!Rh3tfrd3{VHN;?JoR@)+vbp*eU=l7d>UTpe=u+dmGicp)MG^D55Fn{sxt^KG0mkgMD-LsQBaz zDr`K!&r$+;4N6jXR$u-HyBeKWuFDRmm*RQXPx0oPn|S$V0n=xsAZ)E%`t=S8IH#L~ zGRjs^(GUYl=SSooYn#BfEED2fTXAG@|7*boZpv39A zw9d2^R;5}Ppu9$`22Ef(Vhuq%B;5Ht8&tEs7~Gt_D&*-$~!@ zxz& IMw?Ff7pczmDgXcg literal 0 HcmV?d00001 diff --git a/testdata/dnn/tflite/global_average_pooling_2d_out_Identity.npy b/testdata/dnn/tflite/global_average_pooling_2d_out_Identity.npy new file mode 100644 index 0000000000000000000000000000000000000000..79ecb22add19474b69ed77c5d2faa9c98a69d4b5 GIT binary patch literal 148 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+l>qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= tXCxM+0{I$-Itr$mItsN4WCJdf@cDaE=5F27Vkfj$;rPRy?+y0b008CjCGh|N literal 0 HcmV?d00001 diff --git a/testdata/dnn/tflite/global_max_pooling_2d.tflite b/testdata/dnn/tflite/global_max_pooling_2d.tflite new file mode 100644 index 0000000000000000000000000000000000000000..10e8b7b576f885d2d16b370abb9678d5f4381770 GIT binary patch literal 1284 zcmZ`(O=}ZT6un7fzYMX^5(}*mN*5v}aas%AhPGlLX(a}?#O>dK51WL{=v zMy4bSZd@|h3pkAkvXc^d37lm_M)1s)2JQi%#+a(#R2@n-!|WqZr6Z8pjq z^TR+Up#K4U1Kt8>zzJ{!yaJvAjN3$9$_Aiw z&-G(Wfm;MbMin=T9c}fRRMoQ9Nf4}w^-xc{<)XD(yesl9@lRh?(Xz;yb^J4qPk>Y4 zOJc{`&?e<;IBvllOl)XpU{sgzbp_l2QL9$!h4nB%Pa@APDqGG)B-fu7^Ur}H&v|_U zJ_DBkYiT=v0HNwTgnR&ye~o-u6V@Ch&%Xc%kz!8Q0Mif3!I;+vVnUHO=XvhpR~%C^ z2G6mteCGK){&~a9`B}xw93^wt{TfsK$Aikl%!OL|Gr4J>dRFi8@C3Mmo_EC5*!->Q zVSWVX%2-wKoKwa1aOt80Y*oJWX~6p544o&p2pocEzn**D(C#>{>j%5bu5FbbIxgtG zFXm40+}9yr?9XlB19;}N+X|ab%WgaSb|(y5%44bK>_gS}H<;UbGArgmFb-CF4S!3} z-GTg{&r;WOdpi+cGusbbf5+R?b?Z6j)wkeg@^;WE-&W2JD`nzoTS+g0JVm@)kpJpO zDd`VF4Be-^y2JWLa2i~H$6?LvPe%Rp4E>P)Iw?AVd?){)Jxm`sMX1mnOz-_-yW+f;oCl zwo;p=;Y6}ILY08SWph+{n(Z2edUKv8TlwFYD7I;puf8@%k*|E!K|C%yjLQyxWiXe$ zll?z%c~Sidrlv|jJj}vdcgKKTH%(<8t<)&?vgw2^_+sTv64lkhq$`7nJjz9UW=#j4 zPYQ&|=x(%GBB0H870u#1@KmCNYE$NkfAaK&v@H|N6W3m0L02){tck^l5II;syaTyt zq6M5X%&hRk6t)TUeFt!Bp%-4ZdPZ(?=&_Q;C(=h9M9VFr9b@l^_XH65^zUa>@Ph!W z!)MPqZl9#9jaz_GTkwIZlUOg^6Zx3zI1*e;OZ+?OiBc)}EGc5*pH)Hc_&)N_FLwCr z$p}5#|2^Yjc7i~zf$FbE!pL5WLq+DUAD2e}q-4rcl85Rzwsm+DKf zySN+ATkZ?x_Tz0ckrw!-yaBhXD`E72lRUq{-io*xF)n&0V2z5#Px1km{Y zBn{d+g6TiI;>_AaJe777uZl;&xcn|;EltA4hri)Hjx+f&U4m-;D18=f0K0_;tS|Rq zb5A_#rL8pZp#lbiq)^2xrM(H$!s*H}CjH^8G0Ns5aP>8Q_815NY$2sOH^LcjK4 zar?SB$jk@t`Ny;^&~E3Jos*72`y}tV}4>Y49na^>NPehrd~FoEDCSPo6r>Y zC&uwN!oRWGn`ek!dWbD(3UA2T*=#49tC)JokjpfZmGb z>Rzae{TNOkTZHDcHz9kW0mo|%C|2x)B}HvGzu_wL=%5iYTkaFS%nFMWmLcoXPGl|E zOY7VmuggA?-purbwqoAIaUsO_*m=~X4l#&V(cT3DEP6dh= xXCxM+0{I$-Itr#b3P93OQ%9jzfegTP;<=K8Y*(Peb%)3HQin7hmWWF`008G)BZL3| literal 0 HcmV?d00001