From bf97e6a33ae0a3a28d528d6952baf670557ea533 Mon Sep 17 00:00:00 2001 From: xuanyue Date: Fri, 7 Aug 2020 14:48:26 +0800 Subject: [PATCH] correct add/sub/div/mul/addn/cast/unique and add ut --- mindspore/lite/schema/ops.fbs | 4 ++ .../parser/tflite/test_data/addn.tflite | Bin 0 -> 664 bytes .../parser/tflite/test_data/cast.tflite | Bin 0 -> 492 bytes .../tflite/test_data/depth_to_space.tflite | Bin 0 -> 516 bytes .../parser/tflite/test_data/equal.tflite | Bin 0 -> 556 bytes .../parser/tflite/test_data/exp.tflite | Bin 412 -> 0 bytes .../parser/tflite/test_data/greater.tflite | Bin 0 -> 556 bytes .../tflite/test_data/greater_equal.tflite | Bin 0 -> 564 bytes .../parser/tflite/test_data/less.tflite | Bin 0 -> 556 bytes .../parser/tflite/test_data/less_equal.tflite | Bin 0 -> 560 bytes .../parser/tflite/test_data/not_equal.tflite | Bin 0 -> 560 bytes .../parser/tflite/test_data/prelu.tflite | Bin 0 -> 696 bytes .../tflite/test_data/reverse_sequence.tflite | Bin 0 -> 640 bytes .../parser/tflite/test_data/round.tflite | Bin 0 -> 472 bytes .../tflite/test_data/space_to_batch_nd.tflite | Bin 0 -> 720 bytes .../tflite/test_data/space_to_depth.tflite | Bin 0 -> 516 bytes .../tflite/test_data/sparse_to_dense.tflite | Bin 0 -> 772 bytes .../parser/tflite/test_data/square.tflite | Bin 412 -> 488 bytes .../test_data/squared_difference.tflite | Bin 0 -> 548 bytes .../tflite/test_data/strided_slice.tflite | Bin 0 -> 796 bytes .../parser/tflite/test_data/tile.tflite | Bin 0 -> 588 bytes .../parser/tflite/test_data/topk_v2.tflite | Bin 0 -> 660 bytes .../parser/tflite/test_data/unique.tflite | Bin 0 -> 588 bytes .../parser/tflite/test_data/unstack.tflite | Bin 0 -> 740 bytes .../parser/tflite/tflite_addn_parser_test.cc | 44 ++++++++++++++ .../parser/tflite/tflite_cast_parser_test.cc | 46 +++++++++++++++ .../tflite_depth_to_space_parser_test.cc | 45 ++++++++++++++ .../parser/tflite/tflite_equal_parser_test.cc | 36 ++++++++++++ .../tflite_greater_equal_parser_test.cc | 36 ++++++++++++ .../tflite/tflite_greater_parser_test.cc | 36 ++++++++++++ .../tflite/tflite_less_equal_parser_test.cc | 36 ++++++++++++ ...ser_test.cc => tflite_less_parser_test.cc} | 14 +++-- .../tflite/tflite_not_equal_parser_test.cc | 36 ++++++++++++ .../tflite/tflite_p_relu_parser_test.cc | 45 ++++++++++++++ .../tflite_reverse_sequence_parser_test.cc | 47 +++++++++++++++ .../parser/tflite/tflite_round_parser_test.cc | 36 ++++++++++++ .../tflite_space_to_batch_nd_parser_test.cc | 47 +++++++++++++++ .../tflite_space_to_depth_parser_test.cc | 45 ++++++++++++++ .../tflite_sparse_to_dense_parser_test.cc | 50 ++++++++++++++++ .../tflite/tflite_square_parser_test.cc | 2 +- .../tflite_squared_difference_parser_test.cc | 37 ++++++++++++ .../tflite_strided_slice_parser_test.cc | 55 ++++++++++++++++++ .../parser/tflite/tflite_tile_parser_test.cc | 45 ++++++++++++++ .../tflite/tflite_topk_v2_parser_test.cc | 47 +++++++++++++++ .../tflite/tflite_unique_parser_test.cc | 44 ++++++++++++++ .../tflite/tflite_unstack_parser_test.cc | 45 ++++++++++++++ .../parser/tflite/tflite_add_parser.cc | 7 ++- .../parser/tflite/tflite_addn_parser.cc | 2 +- .../parser/tflite/tflite_cast_parser.cc | 9 +-- .../parser/tflite/tflite_cast_parser.h | 14 +++++ .../parser/tflite/tflite_div_parser.cc | 2 +- .../parser/tflite/tflite_mul_parser.cc | 2 +- .../tflite/tflite_sparse_to_dense_parser.cc | 7 +-- .../parser/tflite/tflite_sub_parser.cc | 2 +- .../parser/tflite/tflite_unique_parser.cc | 2 +- .../parser/tflite/tflite_unique_parser.h | 14 +++++ 56 files changed, 913 insertions(+), 26 deletions(-) create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/addn.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/cast.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/depth_to_space.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/equal.tflite delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/exp.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/greater.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/greater_equal.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/less.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/less_equal.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/not_equal.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/prelu.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/reverse_sequence.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/round.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/space_to_batch_nd.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/space_to_depth.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/sparse_to_dense.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/squared_difference.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/strided_slice.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/tile.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/topk_v2.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/unique.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/unstack.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_addn_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cast_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_depth_to_space_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_equal_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_equal_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_equal_parser_test.cc rename mindspore/lite/test/ut/tools/converter/parser/tflite/{tflite_exp_parser_test.cc => tflite_less_parser_test.cc} (80%) create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_not_equal_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_p_relu_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reverse_sequence_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_round_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_space_to_batch_nd_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_space_to_depth_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sparse_to_dense_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_squared_difference_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_strided_slice_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_tile_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_topk_v2_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_unique_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_unstack_parser_test.cc diff --git a/mindspore/lite/schema/ops.fbs b/mindspore/lite/schema/ops.fbs index 78278b0c3a..a870a6bb01 100644 --- a/mindspore/lite/schema/ops.fbs +++ b/mindspore/lite/schema/ops.fbs @@ -384,15 +384,19 @@ table Eltwise { } table Add { + activationType : ActivationType; } table Sub { + activationType : ActivationType; } table Mul { + activationType : ActivationType; } table Div { + activationType : ActivationType; } table AddGrad { diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/addn.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/addn.tflite new file mode 100644 index 0000000000000000000000000000000000000000..d704d5d80d1954224243a29f080503269d9fe77c GIT binary patch literal 664 zcmaKqu}Z^W6os!EV<{yTb;!`6W2a!XLy-`=9&&X_(pd>G05O#~S8X#cEc!Jy;*cYy%W4vzMGT>k!w# z2`|Mrum#T6;XohsKo@kh=9_dip#IvWlILbFaTiSDWHg&6X*`KWkJ0QQo+hv^Iw#jS ztm>d0v^&8*N%?FOFNWt=&Esi8T^fY}jEDQ5Sv(lc&;ni11AVXwZZYPAPx5#01hkhP zdB%Qz2Fk@N`ei=3i!oWv=hALfczImt6j${sYII^n4ar!2kFqRNy?n`U189GJ6Q^E- zFuWvK3+=eni(jSJ*~ZEJJmtb}(7u-X#hw1`ztr6?@$X1S8rn&BlwQ)%+d2Ps O=;mfWecxy7O7|CH(jrj+ literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/depth_to_space.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/depth_to_space.tflite new file mode 100644 index 0000000000000000000000000000000000000000..2f9dbe01c42e40c4b52f33697b657b08f33d4093 GIT binary patch literal 516 zcmYLGy-or_7#!qOLI@BchT;ke3#to0jlIUi1R5oj5~7>1#qC|-pymO56blP0pTvhT zIcN5=ag(|4f4|P z5Vwp~YZ2lUbHn=;XODhr-FkO$g-y-+Xm)#>IjqXE6jzs+CX-}L8%~GLV*dCvyvrQ> z3-gvR)27mY-EC&1HztO}4I#Z}#1C;Iq)SIOK>gaAZmbjMHGS#6q!MxRyohT+=uW@| z>k+@zT;K`ZK+{i)rRn=|uG%;6r@KjycItlGt6F#;`Py-B@?yKpp7YJCVd%H1SNi&X gs`^{fCr-_YQ#u2u_6Vv=t9ALIm;k^2og?4(2RJh=OaK4? literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/equal.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/equal.tflite new file mode 100644 index 0000000000000000000000000000000000000000..b0325f43ecf7162377d0cf83d45a132e7fa5d02b GIT binary patch literal 556 zcmZ9JF;2rk5Jd+t#)^=MAVmrnDJUqAg@FSgp@5J=gXp73xUfVV2sRZ5px^);gi}ya zP*89bB=i0*hKQBEXLk1QpFiuw%q~wx2WFd=SYVN@Ti1G2`&7(UfZv%txvJSNaS3em zQG5og;FHY4&)OiKkIpUz$Fq`qReqIHiE;fmLrg{92Ve)twRu1tDwDNAIRr) zQedj%=8$@anmp;OQSfRAqcTULL{+eI!I=rnX*Tl!B wX8m#vzQBrX_&=eB#5~4VxGVgxe(%i-G;z4 zymVLP*YB!sByH~>Z=`cIDpab{TD2qT#PmmUM$SpWIMl7VFx#%}LOZ;?$MG%pS4rPE zkG?QJ(=`2>!Vz(0-}weK!PKTSUj}a$I~*JSJ(zF%&;vQ{2!{TM(c({h_wnlUD#gsi zjkqusGvR?Ak4tmtapv4+|MVPp!@iGWs-$Q7pcXgkrO!6+i(mb(K${m6FYm{hnwhN0 PG4CPwUFy`|w66aE^zI%0 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/greater.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/greater.tflite new file mode 100644 index 0000000000000000000000000000000000000000..6bf638e1576ad1aa69c8f67e15303aeff54ad24e GIT binary patch literal 556 zcmZ9Ju}Z{16h)sJV^}0Ey2TbLwy>~}VANI+78GG^#C};YMT%r4X07}H3qQaQ@hhw> zEG+yKA)Y&9baCM3y?JxzzWXMLnO&bvj?A_#vA`nRw7w0f4yl-}0lzbQa#gc^;tJU1 zqxcNg!6%y!@DARd0x#eJtO6~06|`3z0{JXw z1*Up#4ypI3$&=1H{<4O+v2Aebxg;mzd4CZn{*C326-ujn=Y+iLulc2NUgxtWukEpI w+gBjIINfZ^eBCLk+eLFIf1&fJz5|!}zpK8|kSA&U@A<2d@lNy$xT{&e0fkF2n*aa+ literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/greater_equal.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/greater_equal.tflite new file mode 100644 index 0000000000000000000000000000000000000000..eabe74532540745c27f7a002b72c26522bbd30f6 GIT binary patch literal 564 zcmZvZze>Yk6vdAkV<=LKcIeQdLk9;bR-Hu<6`?NTUIJza*i>WcM2R}Huf4+OqJ@-pj($(o`U)oexfg-J|r8e0P8EFMnk@Q?~}VARS=5CkDMV!sHcNRg~;vQ~b8g&*LD_!U+b z78ZVr5YL@4x;Sw2-n_YU-+hzB%&yP#BeQKwEU?HnZD=E^V=88A!0*hST-9u!xB_o>=htvnuP*b3)$t@8{2prV;V6>$+DU tzBv7C%Y5A_>$^pJD1V{zsJzRtO&f&n^q>(Jm1?{K&o# ztHc+BPvV1kCr+57AtM~G*dynIlYniaGIla=ZDXo(@=(reGqcQwtPA+{bwk=b%a5{s zI=^R=_OiIRN>68&eNB0jF%whu-wrV|(w-8#gmjBSJ4x6p%_Fg_m`7R##j;~UI;*Ln zsDax<>;vYcNq2qyB8O^Ytnt>@(m7V0*B9}|zp?c3gyQPoIi=sv*Z%87QP%a@eLKCS y|I~He8=)T6_4_UMsL$BDwmFc-(CO6dk@Nf?)@*S|mpBsQUydC3=DdKt+V=-v5-@=P literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/not_equal.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/not_equal.tflite new file mode 100644 index 0000000000000000000000000000000000000000..580f650e2360fee443303c2a23063b44531a6936 GIT binary patch literal 560 zcmZuuJ5Iwu6db@fR)kChDN?v_K|z5m3>*Ln1%VVO5PcL07c1d41e=NjP;dZ_!WpP3 zC@44xl9}0!MG96Lzt6rmZ{9iqaD6&C1h$YMK!gnpFl2Vb46sJ{2zYT>V2^f%*x^U^ zl~^af8GI3+#0PQA91R)ac*Pz$ADjei6Q!}!d1Gr+7SqRK{$MK0Y{X$iG8>7ctUrXmqbzWb@8~?`A#}kUHd*_sXH(&efy)LVIeBaD& z>EgL<+jl}es_XV!?opqycTIgDjiJ-2*+b{~Kdjl}kS=i~#J?Ol@WXild$sQ`F%U2# literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/prelu.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/prelu.tflite new file mode 100644 index 0000000000000000000000000000000000000000..dd432b62acef9b8d857c7838a5661987fbefe484 GIT binary patch literal 696 zcmbtSJxjw-6g_IxP)jY^p+koZ4h|9<1SvR)AP7;UI2J-74;x6*5))?!M-hLkqlodG z#MI*Ig_Ha7?mO?i`!WD_q;L&6c(LBY+S6OPkOL*?c9nv?p%i!9- z8ao&Bl>NC0T~<0&`>VafiZnaK0dYu3v+nXjK{hdCENwD*%B_5#US}uMC?GTF~GeKM&Ps0$yvMhluGFklA zeYfYaL3 gRR3jqC!Mc3X*Le=cQ(3zlrD`11eQiG5`Po literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/reverse_sequence.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/reverse_sequence.tflite new file mode 100644 index 0000000000000000000000000000000000000000..171aaa8caefa864f5dc5661db64b0918a4c5163e GIT binary patch literal 640 zcmZ9JKT88a5XDD5O$Z?dwGd2kMGA`$6SR=Df*`~u3fi5biyoNGzl&H{`T@ib>8B9S z_q$C{9C$Z-vomkr%r?yI^0a?wwq*^AtZY@Q+m52UikPhl;m_=?h?=$JSA>>6_;+Dl z=&ULx+$h+TKUR$UssJzS<>G8Qn{5lj)F;!q&(fhwp51hoj=X(-=Q;Ovq1)~rwL3a2 zY*YTce>R9uMqc@uyKgH}liFYHHAT=I3r%5PKr^#kOVF46tAI8PFS&(p$kTgxn|gTR zL3>GR;FVpGgEsO$@;s-0$pH@*xGO~^43!Wb6Yr^p`sHrXNF99ahZzTsZMX|JnLB^y z>_s(Z8@iA54Y{#=Nx+tU;ly~4VC<%>yzs7z86x^qgYO9FqW_-oulK>sO_C?)AF{_; j(Ve`oo1hqGc;SMFow1|8God;4<9XKA{xwS^CaQk`?@mFA literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/round.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/round.tflite new file mode 100644 index 0000000000000000000000000000000000000000..1c777757379048dde407d7954dc0b83820842575 GIT binary patch literal 472 zcmYL`F;2rk5Jd-KAc~?8L5dVET%@3~u;2hlNJvPbiRdGwxY)vL6l`h=iX4Dra1zdh zWZw6B#Y%r?_Rr4WKXz(n&kySxvkOZtv9V2UZVT8YjM)f;li8tX&8~1)be4l~2?zyBGGe5W7-DHSM}0w*u3#k;XT z+&iNZ?vXUA{d8TY9=$0q*^sMtGGJ4;US2e@v^B?~&%&S39MVuvoJV?5L*L2y*S0Cl Ket9pUS2}+OUnVX9 literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/space_to_batch_nd.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/space_to_batch_nd.tflite new file mode 100644 index 0000000000000000000000000000000000000000..f05f6fef85a9b60295335a3819d11eaa7865d049 GIT binary patch literal 720 zcmZ8f!Ab&A6g}BwB4ScP5-wUuvquUOfdu+?tTHF|b6xMhrvK8BI(Q4uj4#7>&co;PHDl^H?hp z&H8>_Go7t4IB%U@ZXQR5{YlWPGgGAEx&9(E(p@9Ai5)^5;(Vc?L*kwBfRH|!yzVPs zA=EqcLj&ZkezE77lP1+%zs|_?&MVW@zf7O@GuTq?lXr4wt9+Lx@n|28OJ3TqV!s=- zqa#1*_AgF=51xIU&3D2UYw0{dH6}9Rci&9>synPR{>!@?`@LRhZpL`B=d;w}*>CA| zxwGkhbG%jhe@G+E&Qp)(HVC(a4aWawT@Rw}ZD-u~<3RV$+PjOl{JRA)i&tFY(T-|_ Xv^X7#Rnz|#ns|~lfiJrk&-VQQDi~34 literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/space_to_depth.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/space_to_depth.tflite new file mode 100644 index 0000000000000000000000000000000000000000..3ed48958f084a95fbab84185588ba5f19858ddf4 GIT binary patch literal 516 zcmYk3v1$TA6h&{6B@q!LDnVomixgH%Bnasfgn(&OY(?ULQ|#Y0~MR?r=kk3;C(`8TNUKM5 zC*YF%5xs34V|m-`h(t!GU)(JA3o?&FoeIv`<_6z$&V6kVg?^tTS6-2AC(Z74TrQzybXn zQRhegkys*zIpB>b6R+I3CY~4{a!>yi3GwTcyp4fH`Zc2G2W~$N62E8Mf$7J77~uG4 zG;+9CCK|P)TAhAkD-6zCXBS&1VZi?r)2T62qUygMO3X<64zWw9UfLIkFABORD#Rz( z5h0B-d7Ud?8OJ@(4}gO0K_?WLm#)cw@`8*l+qq?Ys?l_^8U{_}KiC^xP8`xBo!d%` z*UBvumyy?xO*?FwAU0eNS$8$c<}x|Ez%{olmvWl3dX{YxGaP%dWpoE#H#IRF);^E< zbSFAjxS8VA8<0-TP}-$&gP7$F(C3VpHli|pF5cPw3k?0t$`T+%CU*?+wq vbL*wuBol1eG9KM^o|DbqtL~a+XCRH5XH^M8{mARB`2j^XfN$HgV>SH(8<}i^ literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/square.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/square.tflite index 8bd23c38c7eda6abecf226bb9a8bbacdd9616d85..4c907b4a1f4b1a8d84ee5a2cb9614dddb0ff068d 100644 GIT binary patch literal 488 zcmYk3Jx;?w5QPUYA&Mds0YwTIE>cig7%qT7LP81+P$Gp$xY)uD7@IRtQl#K8oPaYS zneXk!f|1_N&(6GkV<%>Ie>FcdJFvte8`{_=c0_eb#cT(J%$Vin*qE%BaLB{?i{*k?sVfUn0um|0J)2n@?LE6$ytb7+}=ew77Sr_6Sc>bV4FNHrN4dM`A Vzn|v+bGYicZE~|8-iu(-^e?x)D#ic+ literal 412 zcmZ9I!3u&v6h&_(CM4Fvh09sEXc2Atfk0>#804}|W!IG*geEOJ{leaKHW zbXFQ^foIarii74>a#GjoSz7JOCnoSXp*dd&{7E3n5$ z_664Ai^C^;z#AOn!%)%6x~kqR_r^DHc|u<1rU9Nds{eXu8_4nu2IEqa9hQ)nJDhLC<^7(GnJZYgBZ01szOdP&P x^4=G@im!WG&eg1<%K6uKKH*hu)VK)$rlp8qE2J_dIgd<1gS!H<|zd literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/strided_slice.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/strided_slice.tflite new file mode 100644 index 0000000000000000000000000000000000000000..d586c1faabbf3390072de9777fb5620d4084d164 GIT binary patch literal 796 zcmaiyu}T9$5QaxRlMrGIYLOzv6&4mT7?ogQAqavH8zYtmF$W%)i^Pky58wmj39Q6Y zEPMb9AHYZOA)@j7_Y%BDT=;i(c4q$lcXlggc5=|%GF!5Wd6u(+m28FGGCO8-Ao0xZ z-LBa-b_VP*$qqplyw94wfiid{a0y;m?+{a70f=9xzQ<#aSP9f?joJowIu=QqexxF2?cPU|YX2ypF@y0dZ8C&iVI>olBVac9LVEwVmPj<^>< znvYLlBlw`A}%Mp`95SzM}Dt@`Q%X&0t%qCXf$*Mk_Mk-NL+7=8fI$Z2i> literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/tile.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/tile.tflite new file mode 100644 index 0000000000000000000000000000000000000000..b959b4bfdc0756dd6e08eab0f8ba710f4258ef35 GIT binary patch literal 588 zcmYjOy-or_7#tDtLJSh6prE*d!or+hZ0wCj6Ko8%#KcY9%PZIVHx#2_et=mXwA*$uESw>4;km56RkHK3NBJgLf%+nUf#Y zw*8vXi8|`t=PmX!xK{qrd#^d|mUi02(&-TTZxl~$VMzF3zbXl{s;j0R?UIJ>@p}_) zi*KdxG`!%Dw^v}w=sO+LJE9rE8wFV)IFRxzBYxcii>25v9mvxJ};=8Qr Jx6OI^`T?A9H9r6V literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/topk_v2.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/topk_v2.tflite new file mode 100644 index 0000000000000000000000000000000000000000..4f8e658707d01e2a32b4ede2d02a5ff2081d8f98 GIT binary patch literal 660 zcmZuv!AiqW5FBf4V=1**4?W~iq=z0PHdttnf<+MOMZ6cGIRwdz)TAdrzz^^PJc{4Y zPZQ(JdkK1QVY=JN?!4KT1OV=@mlwb>0(kJzK@TTn2V{VK!u73^OTsAS5JqKwodSE4ID7{i8L{*O=0pRjaS=v^PFS`pWkKa@mY_E!da*@ z>o{U@yS%v@US)>;dAttEbm{olf0vAWkBBjGMo2@NYZ?lO9qSiD{uIizY;(Y@-t-|c z(w3I|x9CXPj8pY!FZJ!{SF?idOj+Ty+jde4ZAVYUZ_Bb|YG_Ak42Tg?&(~VIudK+Q ziad%~V$3;1XimMF8&>sS4=r-l96sz>O*-)GyV7}r=H1=-+|9lFYCr2sdfHLDDh`QC l^Zb#u)THC?NR|77q#=LW^FM#O2YoY%(OSS4{drW9!Vk;FK@cwhZx2`G|ujT5+H8s_J`XZj8Zv+>4ahXp^ zws8dC&S&@8byIV$EuV5K39kQUNT|qr22Q~lkax|LVeAur1M;X4_eja*v3hhEO1zGC zGh{o`CGOOt+0++xT{nPrzGqV6fc_yIllgcK_sMI_FJa$X&4Ff>Kk)>pSLd|fX5AJA zyyUL2pET@My_!_B3c6pcd3z1%$fqk3o8i-0U44%LvcmQqwi(3cEp-eg>RKPYE#;!M>x+ES(z58f9iARoT z8BU4Wn2p-Z!e$sYTWtK;U_I}iUF@BX9Osf~&?FMz;MY$;L_YR`jvfK|knRVC$x90? z`2GZQpn5g57HF_n9m9T1aY3djKNTud4n|wL;uT(1zkEt#-9vlYlJ!@5iYu0nTBfM( z)bhZU{sn28%D-yXsvL!;^rvo;^lxru%@*HjdgA%gUc%?@=?h%v`9+`q(LWIX8t$9t z>y0eY55=Fs{qlVI{>#@J@b%NJa@OO#zp5sGmFlm~$+PZK^+~JfsrnMTyJ +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserAddN : public TestTfliteParser { + public: + TestTfliteParserAddN() {} + void SetUp() override { + meta_graph = LoadAndConvert("./addn.tflite"); + } +}; + +TEST_F(TestTfliteParserAddN, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_AddN) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserAddN, AttrValue) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsAddN(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsAddN()->N, 4); +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cast_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cast_parser_test.cc new file mode 100644 index 0000000000..c986d595d7 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cast_parser_test.cc @@ -0,0 +1,46 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserCast : public TestTfliteParser { + public: + TestTfliteParserCast() {} + void SetUp() override { + meta_graph = LoadAndConvert("./cast.tflite"); + } +}; + +TEST_F(TestTfliteParserCast, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_Cast) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserCast, AttrValue) { + // float32 --> int32 + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsCast(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsCast()->srcT, 43); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsCast()->dstT, 34); +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_depth_to_space_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_depth_to_space_parser_test.cc new file mode 100644 index 0000000000..d1983e0b84 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_depth_to_space_parser_test.cc @@ -0,0 +1,45 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserDepthToSpace : public TestTfliteParser { + public: + TestTfliteParserDepthToSpace() {} + void SetUp() override { + meta_graph = LoadAndConvert("./depth_to_space.tflite"); + } +}; + +TEST_F(TestTfliteParserDepthToSpace, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_DepthToSpace) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserDepthToSpace, AttrValue) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsDepthToSpace(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsDepthToSpace()->blockSize, 4); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsDepthToSpace()->format, schema::Format_NHWC); +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_equal_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_equal_parser_test.cc new file mode 100644 index 0000000000..7e816a9d39 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_equal_parser_test.cc @@ -0,0 +1,36 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserEqual : public TestTfliteParser { + public: + TestTfliteParserEqual() {} + void SetUp() override { + meta_graph = LoadAndConvert("./equal.tflite"); + } +}; + +TEST_F(TestTfliteParserEqual, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_Equal) << "wrong Op Type"; +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_equal_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_equal_parser_test.cc new file mode 100644 index 0000000000..3b5dba47c2 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_equal_parser_test.cc @@ -0,0 +1,36 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserGreaterEqual : public TestTfliteParser { + public: + TestTfliteParserGreaterEqual() {} + void SetUp() override { + meta_graph = LoadAndConvert("./greater_equal.tflite"); + } +}; + +TEST_F(TestTfliteParserGreaterEqual, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_GreaterEqual) << "wrong Op Type"; +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_parser_test.cc new file mode 100644 index 0000000000..055dbab7da --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_parser_test.cc @@ -0,0 +1,36 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserGreater : public TestTfliteParser { + public: + TestTfliteParserGreater() {} + void SetUp() override { + meta_graph = LoadAndConvert("./greater.tflite"); + } +}; + +TEST_F(TestTfliteParserGreater, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_Greater) << "wrong Op Type"; +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_equal_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_equal_parser_test.cc new file mode 100644 index 0000000000..6c1d29877f --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_equal_parser_test.cc @@ -0,0 +1,36 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserLessEqual : public TestTfliteParser { + public: + TestTfliteParserLessEqual() {} + void SetUp() override { + meta_graph = LoadAndConvert("./less_equal.tflite"); + } +}; + +TEST_F(TestTfliteParserLessEqual, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_LessEqual) << "wrong Op Type"; +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_exp_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_parser_test.cc similarity index 80% rename from mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_exp_parser_test.cc rename to mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_parser_test.cc index 5a09b9e428..795acfce7d 100644 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_exp_parser_test.cc +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_parser_test.cc @@ -13,22 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" #include #include "common/common_test.h" namespace mindspore { -class TestTfliteParserExp : public TestTfliteParser { +class TestTfliteParserLess : public TestTfliteParser { public: - TestTfliteParserExp() {} - void SetUp() override { meta_graph = LoadAndConvert("./exp.tflite", ""); } + TestTfliteParserLess() {} + void SetUp() override { + meta_graph = LoadAndConvert("./less.tflite"); + } }; -TEST_F(TestTfliteParserExp, OpType) { +TEST_F(TestTfliteParserLess, OpType) { ASSERT_NE(meta_graph, nullptr); ASSERT_GT(meta_graph->nodes.size(), 0); ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_Exp) << "wrong Op Type"; + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_Less) << "wrong Op Type"; } - } // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_not_equal_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_not_equal_parser_test.cc new file mode 100644 index 0000000000..e7260a1262 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_not_equal_parser_test.cc @@ -0,0 +1,36 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserNotEqual : public TestTfliteParser { + public: + TestTfliteParserNotEqual() {} + void SetUp() override { + meta_graph = LoadAndConvert("./not_equal.tflite"); + } +}; + +TEST_F(TestTfliteParserNotEqual, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_NotEqual) << "wrong Op Type"; +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_p_relu_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_p_relu_parser_test.cc new file mode 100644 index 0000000000..11e5fe7c14 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_p_relu_parser_test.cc @@ -0,0 +1,45 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserPrelu : public TestTfliteParser { + public: + TestTfliteParserPrelu() {} + void SetUp() override { + meta_graph = LoadAndConvert("./prelu.tflite"); + } +}; + +TEST_F(TestTfliteParserPrelu, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_Prelu) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserPrelu, AttrValue) { + std::vector slope(20, 0); + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsPrelu(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsPrelu()->slope, slope); +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reverse_sequence_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reverse_sequence_parser_test.cc new file mode 100644 index 0000000000..f1a972f6e4 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reverse_sequence_parser_test.cc @@ -0,0 +1,47 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserReverseSequence : public TestTfliteParser { + public: + TestTfliteParserReverseSequence() {} + void SetUp() override { + meta_graph = LoadAndConvert("./reverse_sequence.tflite"); + } +}; + +TEST_F(TestTfliteParserReverseSequence, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_ReverseSequence) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserReverseSequence, AttrValue) { + std::vector seq_length{7, 2, 3, 5}; + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsReverseSequence(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReverseSequence()->seqAxis, 1); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReverseSequence()->seqAxis, 1); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReverseSequence()->seqLengths, seq_length); +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_round_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_round_parser_test.cc new file mode 100644 index 0000000000..ffb6a26ffe --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_round_parser_test.cc @@ -0,0 +1,36 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserRound : public TestTfliteParser { + public: + TestTfliteParserRound() {} + void SetUp() override { + meta_graph = LoadAndConvert("./round.tflite"); + } +}; + +TEST_F(TestTfliteParserRound, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_Round) << "wrong Op Type"; +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_space_to_batch_nd_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_space_to_batch_nd_parser_test.cc new file mode 100644 index 0000000000..a9d66ceaf4 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_space_to_batch_nd_parser_test.cc @@ -0,0 +1,47 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserSpaceToBatchND : public TestTfliteParser { + public: + TestTfliteParserSpaceToBatchND() {} + void SetUp() override { + meta_graph = LoadAndConvert("./space_to_batch_nd.tflite"); + } +}; + +TEST_F(TestTfliteParserSpaceToBatchND, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_SpaceToBatchND) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserSpaceToBatchND, AttrValue) { + std::vector blockshape{2, 2}; + std::vector padding{0, 0, 2, 0}; + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsSpaceToBatchND(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsSpaceToBatchND()->blockShape, blockshape); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsSpaceToBatchND()->paddings, padding); +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_space_to_depth_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_space_to_depth_parser_test.cc new file mode 100644 index 0000000000..76245204a7 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_space_to_depth_parser_test.cc @@ -0,0 +1,45 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserSpaceToDepth : public TestTfliteParser { + public: + TestTfliteParserSpaceToDepth() {} + void SetUp() override { + meta_graph = LoadAndConvert("./space_to_depth.tflite"); + } +}; + +TEST_F(TestTfliteParserSpaceToDepth, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_SpaceToDepth) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserSpaceToDepth, AttrValue) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsSpaceToDepth(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsSpaceToDepth()->blockSize, 2); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsSpaceToDepth()->format, schema::Format_NHWC); +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sparse_to_dense_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sparse_to_dense_parser_test.cc new file mode 100644 index 0000000000..043fdbfe63 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sparse_to_dense_parser_test.cc @@ -0,0 +1,50 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserSparseToDense : public TestTfliteParser { + public: + TestTfliteParserSparseToDense() {} + void SetUp() override { + meta_graph = LoadAndConvert("./sparse_to_dense.tflite"); + } +}; + +TEST_F(TestTfliteParserSparseToDense, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_SparseToDense) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserSparseToDense, AttrValue) { + std::vector outputShape{5, 5}; + std::vector sparseValue{1}; + std::vector defaultValue{0}; + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsSparseToDense(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsSparseToDense()->outputShape, outputShape); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsSparseToDense()->sparseValue, sparseValue); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsSparseToDense()->defaultValue, defaultValue); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsSparseToDense()->validateIndices, false); +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_square_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_square_parser_test.cc index 5301c2302a..96e0e71f0c 100644 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_square_parser_test.cc +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_square_parser_test.cc @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" #include #include "common/common_test.h" @@ -30,5 +31,4 @@ TEST_F(TestTfliteParserSquare, OpType) { ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_Square) << "wrong Op Type"; } - } // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_squared_difference_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_squared_difference_parser_test.cc new file mode 100644 index 0000000000..f6be7a992d --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_squared_difference_parser_test.cc @@ -0,0 +1,37 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserSquaredDifference : public TestTfliteParser { + public: + TestTfliteParserSquaredDifference() {} + void SetUp() override { + meta_graph = LoadAndConvert("./squared_difference.tflite"); + } +}; + +TEST_F(TestTfliteParserSquaredDifference, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_SquaredDifference) + << "wrong Op Type"; +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_strided_slice_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_strided_slice_parser_test.cc new file mode 100644 index 0000000000..bbb327b998 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_strided_slice_parser_test.cc @@ -0,0 +1,55 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserStridedSlice : public TestTfliteParser { + public: + TestTfliteParserStridedSlice() {} + void SetUp() override { + meta_graph = LoadAndConvert("./strided_slice.tflite"); + } +}; + +TEST_F(TestTfliteParserStridedSlice, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_StridedSlice) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserStridedSlice, AttrValue) { + std::vector begin{1, -1, 0}; + std::vector end{2, -3, 3}; + std::vector stride{1, -1, 1}; + std::vector isscale{3, 2, 3}; + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsStridedSlice(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsStridedSlice()->beginMask, 0); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsStridedSlice()->endMask, 0); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsStridedSlice()->beginMask, 0); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsStridedSlice()->beginMask, 0); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsStridedSlice()->begin, begin); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsStridedSlice()->end, end); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsStridedSlice()->stride, stride); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsStridedSlice()->isScale, isscale); +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_tile_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_tile_parser_test.cc new file mode 100644 index 0000000000..19401218f7 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_tile_parser_test.cc @@ -0,0 +1,45 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserTile : public TestTfliteParser { + public: + TestTfliteParserTile() {} + void SetUp() override { + meta_graph = LoadAndConvert("./tile.tflite"); + } +}; + +TEST_F(TestTfliteParserTile, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_Tile) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserTile, AttrValue) { + std::vector multiply{2, 3, 4}; + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsTile(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsTile()->multiples, multiply); +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_topk_v2_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_topk_v2_parser_test.cc new file mode 100644 index 0000000000..d358fdb2d5 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_topk_v2_parser_test.cc @@ -0,0 +1,47 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserTopKV2 : public TestTfliteParser { + public: + TestTfliteParserTopKV2() {} + void SetUp() override { + meta_graph = LoadAndConvert("./topk_v2.tflite"); + } +}; + +TEST_F(TestTfliteParserTopKV2, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_TopKV2) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserTopKV2, AttrValue) { + // attr->sorted default is true + std::vector k{3}; + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsTopKV2(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsTopKV2()->k, k); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsTopKV2()->sorted, true); +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_unique_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_unique_parser_test.cc new file mode 100644 index 0000000000..244abf8ee2 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_unique_parser_test.cc @@ -0,0 +1,44 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserUnique : public TestTfliteParser { + public: + TestTfliteParserUnique() {} + void SetUp() override { + meta_graph = LoadAndConvert("./unique.tflite"); + } +}; + +TEST_F(TestTfliteParserUnique, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_Unique) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserUnique, AttrValue) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsUnique(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsUnique()->outType, 34); // int32 +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_unstack_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_unstack_parser_test.cc new file mode 100644 index 0000000000..e2c03a5bec --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_unstack_parser_test.cc @@ -0,0 +1,45 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h" +#include +#include "common/common_test.h" + +namespace mindspore { +class TestTfliteParserUnstack : public TestTfliteParser { + public: + TestTfliteParserUnstack() {} + void SetUp() override { + meta_graph = LoadAndConvert("./unstack.tflite"); + } +}; + +TEST_F(TestTfliteParserUnstack, OpType) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_Unstack) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserUnstack, AttrValue) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsUnstack(), nullptr); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsUnstack()->num, 5); + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsUnstack()->axis, 1); +} +} // namespace mindspore diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_add_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_add_parser.cc index a1c981ca61..3981b4b6ae 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_add_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_add_parser.cc @@ -29,6 +29,11 @@ STATUS TfliteAddParser::Parse(const std::unique_ptr &tfliteOp bool quantizedModel) { MS_LOG(DEBUG) << "parse TfliteAddParser"; std::unique_ptr attr(new schema::AddT()); + const auto &tfliteAttr = tfliteOp->builtin_options.AsAddOptions(); + if (nullptr == tfliteAttr) { + MS_LOG(ERROR) << "get op: " << op->name.c_str() << " attr failed"; + return RET_NULL_PTR; + } auto weight_index = tfliteOp->inputs[1]; const auto &weight_tensor = tfliteTensors[weight_index]; @@ -36,7 +41,7 @@ STATUS TfliteAddParser::Parse(const std::unique_ptr &tfliteOp if (RET_OK != ParseWeight(weight_tensors, tfliteModelBuffer, tensor_cache, schema::Format_KHWC)) { return RET_ERROR; } - + attr->activationType = GetActivationFunctionType(tfliteAttr->fused_activation_function); if (op != nullptr) { op->primitive = std::make_unique(); op->primitive->value.type = schema::PrimitiveType_Add; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_addn_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_addn_parser.cc index 70905aaebc..5dc9ee5bfd 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_addn_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_addn_parser.cc @@ -30,7 +30,7 @@ STATUS TfliteAddNParser::Parse(const std::unique_ptr &tflite_ bool quantized_model) { MS_LOG(DEBUG) << "parse TfliteAddNParser"; std::unique_ptr attr(new schema::AddNT()); - attr->N = tflite_tensors.size(); + attr->N = tflite_tensors.size() - 1; if (op != nullptr) { op->primitive = std::make_unique(); op->primitive->value.type = schema::PrimitiveType_AddN; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_cast_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_cast_parser.cc index d81fb87075..a7cce134a6 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_cast_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_cast_parser.cc @@ -29,14 +29,9 @@ STATUS TfliteCastParser::Parse(const std::unique_ptr &tflite_ TensorCache *tensor_cache, bool quantized_model) { MS_LOG(DEBUG) << "parse TfliteCastParser"; std::unique_ptr attr(new schema::CastT()); - const auto &tflite_attr = tflite_op->builtin_options.AsCastOptions(); - if (tflite_attr == nullptr) { - MS_LOG(ERROR) << "get op:" << op->name.c_str() << " attr failed"; - return RET_NULL_PTR; - } - attr->srcT = tflite_attr->in_data_type; - attr->dstT = tflite_attr->out_data_type; + attr->srcT = dtype_map[tflite_tensors[tflite_op->inputs[0]]->type]; + attr->dstT = dtype_map[tflite_tensors[tflite_op->outputs[0]]->type]; if (op != nullptr) { op->primitive = std::make_unique(); diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_cast_parser.h b/mindspore/lite/tools/converter/parser/tflite/tflite_cast_parser.h index 935389d5ba..843a144929 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_cast_parser.h +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_cast_parser.h @@ -19,6 +19,7 @@ #include #include +#include #include "tools/converter/parser/tflite/tflite_node_parser.h" #include "tools/converter/parser/tflite/tflite_node_parser_registry.h" @@ -34,6 +35,19 @@ class TfliteCastParser : public TfliteNodeParser { const std::vector> &tflite_opset, schema::CNodeT *op, TensorCache *tensor_cache, bool quantized_model) override; + + private: + std::map dtype_map = { + {tflite::TensorType_FLOAT64, TypeId::kNumberTypeFloat64}, + {tflite::TensorType_FLOAT32, TypeId::kNumberTypeFloat32}, + {tflite::TensorType_FLOAT16, TypeId::kNumberTypeFloat16}, + {tflite::TensorType_INT64, TypeId::kNumberTypeInt64}, + {tflite::TensorType_INT32, TypeId::kNumberTypeInt32}, + {tflite::TensorType_INT16, TypeId::kNumberTypeInt16}, + {tflite::TensorType_INT8, TypeId::kNumberTypeInt8}, + {tflite::TensorType_UINT8, TypeId::kNumberTypeUInt8}, + {tflite::TensorType_BOOL, TypeId::kNumberTypeBool}, + }; }; } // namespace lite } // namespace mindspore diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_div_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_div_parser.cc index c9d52f6cab..b7b6efe123 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_div_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_div_parser.cc @@ -42,7 +42,7 @@ STATUS TfliteDivParser::Parse(const std::unique_ptr &tfliteOp MS_LOG(ERROR) << "parse weight failed"; return RET_ERROR; } - + attr->activationType = GetActivationFunctionType(tfliteAttr->fused_activation_function); if (op != nullptr) { op->primitive = std::make_unique(); op->primitive->value.type = schema::PrimitiveType_Div; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_mul_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_mul_parser.cc index 7d6647171e..efdefbc743 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_mul_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_mul_parser.cc @@ -43,7 +43,7 @@ STATUS TfliteMulParser::Parse(const std::unique_ptr &tfliteOp MS_LOG(ERROR) << "parse weight failed"; return RET_ERROR; } - + attr->activationType = GetActivationFunctionType(tfliteAttr->fused_activation_function); if (op != nullptr) { op->primitive = std::make_unique(); op->primitive->value.type = schema::PrimitiveType_Mul; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_sparse_to_dense_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_sparse_to_dense_parser.cc index 8e805acd97..86ed3d0a2a 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_sparse_to_dense_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_sparse_to_dense_parser.cc @@ -29,11 +29,6 @@ STATUS TfliteSparseToDenseParser::Parse(const std::unique_ptr TensorCache *tensor_cache, bool quantized_model) { MS_LOG(DEBUG) << "parse TfliteSparseToDenseParser"; std::unique_ptr attr(new schema::SparseToDenseT()); - const auto &tflite_attr = tflite_op->builtin_options.AsSparseToDenseOptions(); - if (tflite_attr == nullptr) { - MS_LOG(ERROR) << "get op:" << op->name.c_str() << " attr failed"; - return RET_NULL_PTR; - } if (GetTfliteData(tflite_op->inputs[1], tflite_tensors, tflite_model_buffer, attr->outputShape)) { MS_LOG(ERROR) << "sparseToDense -> outputShape get failed"; @@ -47,7 +42,7 @@ STATUS TfliteSparseToDenseParser::Parse(const std::unique_ptr MS_LOG(ERROR) << "sparseToDense -> defaultValue get failed"; return RET_ERROR; } - attr->validateIndices = tflite_attr->validate_indices; + attr->validateIndices = false; if (op != nullptr) { op->primitive = std::make_unique(); op->primitive->value.type = schema::PrimitiveType_SparseToDense; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_sub_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_sub_parser.cc index 0590734bf0..1a517f1490 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_sub_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_sub_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteSubParser::Parse(const std::unique_ptr &tfliteOp if (RET_OK != ParseWeight(weight_tensors, tfliteModelBuffer, tensor_cache, schema::Format_KHWC)) { MS_LOG(ERROR) << "parse weight failed"; } - + attr->activationType = GetActivationFunctionType(tfliteAttr->fused_activation_function); if (op != nullptr) { op->primitive = std::make_unique(); op->primitive->value.type = schema::PrimitiveType_Sub; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_unique_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_unique_parser.cc index fe386d5736..12131d606f 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_unique_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_unique_parser.cc @@ -35,7 +35,7 @@ STATUS TfliteUniqueParser::Parse(const std::unique_ptr &tflit return RET_NULL_PTR; } - attr->outType = GetTfliteDataType(tflite_attr->idx_out_type); + attr->outType = dtype_map[tflite_attr->idx_out_type]; if (op != nullptr) { op->primitive = std::make_unique(); op->primitive->value.type = schema::PrimitiveType_Unique; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_unique_parser.h b/mindspore/lite/tools/converter/parser/tflite/tflite_unique_parser.h index f0e3b30c45..331aa5e48f 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_unique_parser.h +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_unique_parser.h @@ -19,6 +19,7 @@ #include #include +#include #include "tools/converter/parser/tflite/tflite_node_parser.h" #include "tools/converter/parser/tflite/tflite_node_parser_registry.h" @@ -34,6 +35,19 @@ class TfliteUniqueParser : public TfliteNodeParser { const std::vector> &tflite_opset, schema::CNodeT *op, TensorCache *tensor_cache, bool quantized_model) override; + + private: + std::map dtype_map = { + {tflite::TensorType_FLOAT64, TypeId::kNumberTypeFloat64}, + {tflite::TensorType_FLOAT32, TypeId::kNumberTypeFloat32}, + {tflite::TensorType_FLOAT16, TypeId::kNumberTypeFloat16}, + {tflite::TensorType_INT64, TypeId::kNumberTypeInt64}, + {tflite::TensorType_INT32, TypeId::kNumberTypeInt32}, + {tflite::TensorType_INT16, TypeId::kNumberTypeInt16}, + {tflite::TensorType_INT8, TypeId::kNumberTypeInt8}, + {tflite::TensorType_UINT8, TypeId::kNumberTypeUInt8}, + {tflite::TensorType_BOOL, TypeId::kNumberTypeBool}, + }; }; } // namespace lite } // namespace mindspore