From 754ef228314a9b4696adca3e53f9ccc52b4e2d00 Mon Sep 17 00:00:00 2001 From: lyvette Date: Tue, 11 Aug 2020 15:23:51 +0800 Subject: [PATCH] merge similar parser ut. fix fc parser bug. modify pooling parser and add its ut. fix gatherND parser bug. --- mindspore/lite/schema/ops.fbs | 1 + .../tflite/test_data/avg_pooling.tflite | Bin 0 -> 544 bytes .../parser/tflite/test_data/exp.tflite | Bin 0 -> 476 bytes .../tflite/test_data/max_pooling.tflite | Bin 0 -> 544 bytes .../parser/tflite/test_data/mean.tflite | Bin 0 -> 632 bytes .../parser/tflite/test_data/relu6.tflite | Bin 0 -> 476 bytes .../parser/tflite/test_data/reshape.tflite | Bin 0 -> 596 bytes .../tflite/test_data/resize_bilinear.tflite | Bin 0 -> 628 bytes .../parser/tflite/test_data/softmax.tflite | Bin 0 -> 512 bytes .../parser/tflite/test_data/tanh.tflite | Bin 0 -> 476 bytes .../parser/tflite/tflite_abs_parser_test.cc | 34 -- .../tflite/tflite_activation_parser_test.cc | 105 ++++ .../parser/tflite/tflite_add_parser_test.cc | 78 --- .../tflite/tflite_arithmetic_parser_test.cc | 576 ++++++++++++++++++ .../parser/tflite/tflite_ceil_parser_test.cc | 33 - .../parser/tflite/tflite_cos_parser_test.cc | 34 -- .../parser/tflite/tflite_div_parser_test.cc | 78 --- .../parser/tflite/tflite_equal_parser_test.cc | 36 -- .../tflite/tflite_floor_div_parser_test.cc | 33 - .../tflite/tflite_floor_mod_parser_test.cc | 33 - .../parser/tflite/tflite_floor_parser_test.cc | 33 - .../tflite_greater_equal_parser_test.cc | 36 -- .../tflite/tflite_leaky_relu_parser_test.cc | 42 -- .../tflite/tflite_less_equal_parser_test.cc | 36 -- .../parser/tflite/tflite_less_parser_test.cc | 36 -- .../parser/tflite/tflite_log_parser_test.cc | 34 -- .../tflite/tflite_logical_and_parser_test.cc | 34 -- .../tflite/tflite_logical_or_parser_test.cc | 34 -- ..._test.cc => tflite_logical_parser_test.cc} | 27 + .../tflite/tflite_maximum_parser_test.cc | 34 -- .../tflite/tflite_minimum_parser_test.cc | 34 -- .../parser/tflite/tflite_mul_parser_test.cc | 78 --- .../tflite/tflite_not_equal_parser_test.cc | 36 -- .../tflite/tflite_pooling_parser_test.cc | 95 +++ .../parser/tflite/tflite_pow_parser_test.cc | 44 -- .../tflite/tflite_reduce_max_parser_test.cc | 46 -- .../tflite/tflite_reduce_min_parser_test.cc | 46 -- .../tflite/tflite_reduce_parser_test.cc | 155 +++++ .../tflite/tflite_reduce_prod_parser_test.cc | 46 -- .../parser/tflite/tflite_relu_parser_test.cc | 33 - ..._test.cc => tflite_reshape_parser_test.cc} | 19 +- ...r_test.cc => tflite_resize_parser_test.cc} | 32 +- .../parser/tflite/tflite_round_parser_test.cc | 36 -- .../parser/tflite/tflite_rsqrt_parser_test.cc | 34 -- .../parser/tflite/tflite_sin_parser_test.cc | 34 -- ..._test.cc => tflite_softmax_parser_test.cc} | 19 +- .../parser/tflite/tflite_sqrt_parser_test.cc | 34 -- .../tflite/tflite_square_parser_test.cc | 34 -- .../tflite_squared_difference_parser_test.cc | 37 -- .../parser/tflite/tflite_sub_parser_test.cc | 78 --- .../parser/tflite/tflite_sum_parser_test.cc | 47 -- .../parser/caffe/caffe_innerproduct_parser.cc | 3 +- .../tflite/tflite_fullyconnected_parser.cc | 1 + .../parser/tflite/tflite_gather_nd_parser.cc | 24 + .../parser/tflite/tflite_pooling_parser.cc | 32 +- .../parser/tflite/tflite_reshape_parser.cc | 5 +- .../converter/parser/tflite/tflite_util.cc | 4 + 57 files changed, 1078 insertions(+), 1395 deletions(-) create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/avg_pooling.tflite create 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/max_pooling.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/mean.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/relu6.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/reshape.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/resize_bilinear.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/softmax.tflite create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/tanh.tflite delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_abs_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_activation_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_add_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_arithmetic_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_ceil_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cos_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_div_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_equal_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_div_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_mod_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_equal_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_leaky_relu_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_equal_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_log_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_and_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_or_parser_test.cc rename mindspore/lite/test/ut/tools/converter/parser/tflite/{tflite_logical_not_parser_test.cc => tflite_logical_parser_test.cc} (56%) delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_maximum_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_minimum_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_mul_parser_test.cc delete 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_pooling_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_pow_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_max_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_min_parser_test.cc create mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_prod_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_relu_parser_test.cc rename mindspore/lite/test/ut/tools/converter/parser/tflite/{tflite_p_relu_parser_test.cc => tflite_reshape_parser_test.cc} (70%) rename mindspore/lite/test/ut/tools/converter/parser/tflite/{tflite_resize_nn_parser_test.cc => tflite_resize_parser_test.cc} (57%) delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_round_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_rsqrt_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sin_parser_test.cc rename mindspore/lite/test/ut/tools/converter/parser/tflite/{tflite_greater_parser_test.cc => tflite_softmax_parser_test.cc} (64%) delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sqrt_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_square_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_squared_difference_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sub_parser_test.cc delete mode 100644 mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sum_parser_test.cc diff --git a/mindspore/lite/schema/ops.fbs b/mindspore/lite/schema/ops.fbs index 27b3b942d5..d43ccf192f 100644 --- a/mindspore/lite/schema/ops.fbs +++ b/mindspore/lite/schema/ops.fbs @@ -345,6 +345,7 @@ table DetectionPostProcess { table FullConnection { hasBias: bool; axis: int; + useAxis: bool; } // Mean(input_tensor, axis, keep_dims) diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/avg_pooling.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/avg_pooling.tflite new file mode 100644 index 0000000000000000000000000000000000000000..9f00254037117fd2a8348bfcbcb1cd525fa877b9 GIT binary patch literal 544 zcmZvZ%}T>S6oqd!{h`!YRK!IVUAS-|!6Jf7MG=GwMcjvCg9h>gvGy5!fIg8c7cP7V zA47=W$uzie;F~-5&Yd$SnZV2*ZYHN@I~JH{Jsa52_NX3EG1~-}nZ4Cjvm;^)u9*~9 z;K3KkCw#yKx%LJiO)2;4wbR^Xoh5lxzUGT0i=$;+z9dCXwL_oB>@(iZ4;(mG_NWBdk~u-Jcs1bnbr zgLiPr-e&_~PBZsH+;JWdS7kk4zSK=w74z3(xhfYm*&XT<){b+CKg%!jQ+%{Ng4@~6 z-S}!z)7KP_Ihhp2fBI80)}4Vdm;meE1Ye*5)@QSiaJ^@#9!kWdfy4TDc@=YFM>`@d-KFzzw`9%IZSTe?ruljkN9r)xc-0dHaVVR M<(YoCBZ0-8zYk6*Z~y=R literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/max_pooling.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/max_pooling.tflite new file mode 100644 index 0000000000000000000000000000000000000000..c60b183b4146bb1463eea29c0be635275dc82fbc GIT binary patch literal 544 zcmZ9Jy-LJD6os#v{b3Dp)kQ5*Y++#)6tUYv5JX`Y7O`J~8!(U`h^zPrK7fVKV`X9C zWB3q4{7!}-IPlHAb7pdKk_pZ1_Hue^wqv1r);HgVHbOl>G1~yQGJ9!Mvm@#nTrsJ> zf(KtLKH&q-S!>S+dCIxp^v-jaK2M89^;oRZJXt&?)k9hqs9nx^%+7O2J&DeuV`@9L zXlB#voAE_i@Z2g{MkoP^|MCYY${oTO4neus;TzsS`7~5pbY9<*$0=a~+oMevzFE&Ji!v*Z?m@MsM?Z_7 s=Vh6pbsJq-Mos5#QCZ|A-~V16G$FrDm}l`_a$jc4q_Q6}cB3&?7|K z|DBW6z`rwR=IlTJ%x+|6Pj{mWvjdB)Vs&d;+d9g2l`-29!pZE_XU$IJOTwid_%~r! z7?jQW!c56X{#rTeO#xom>pnKcW{1Ke&EkBMt*nwjNRfAjew8N5e| z(O#1pcxA_Mb_M1#tEyhp(_3lF1s@iAG&}=LjgTIYe=drG8PP>wc%4yquX2?$g{Qo9SBXkJBtkr*1{xs_zYF l$4BAsfD;}#(9M4T>qa~0J>g+KnY!6>p19n;q`jgFwIAT#IK2P> literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/relu6.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/relu6.tflite new file mode 100644 index 0000000000000000000000000000000000000000..530e02625671f18c44da9e490a1218be9d8b5e32 GIT binary patch literal 476 zcmZvZ%}T>i5QRsLwbW9JR_G#&EL^w>is)Jp1fhZy_obK%2J!>3^$A>b;nK(ONqiU&n2;$J>JeP%nmKK$oe+4u}xs7FlIX-RAw8`nw=82#B(TqfC#)( zY``11rdDqVq$%aT&x7U>d6`#>W?ilF(k)(H^ODyUY>&B!GiZ*9=jmm7M(n-=lKa`+ zJh`bW_Es)SVMaLq^FM--?-(TD1jzR`_yie{KYfZFrsR4{xy&&$@cyMbfRh*Xy4h|& z%HVj%5C2dspWJg@ NWUjGq?u^)%{trcYCxQR~ literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/reshape.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/reshape.tflite new file mode 100644 index 0000000000000000000000000000000000000000..0599e6ee9b70cbad1c44951f9502f726884015be GIT binary patch literal 596 zcmYjO!AiqG5PjCzhFWXUB0c1gg9i^16%o7(QlWwr&z4{p5@ax@aSjxIUc0( zz1;>~cssMRGjHDPMgSgfCzrqhA_NH0!vI4@M~nd5gg*iAE()B|Zpr5+`$6mwL5mwP zX7HQ1=27=OLcC%RozGm_L!!v-ta`PpyfCvjQ!Vq-V!f_w-4BS1737TC$QZJ0jG(NOKExopv#I8IvB} zHTkO1@;u7z@Z@vp94Y=(*R|@@Tio%+*I92SovNCeWtP4ed@>(slO^Ep`|17u=lgj> z*7?8Eyj(5yktSKqt^TUpBR2eJzKeLY=h{+?7V%uZ{F-C5rEr^@iDN22mzXCqlZ0aLuP<=!mogrDhnKt*N6cp@hh=G z^cz4-WK4$S5p&va6VjD>vx>nO*d=DxO^OG%v@aO+!q(6-Q+Co=vTju5{#m zi*BUL(G5B2PCEBauXVjNG`w!Bs#0~!r}vdl%d*tHV!IY|di>J!_ZM_}o4CoRcjkVcXQr48x&ET}fVDp#dZ04^feTfo_$D$~t)g`CFSukO&#vzlN z+4bGRS!tdym+v~ANR#70 zT79BB0sHKGoHg=`N~h8Wn(k|58fac1R=>bS7cTt_zr=46 z;<@iNxG`|w%-or|?>-Wn+2U?~Wp-+@Mb@{Wjco!ug)ut-p)%Wg*6f0~C!Ry`6GY&H zVhi5E4YhhhAWbRveI7K=$g9#Vn^(6ft77?9G%scCV0+9(oI!I;oTant^pa%voe&@9 z_fN@f?bzECc?vVa@t^+@jC{u+0p~!z_rVv)f&A%H>@X$QTdJ(Y%)tAX>Htn&)az!u z{V;b#C(Mz=>V3Cus~z1bFUc-HBuYnEWNt+u@A+EqnD{LG3B5xa()&;282)jcJr}Eb OofnP$aA(B6w0{9>H79id literal 0 HcmV?d00001 diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_abs_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_abs_parser_test.cc deleted file mode 100644 index 7f0453bd11..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_abs_parser_test.cc +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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 TestTfliteParserAbs : public TestTfliteParser { - public: - TestTfliteParserAbs() = default; - void SetUp() override { meta_graph = LoadAndConvert("./abs.tflite", ""); } -}; - -TEST_F(TestTfliteParserAbs, 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_Abs) << "wrong Op Type"; -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_activation_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_activation_parser_test.cc new file mode 100644 index 0000000000..24f2a34899 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_activation_parser_test.cc @@ -0,0 +1,105 @@ +/** + * 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 TestTfliteParserRelu : public TestTfliteParser { + public: + TestTfliteParserRelu() = default; + void SetUp() override { meta_graph = LoadAndConvert("./relu.tflite", ""); } +}; + +TEST_F(TestTfliteParserRelu, OpType) { + 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_Activation) << "wrong Op Type"; +} + +class TestTfliteParserRelu6 : public TestTfliteParser { + public: + TestTfliteParserRelu6() = default; + void SetUp() override { meta_graph = LoadAndConvert("./relu6.tflite", ""); } +}; + +TEST_F(TestTfliteParserRelu6, OpType) { + 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_Activation) << "wrong Op Type"; +} + +class TestTfliteParserTanh : public TestTfliteParser { + public: + TestTfliteParserTanh() = default; + void SetUp() override { meta_graph = LoadAndConvert("./tanh.tflite", ""); } +}; + +TEST_F(TestTfliteParserTanh, OpType) { + 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_Activation) << "wrong Op Type"; +} + +// logistic + +class TestTfliteParserPrelu : public TestTfliteParser { + public: + TestTfliteParserPrelu() = default; + 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); +} + +class TestTfliteParserLeakyRelu : public TestTfliteParser { + public: + TestTfliteParserLeakyRelu() = default; + void SetUp() override { meta_graph = LoadAndConvert("./leaky_relu.tflite", ""); } +}; + +TEST_F(TestTfliteParserLeakyRelu, OpType) { + 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_LeakyReLU) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserLeakyRelu, AttrValue) { + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + + auto val = meta_graph->nodes.front()->primitive->value.AsLeakyReLU(); + ASSERT_NE(val, nullptr); + ASSERT_EQ(val->negativeSlope, 0.20000000298023224); +} + +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_add_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_add_parser_test.cc deleted file mode 100644 index d590be8131..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_add_parser_test.cc +++ /dev/null @@ -1,78 +0,0 @@ -/** - * 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 TestTfliteParserAdd1 : public TestTfliteParser { - public: - TestTfliteParserAdd1() = default; - void SetUp() override { meta_graph = LoadAndConvert("./add1.tflite", ""); } -}; - -TEST_F(TestTfliteParserAdd1, OpType) { - 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_Add) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserAdd1, Tensor) { - ASSERT_GT(meta_graph->allTensors.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); - ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); -} - -class TestTfliteParserAdd2 : public TestTfliteParser { - public: - TestTfliteParserAdd2() = default; - void SetUp() override { meta_graph = LoadAndConvert("./add2.tflite", ""); } -}; - -TEST_F(TestTfliteParserAdd2, OpType) { - 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_Add) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserAdd2, Tensor) { - ASSERT_GT(meta_graph->allTensors.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); - ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); -} - -class TestTfliteParserAdd3 : public TestTfliteParser { - public: - TestTfliteParserAdd3() = default; - void SetUp() override { meta_graph = LoadAndConvert("./add3.tflite", ""); } -}; - -TEST_F(TestTfliteParserAdd3, OpType) { - 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_Add) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserAdd3, Tensor) { - ASSERT_GT(meta_graph->allTensors.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(1)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_arithmetic_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_arithmetic_parser_test.cc new file mode 100644 index 0000000000..64056ecde4 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_arithmetic_parser_test.cc @@ -0,0 +1,576 @@ +/** + * 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 { +// doubleInputOp +class TestTfliteParserAdd1 : public TestTfliteParser { + public: + TestTfliteParserAdd1() = default; + void SetUp() override { meta_graph = LoadAndConvert("./add1.tflite", ""); } +}; + +TEST_F(TestTfliteParserAdd1, OpType) { + 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_Add) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserAdd1, Tensor) { + ASSERT_GT(meta_graph->allTensors.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); + ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); +} + +class TestTfliteParserAdd2 : public TestTfliteParser { + public: + TestTfliteParserAdd2() = default; + void SetUp() override { meta_graph = LoadAndConvert("./add2.tflite", ""); } +}; + +TEST_F(TestTfliteParserAdd2, OpType) { + 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_Add) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserAdd2, Tensor) { + ASSERT_GT(meta_graph->allTensors.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); + ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); +} + +class TestTfliteParserAdd3 : public TestTfliteParser { + public: + TestTfliteParserAdd3() = default; + void SetUp() override { meta_graph = LoadAndConvert("./add3.tflite", ""); } +}; + +TEST_F(TestTfliteParserAdd3, OpType) { + 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_Add) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserAdd3, Tensor) { + ASSERT_GT(meta_graph->allTensors.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(1)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); +} + +class TestTfliteParserSub1 : public TestTfliteParser { + public: + TestTfliteParserSub1() = default; + void SetUp() override { meta_graph = LoadAndConvert("./sub1.tflite", ""); } +}; + +TEST_F(TestTfliteParserSub1, OpType) { + 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_Sub) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserSub1, Tensor) { + ASSERT_GT(meta_graph->allTensors.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); + ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); +} + +class TestTfliteParserSub2 : public TestTfliteParser { + public: + TestTfliteParserSub2() = default; + void SetUp() override { meta_graph = LoadAndConvert("./sub2.tflite", ""); } +}; + +TEST_F(TestTfliteParserSub2, OpType) { + 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_Sub) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserSub2, Tensor) { + ASSERT_GT(meta_graph->allTensors.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); + ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); +} + +class TestTfliteParserSub3 : public TestTfliteParser { + public: + TestTfliteParserSub3() = default; + void SetUp() override { meta_graph = LoadAndConvert("./sub3.tflite", ""); } +}; + +TEST_F(TestTfliteParserSub3, OpType) { + 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_Sub) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserSub3, Tensor) { + ASSERT_GT(meta_graph->allTensors.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(1)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); +} + +class TestTfliteParserMul1 : public TestTfliteParser { + public: + TestTfliteParserMul1() = default; + void SetUp() override { meta_graph = LoadAndConvert("./mul1.tflite", ""); } +}; + +TEST_F(TestTfliteParserMul1, OpType) { + 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_Mul) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserMul1, Tensor) { + ASSERT_GT(meta_graph->allTensors.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); + ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); +} + +class TestTfliteParserMul2 : public TestTfliteParser { + public: + TestTfliteParserMul2() = default; + void SetUp() override { meta_graph = LoadAndConvert("./mul2.tflite", ""); } +}; + +TEST_F(TestTfliteParserMul2, OpType) { + 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_Mul) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserMul2, Tensor) { + ASSERT_GT(meta_graph->allTensors.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); + ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); +} + +class TestTfliteParserMul3 : public TestTfliteParser { + public: + TestTfliteParserMul3() = default; + void SetUp() override { meta_graph = LoadAndConvert("./mul3.tflite", ""); } +}; + +TEST_F(TestTfliteParserMul3, OpType) { + 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_Mul) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserMul3, Tensor) { + ASSERT_GT(meta_graph->allTensors.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(1)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); +} + +class TestTfliteParserDiv1 : public TestTfliteParser { + public: + TestTfliteParserDiv1() = default; + void SetUp() override { meta_graph = LoadAndConvert("./div1.tflite", ""); } +}; + +TEST_F(TestTfliteParserDiv1, OpType) { + 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_Div) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserDiv1, Tensor) { + ASSERT_GT(meta_graph->allTensors.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); + ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); +} + +class TestTfliteParserDiv2 : public TestTfliteParser { + public: + TestTfliteParserDiv2() = default; + void SetUp() override { meta_graph = LoadAndConvert("./div2.tflite", ""); } +}; + +TEST_F(TestTfliteParserDiv2, OpType) { + 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_Div) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserDiv2, Tensor) { + ASSERT_GT(meta_graph->allTensors.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); + ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); +} + +class TestTfliteParserDiv3 : public TestTfliteParser { + public: + TestTfliteParserDiv3() = default; + void SetUp() override { meta_graph = LoadAndConvert("./div3.tflite", ""); } +}; + +TEST_F(TestTfliteParserDiv3, OpType) { + 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_Div) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserDiv3, Tensor) { + ASSERT_GT(meta_graph->allTensors.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(1)->data.size(), 0); + ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); +} + +class TestTfliteParserFloorDiv : public TestTfliteParser { + public: + TestTfliteParserFloorDiv() = default; + void SetUp() override { meta_graph = LoadAndConvert("./floor_div.tflite", ""); } +}; + +TEST_F(TestTfliteParserFloorDiv, OpType) { + 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_FloorDiv) << "wrong Op Type"; +} + +class TestTfliteParserFloorMod : public TestTfliteParser { + public: + TestTfliteParserFloorMod() = default; + void SetUp() override { meta_graph = LoadAndConvert("./floor_mod.tflite", ""); } +}; + +TEST_F(TestTfliteParserFloorMod, OpType) { + 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_FloorMod) << "wrong Op Type"; +} + +// realDiv + +class TestTfliteParserSquaredDifference : public TestTfliteParser { + public: + TestTfliteParserSquaredDifference() = default; + 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"; +} + +class TestTfliteParserPow : public TestTfliteParser { + public: + TestTfliteParserPow() = default; + void SetUp() override { meta_graph = LoadAndConvert("./pow.tflite", ""); } +}; + +TEST_F(TestTfliteParserPow, OpType) { + 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_Power) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserPow, AttrValue) { + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + + auto val = meta_graph->nodes.front()->primitive->value.AsPower(); + + ASSERT_EQ(val->scale, 1.0); + ASSERT_EQ(val->shift, 0.0); + ASSERT_EQ(val->power, 0.0); +} + +class TestTfliteParserMaximum : public TestTfliteParser { + public: + TestTfliteParserMaximum() = default; + void SetUp() override { meta_graph = LoadAndConvert("./maximum.tflite"); } +}; + +TEST_F(TestTfliteParserMaximum, 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_Maximum) << "wrong Op Type"; +} + +class TestTfliteParserMinimum : public TestTfliteParser { + public: + TestTfliteParserMinimum() = default; + void SetUp() override { meta_graph = LoadAndConvert("./minimum.tflite"); } +}; + +TEST_F(TestTfliteParserMinimum, 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_Minimum) << "wrong Op Type"; +} + +// singleInputOp +class TestTfliteParserAbs : public TestTfliteParser { + public: + TestTfliteParserAbs() = default; + void SetUp() override { meta_graph = LoadAndConvert("./abs.tflite", ""); } +}; + +TEST_F(TestTfliteParserAbs, 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_Abs) << "wrong Op Type"; +} + +class TestTfliteParserExp : public TestTfliteParser { + public: + TestTfliteParserExp() = default; + void SetUp() override { meta_graph = LoadAndConvert("./exp.tflite", ""); } +}; + +TEST_F(TestTfliteParserExp, 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"; +} + +class TestTfliteParserSqrt : public TestTfliteParser { + public: + TestTfliteParserSqrt() = default; + void SetUp() override { meta_graph = LoadAndConvert("./sqrt.tflite", ""); } +}; + +TEST_F(TestTfliteParserSqrt, 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_Sqrt) << "wrong Op Type"; +} + +class TestTfliteParserRsqrt : public TestTfliteParser { + public: + TestTfliteParserRsqrt() = default; + void SetUp() override { meta_graph = LoadAndConvert("./rsqrt.tflite", ""); } +}; + +TEST_F(TestTfliteParserRsqrt, 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_Rsqrt) << "wrong Op Type"; +} + +class TestTfliteParserSquare : public TestTfliteParser { + public: + TestTfliteParserSquare() = default; + void SetUp() override { meta_graph = LoadAndConvert("./square.tflite", ""); } +}; + +TEST_F(TestTfliteParserSquare, 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_Square) << "wrong Op Type"; +} + +class TestTfliteParserSin : public TestTfliteParser { + public: + TestTfliteParserSin() = default; + void SetUp() override { meta_graph = LoadAndConvert("./sin.tflite", ""); } +}; + +TEST_F(TestTfliteParserSin, 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_Sin) << "wrong Op Type"; +} + +class TestTfliteParserCos : public TestTfliteParser { + public: + TestTfliteParserCos() = default; + void SetUp() override { meta_graph = LoadAndConvert("./cos.tflite", ""); } +}; + +TEST_F(TestTfliteParserCos, 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_Cos) << "wrong Op Type"; +} + +class TestTfliteParserLog : public TestTfliteParser { + public: + TestTfliteParserLog() = default; + void SetUp() override { meta_graph = LoadAndConvert("./log.tflite", ""); } +}; + +TEST_F(TestTfliteParserLog, 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_Log) << "wrong Op Type"; +} + +class TestTfliteParserRound : public TestTfliteParser { + public: + TestTfliteParserRound() = default; + 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"; +} + +class TestTfliteParserCeil : public TestTfliteParser { + public: + TestTfliteParserCeil() = default; + void SetUp() override { meta_graph = LoadAndConvert("./ceil.tflite", ""); } +}; + +TEST_F(TestTfliteParserCeil, OpType) { + 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_Ceil) << "wrong Op Type"; +} + +class TestTfliteParserFloor : public TestTfliteParser { + public: + TestTfliteParserFloor() = default; + void SetUp() override { meta_graph = LoadAndConvert("./floor.tflite", ""); } +}; + +TEST_F(TestTfliteParserFloor, OpType) { + 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_Floor) << "wrong Op Type"; +} + +// comareOp +class TestTfliteParserEqual : public TestTfliteParser { + public: + TestTfliteParserEqual() = default; + 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"; +} + +class TestTfliteParserNotEqual : public TestTfliteParser { + public: + TestTfliteParserNotEqual() = default; + 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"; +} + +class TestTfliteParserGreater : public TestTfliteParser { + public: + TestTfliteParserGreater() = default; + 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"; +} + +class TestTfliteParserGreaterEqual : public TestTfliteParser { + public: + TestTfliteParserGreaterEqual() = default; + 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"; +} + +class TestTfliteParserLess : public TestTfliteParser { + public: + TestTfliteParserLess() = default; + void SetUp() override { + meta_graph = LoadAndConvert("./less.tflite"); + } +}; + +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_Less) << "wrong Op Type"; +} + +class TestTfliteParserLessEqual : public TestTfliteParser { + public: + TestTfliteParserLessEqual() = default; + 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_ceil_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_ceil_parser_test.cc deleted file mode 100644 index 59d8664be1..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_ceil_parser_test.cc +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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 TestTfliteParserCeil : public TestTfliteParser { - public: - TestTfliteParserCeil() = default; - void SetUp() override { meta_graph = LoadAndConvert("./ceil.tflite", ""); } -}; - -TEST_F(TestTfliteParserCeil, OpType) { - 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_Ceil) << "wrong Op Type"; -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cos_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cos_parser_test.cc deleted file mode 100644 index 756cd626c6..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cos_parser_test.cc +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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 TestTfliteParserCos : public TestTfliteParser { - public: - TestTfliteParserCos() = default; - void SetUp() override { meta_graph = LoadAndConvert("./cos.tflite", ""); } -}; - -TEST_F(TestTfliteParserCos, 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_Cos) << "wrong Op Type"; -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_div_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_div_parser_test.cc deleted file mode 100644 index 8ee47212a4..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_div_parser_test.cc +++ /dev/null @@ -1,78 +0,0 @@ -/** - * 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 TestTfliteParserDiv1 : public TestTfliteParser { - public: - TestTfliteParserDiv1() = default; - void SetUp() override { meta_graph = LoadAndConvert("./div1.tflite", ""); } -}; - -TEST_F(TestTfliteParserDiv1, OpType) { - 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_Div) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserDiv1, Tensor) { - ASSERT_GT(meta_graph->allTensors.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); - ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); -} - -class TestTfliteParserDiv2 : public TestTfliteParser { - public: - TestTfliteParserDiv2() = default; - void SetUp() override { meta_graph = LoadAndConvert("./div2.tflite", ""); } -}; - -TEST_F(TestTfliteParserDiv2, OpType) { - 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_Div) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserDiv2, Tensor) { - ASSERT_GT(meta_graph->allTensors.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); - ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); -} - -class TestTfliteParserDiv3 : public TestTfliteParser { - public: - TestTfliteParserDiv3() = default; - void SetUp() override { meta_graph = LoadAndConvert("./div3.tflite", ""); } -}; - -TEST_F(TestTfliteParserDiv3, OpType) { - 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_Div) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserDiv3, Tensor) { - ASSERT_GT(meta_graph->allTensors.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(1)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); -} - -} // 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 deleted file mode 100644 index ba2e4b0f51..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_equal_parser_test.cc +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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() = default; - 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_floor_div_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_div_parser_test.cc deleted file mode 100644 index d92c1608a7..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_div_parser_test.cc +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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 TestTfliteParserFloorDiv : public TestTfliteParser { - public: - TestTfliteParserFloorDiv() = default; - void SetUp() override { meta_graph = LoadAndConvert("./floor_div.tflite", ""); } -}; - -TEST_F(TestTfliteParserFloorDiv, OpType) { - 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_FloorDiv) << "wrong Op Type"; -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_mod_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_mod_parser_test.cc deleted file mode 100644 index f8cf0fdf03..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_mod_parser_test.cc +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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 TestTfliteParserFloorMod : public TestTfliteParser { - public: - TestTfliteParserFloorMod() = default; - void SetUp() override { meta_graph = LoadAndConvert("./floor_mod.tflite", ""); } -}; - -TEST_F(TestTfliteParserFloorMod, OpType) { - 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_FloorMod) << "wrong Op Type"; -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_parser_test.cc deleted file mode 100644 index d7777f24b9..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_parser_test.cc +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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 TestTfliteParserFloor : public TestTfliteParser { - public: - TestTfliteParserFloor() = default; - void SetUp() override { meta_graph = LoadAndConvert("./floor.tflite", ""); } -}; - -TEST_F(TestTfliteParserFloor, OpType) { - 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_Floor) << "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 deleted file mode 100644 index c65b80cc88..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_equal_parser_test.cc +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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() = default; - 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_leaky_relu_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_leaky_relu_parser_test.cc deleted file mode 100644 index 80c8826088..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_leaky_relu_parser_test.cc +++ /dev/null @@ -1,42 +0,0 @@ -/** - * 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 TestTfliteParserLeakyRelu : public TestTfliteParser { - public: - TestTfliteParserLeakyRelu() = default; - void SetUp() override { meta_graph = LoadAndConvert("./leaky_relu.tflite", ""); } -}; - -TEST_F(TestTfliteParserLeakyRelu, OpType) { - 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_LeakyReLU) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserLeakyRelu, AttrValue) { - ASSERT_GT(meta_graph->nodes.size(), 0); - ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); - - auto val = meta_graph->nodes.front()->primitive->value.AsLeakyReLU(); - ASSERT_NE(val, nullptr); - ASSERT_EQ(val->negativeSlope, 0.20000000298023224); -} - -} // 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 deleted file mode 100644 index 06f57a4bab..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_equal_parser_test.cc +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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() = default; - 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_less_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_parser_test.cc deleted file mode 100644 index 1872d2d3f1..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_parser_test.cc +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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 TestTfliteParserLess : public TestTfliteParser { - public: - TestTfliteParserLess() = default; - void SetUp() override { - meta_graph = LoadAndConvert("./less.tflite"); - } -}; - -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_Less) << "wrong Op Type"; -} -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_log_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_log_parser_test.cc deleted file mode 100644 index 22976eceb8..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_log_parser_test.cc +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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 TestTfliteParserLog : public TestTfliteParser { - public: - TestTfliteParserLog() = default; - void SetUp() override { meta_graph = LoadAndConvert("./log.tflite", ""); } -}; - -TEST_F(TestTfliteParserLog, 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_Log) << "wrong Op Type"; -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_and_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_and_parser_test.cc deleted file mode 100644 index a1a5159ae0..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_and_parser_test.cc +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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 TestTfliteLogicalParserAnd : public TestTfliteParser { - public: - TestTfliteLogicalParserAnd() = default; - void SetUp() override { meta_graph = LoadAndConvert("./logical_and.tflite", ""); } -}; - -TEST_F(TestTfliteLogicalParserAnd, 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_LogicalAnd) << "wrong Op Type"; -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_or_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_or_parser_test.cc deleted file mode 100644 index 508293542f..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_or_parser_test.cc +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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 TestTfliteParserLogicalOr : public TestTfliteParser { - public: - TestTfliteParserLogicalOr() = default; - void SetUp() override { meta_graph = LoadAndConvert("./logical_or.tflite", ""); } -}; - -TEST_F(TestTfliteParserLogicalOr, 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_LogicalOr) << "wrong Op Type"; -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_not_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_parser_test.cc similarity index 56% rename from mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_not_parser_test.cc rename to mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_parser_test.cc index cb2c21411e..5a969bfe41 100644 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_not_parser_test.cc +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_parser_test.cc @@ -18,6 +18,19 @@ #include "common/common_test.h" namespace mindspore { +class TestTfliteLogicalParserAnd : public TestTfliteParser { + public: + TestTfliteLogicalParserAnd() = default; + void SetUp() override { meta_graph = LoadAndConvert("./logical_and.tflite", ""); } +}; + +TEST_F(TestTfliteLogicalParserAnd, 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_LogicalAnd) << "wrong Op Type"; +} + class TestTfliteParserLogicalNot : public TestTfliteParser { public: TestTfliteParserLogicalNot() = default; @@ -31,4 +44,18 @@ TEST_F(TestTfliteParserLogicalNot, OpType) { ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_LogicalNot) << "wrong Op Type"; } +class TestTfliteParserLogicalOr : public TestTfliteParser { + public: + TestTfliteParserLogicalOr() = default; + void SetUp() override { meta_graph = LoadAndConvert("./logical_or.tflite", ""); } +}; + +TEST_F(TestTfliteParserLogicalOr, 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_LogicalOr) << "wrong Op Type"; +} + + } // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_maximum_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_maximum_parser_test.cc deleted file mode 100644 index b99119df5a..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_maximum_parser_test.cc +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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 TestTfliteParserMaximum : public TestTfliteParser { - public: - TestTfliteParserMaximum() = default; - void SetUp() override { meta_graph = LoadAndConvert("./maximum.tflite"); } -}; - -TEST_F(TestTfliteParserMaximum, 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_Maximum) << "wrong Op Type"; -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_minimum_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_minimum_parser_test.cc deleted file mode 100644 index 431a15e5bd..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_minimum_parser_test.cc +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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 TestTfliteParserMinimum : public TestTfliteParser { - public: - TestTfliteParserMinimum() = default; - void SetUp() override { meta_graph = LoadAndConvert("./minimum.tflite"); } -}; - -TEST_F(TestTfliteParserMinimum, 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_Minimum) << "wrong Op Type"; -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_mul_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_mul_parser_test.cc deleted file mode 100644 index 140960e53b..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_mul_parser_test.cc +++ /dev/null @@ -1,78 +0,0 @@ -/** - * 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 TestTfliteParserMul1 : public TestTfliteParser { - public: - TestTfliteParserMul1() = default; - void SetUp() override { meta_graph = LoadAndConvert("./mul1.tflite", ""); } -}; - -TEST_F(TestTfliteParserMul1, OpType) { - 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_Mul) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserMul1, Tensor) { - ASSERT_GT(meta_graph->allTensors.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); - ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); -} - -class TestTfliteParserMul2 : public TestTfliteParser { - public: - TestTfliteParserMul2() = default; - void SetUp() override { meta_graph = LoadAndConvert("./mul2.tflite", ""); } -}; - -TEST_F(TestTfliteParserMul2, OpType) { - 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_Mul) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserMul2, Tensor) { - ASSERT_GT(meta_graph->allTensors.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); - ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); -} - -class TestTfliteParserMul3 : public TestTfliteParser { - public: - TestTfliteParserMul3() = default; - void SetUp() override { meta_graph = LoadAndConvert("./mul3.tflite", ""); } -}; - -TEST_F(TestTfliteParserMul3, OpType) { - 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_Mul) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserMul3, Tensor) { - ASSERT_GT(meta_graph->allTensors.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(1)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); -} - -} // 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 deleted file mode 100644 index 3e697c862e..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_not_equal_parser_test.cc +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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() = default; - 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_pooling_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_pooling_parser_test.cc new file mode 100644 index 0000000000..d234a76a32 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_pooling_parser_test.cc @@ -0,0 +1,95 @@ +/** + * 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 TestTfliteParserMaxPooling : public TestTfliteParser { + public: + TestTfliteParserMaxPooling() = default; + void SetUp() override { + meta_graph = LoadAndConvert("./max_pooling.tflite"); + } +}; + +TEST_F(TestTfliteParserMaxPooling, 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_Pooling) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserMaxPooling, AttrValue) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + + auto val = meta_graph->nodes.front()->primitive->value.AsPooling(); + ASSERT_NE(val, nullptr); + ASSERT_EQ(val->format, schema::Format_NHWC); + ASSERT_EQ(val->poolingMode, schema::PoolMode_MAX_POOLING); + ASSERT_EQ(val->global, false); + ASSERT_EQ(val->windowW, 2); + ASSERT_EQ(val->windowH, 2); + ASSERT_EQ(val->strideW, 1); + ASSERT_EQ(val->strideH, 1); + ASSERT_EQ(val->padMode, schema::PadMode_VALID); + ASSERT_EQ(val->padUp, 0); + ASSERT_EQ(val->padDown, 0); + ASSERT_EQ(val->padLeft, 0); + ASSERT_EQ(val->padRight, 0); + ASSERT_EQ(val->roundMode, schema::RoundMode_FLOOR); +} + +class TestTfliteParserAvgPooling : public TestTfliteParser { + public: + TestTfliteParserAvgPooling() = default; + void SetUp() override { + meta_graph = LoadAndConvert("./avg_pooling.tflite"); + } +}; + +TEST_F(TestTfliteParserAvgPooling, 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_Pooling) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserAvgPooling, AttrValue) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + + auto val = meta_graph->nodes.front()->primitive->value.AsPooling(); + ASSERT_NE(val, nullptr); + ASSERT_EQ(val->format, schema::Format_NHWC); + ASSERT_EQ(val->poolingMode, schema::PoolMode_MEAN_POOLING); + ASSERT_EQ(val->global, false); + ASSERT_EQ(val->windowW, 2); + ASSERT_EQ(val->windowH, 2); + ASSERT_EQ(val->strideW, 1); + ASSERT_EQ(val->strideH, 1); + ASSERT_EQ(val->padMode, schema::PadMode_SAME); + ASSERT_EQ(val->padUp, 0); + ASSERT_EQ(val->padDown, 1); + ASSERT_EQ(val->padLeft, 0); + ASSERT_EQ(val->padRight, 1); + ASSERT_EQ(val->roundMode, schema::RoundMode_FLOOR); +} +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_pow_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_pow_parser_test.cc deleted file mode 100644 index 52188a5d9b..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_pow_parser_test.cc +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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 TestTfliteParserPow : public TestTfliteParser { - public: - TestTfliteParserPow() = default; - void SetUp() override { meta_graph = LoadAndConvert("./pow.tflite", ""); } -}; - -TEST_F(TestTfliteParserPow, OpType) { - 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_Power) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserPow, AttrValue) { - ASSERT_GT(meta_graph->nodes.size(), 0); - ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); - - auto val = meta_graph->nodes.front()->primitive->value.AsPower(); - - ASSERT_EQ(val->scale, 1.0); - ASSERT_EQ(val->shift, 0.0); - ASSERT_EQ(val->power, 0.0); -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_max_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_max_parser_test.cc deleted file mode 100644 index 8b5c97a3f8..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_max_parser_test.cc +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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 TestTfliteParserReduceMax : public TestTfliteParser { - public: - TestTfliteParserReduceMax() = default; - void SetUp() override { meta_graph = LoadAndConvert("./reduce_max.tflite"); } -}; - -TEST_F(TestTfliteParserReduceMax, 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_Reduce) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserReduceMax, 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.AsReduce(), nullptr); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->mode, schema::ReduceMode_ReduceMax) - << "wrong reduce mode"; - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->keepDims, false); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->axes.size(), 1); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->axes[0], 2); -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_min_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_min_parser_test.cc deleted file mode 100644 index 01995e9bba..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_min_parser_test.cc +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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 TestTfliteParserReduceMin : public TestTfliteParser { - public: - TestTfliteParserReduceMin() = default; - void SetUp() override { meta_graph = LoadAndConvert("./reduce_min.tflite"); } -}; - -TEST_F(TestTfliteParserReduceMin, 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_Reduce) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserReduceMin, 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.AsReduce(), nullptr); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->mode, schema::ReduceMode_ReduceMin) - << "wrong reduce mode"; - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->keepDims, false); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->axes.size(), 1); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->axes[0], 2); -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_parser_test.cc new file mode 100644 index 0000000000..bf790bd842 --- /dev/null +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_parser_test.cc @@ -0,0 +1,155 @@ +/** + * 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 TestTfliteParserReduceMax : public TestTfliteParser { + public: + TestTfliteParserReduceMax() = default; + void SetUp() override { meta_graph = LoadAndConvert("./reduce_max.tflite"); } +}; + +TEST_F(TestTfliteParserReduceMax, 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_Reduce) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserReduceMax, AttrValue) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + + auto val = meta_graph->nodes.front()->primitive->value.AsReduce(); + ASSERT_NE(val, nullptr); + ASSERT_EQ(val->mode, schema::ReduceMode_ReduceMax) << "wrong reduce mode"; + ASSERT_EQ(val->keepDims, false); + std::vector axes = {2}; + ASSERT_EQ(val->axes, axes); +} + +class TestTfliteParserReduceMin : public TestTfliteParser { + public: + TestTfliteParserReduceMin() = default; + void SetUp() override { meta_graph = LoadAndConvert("./reduce_min.tflite"); } +}; + +TEST_F(TestTfliteParserReduceMin, 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_Reduce) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserReduceMin, AttrValue) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + + auto val = meta_graph->nodes.front()->primitive->value.AsReduce(); + ASSERT_NE(val, nullptr); + ASSERT_EQ(val->mode, schema::ReduceMode_ReduceMin) << "wrong reduce mode"; + ASSERT_EQ(val->keepDims, false); + std::vector axes = {2}; + ASSERT_EQ(val->axes, axes); +} + +class TestTfliteParserReduceProd : public TestTfliteParser { + public: + TestTfliteParserReduceProd() = default; + void SetUp() override { meta_graph = LoadAndConvert("./reduce_prod.tflite"); } +}; + +TEST_F(TestTfliteParserReduceProd, 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_Reduce) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserReduceProd, AttrValue) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + + auto val = meta_graph->nodes.front()->primitive->value.AsReduce(); + ASSERT_NE(val, nullptr); + ASSERT_EQ(val->mode, schema::ReduceMode_ReduceProd) << "wrong reduce mode"; + ASSERT_EQ(val->keepDims, false); + std::vector axes = {2}; + ASSERT_EQ(val->axes, axes); +} + +class TestTfliteParserSum : public TestTfliteParser { + public: + TestTfliteParserSum() = default; + + void SetUp() override { meta_graph = LoadAndConvert("./sum.tflite"); } +}; + +TEST_F(TestTfliteParserSum, 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_Reduce) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserSum, AttrValue) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + + auto val = meta_graph->nodes.front()->primitive->value.AsReduce(); + ASSERT_NE(val, nullptr); + ASSERT_EQ(val->mode, schema::ReduceMode_ReduceSum) << "wrong reduce mode"; + ASSERT_EQ(val->keepDims, false); + std::vector axes = {2}; + ASSERT_EQ(val->axes, axes); +} + +class TestTfliteParserMean : public TestTfliteParser { + public: + TestTfliteParserMean() = default; + + void SetUp() override { meta_graph = LoadAndConvert("./mean.tflite"); } +}; + +TEST_F(TestTfliteParserMean, 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_Reduce) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserMean, AttrValue) { + ASSERT_NE(meta_graph, nullptr); + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + + auto val = meta_graph->nodes.front()->primitive->value.AsReduce(); + ASSERT_NE(val, nullptr); + ASSERT_EQ(val->mode, schema::ReduceMode_ReduceMean) << "wrong reduce mode"; + ASSERT_EQ(val->keepDims, true); + std::vector axes = {2, 3}; + ASSERT_EQ(val->axes, axes); +} + +// reduceAny + +} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_prod_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_prod_parser_test.cc deleted file mode 100644 index 2b0352231f..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_prod_parser_test.cc +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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 TestTfliteParserReduceProd : public TestTfliteParser { - public: - TestTfliteParserReduceProd() = default; - void SetUp() override { meta_graph = LoadAndConvert("./reduce_prod.tflite"); } -}; - -TEST_F(TestTfliteParserReduceProd, 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_Reduce) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserReduceProd, 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.AsReduce(), nullptr); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->mode, schema::ReduceMode_ReduceProd) - << "wrong reduce mode"; - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->keepDims, false); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->axes.size(), 1); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->axes[0], 2); -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_relu_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_relu_parser_test.cc deleted file mode 100644 index a0d44c30cd..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_relu_parser_test.cc +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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 TestTfliteParserRelu : public TestTfliteParser { - public: - TestTfliteParserRelu() = default; - void SetUp() override { meta_graph = LoadAndConvert("./relu.tflite", ""); } -}; - -TEST_F(TestTfliteParserRelu, OpType) { - 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_Activation) << "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_reshape_parser_test.cc similarity index 70% rename from mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_p_relu_parser_test.cc rename to mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reshape_parser_test.cc index 7b64cb1d02..a4eef7898b 100644 --- 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_reshape_parser_test.cc @@ -19,27 +19,28 @@ #include "common/common_test.h" namespace mindspore { -class TestTfliteParserPrelu : public TestTfliteParser { +class TestTfliteParserReshape : public TestTfliteParser { public: - TestTfliteParserPrelu() = default; + TestTfliteParserReshape() = default; void SetUp() override { - meta_graph = LoadAndConvert("./prelu.tflite"); + meta_graph = LoadAndConvert("./reshape.tflite"); } }; -TEST_F(TestTfliteParserPrelu, OpType) { +TEST_F(TestTfliteParserReshape, 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"; + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_Reshape) << "wrong Op Type"; } -TEST_F(TestTfliteParserPrelu, AttrValue) { - std::vector slope(20, 0); +TEST_F(TestTfliteParserReshape, 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.AsPrelu(), nullptr); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsPrelu()->slope, slope); + ASSERT_NE(meta_graph->nodes.front()->primitive->value.AsReshape(), nullptr); + + std::vector shape = {3, 5, 20}; + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReshape()->shape, shape); // int32 } } // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_resize_nn_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_resize_parser_test.cc similarity index 57% rename from mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_resize_nn_parser_test.cc rename to mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_resize_parser_test.cc index 199c560f13..ab0c9a9a25 100644 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_resize_nn_parser_test.cc +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_resize_parser_test.cc @@ -18,6 +18,7 @@ #include "common/common_test.h" namespace mindspore { + class TestTfliteParserResizeNN : public TestTfliteParser { public: TestTfliteParserResizeNN() = default; @@ -35,10 +36,39 @@ TEST_F(TestTfliteParserResizeNN, AttrValue) { ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); auto val = meta_graph->nodes.front()->primitive->value.AsResize(); - + ASSERT_NE(val, nullptr); ASSERT_EQ(val->alignCorners, false); ASSERT_EQ(val->newHeight, 3); ASSERT_EQ(val->newWidth, 100); + ASSERT_EQ(val->format, schema::Format_NHWC); + ASSERT_EQ(val->preserveAspectRatio, false); + ASSERT_EQ(val->method, schema::ResizeMethod_NEAREST_NEIGHBOR); +} + +class TestTfliteParserResizeBilinear : public TestTfliteParser { + public: + TestTfliteParserResizeBilinear() = default; + void SetUp() override { meta_graph = LoadAndConvert("./resize_bilinear.tflite", ""); } +}; + +TEST_F(TestTfliteParserResizeBilinear, OpType) { + 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_Resize) << "wrong Op Type"; +} + +TEST_F(TestTfliteParserResizeBilinear, AttrValue) { + ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); + + auto val = meta_graph->nodes.front()->primitive->value.AsResize(); + ASSERT_NE(val, nullptr); + ASSERT_EQ(val->alignCorners, false); + ASSERT_EQ(val->newHeight, 75); + ASSERT_EQ(val->newWidth, 4); + ASSERT_EQ(val->format, schema::Format_NHWC); + ASSERT_EQ(val->preserveAspectRatio, false); + ASSERT_EQ(val->method, schema::ResizeMethod_BILINEAR); } } // 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 deleted file mode 100644 index 9ec5ed9b21..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_round_parser_test.cc +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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() = default; - 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_rsqrt_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_rsqrt_parser_test.cc deleted file mode 100644 index 9b8afe78b3..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_rsqrt_parser_test.cc +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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 TestTfliteParserRsqrt : public TestTfliteParser { - public: - TestTfliteParserRsqrt() = default; - void SetUp() override { meta_graph = LoadAndConvert("./rsqrt.tflite", ""); } -}; - -TEST_F(TestTfliteParserRsqrt, 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_Rsqrt) << "wrong Op Type"; -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sin_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sin_parser_test.cc deleted file mode 100644 index 6ad75bb28c..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sin_parser_test.cc +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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 TestTfliteParserSin : public TestTfliteParser { - public: - TestTfliteParserSin() = default; - void SetUp() override { meta_graph = LoadAndConvert("./sin.tflite", ""); } -}; - -TEST_F(TestTfliteParserSin, 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_Sin) << "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_softmax_parser_test.cc similarity index 64% rename from mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_parser_test.cc rename to mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_softmax_parser_test.cc index b765fc8d85..c6fb258e6e 100644 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_parser_test.cc +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_softmax_parser_test.cc @@ -19,18 +19,27 @@ #include "common/common_test.h" namespace mindspore { -class TestTfliteParserGreater : public TestTfliteParser { +class TestTfliteParserSoftmax : public TestTfliteParser { public: - TestTfliteParserGreater() = default; + TestTfliteParserSoftmax() = default; void SetUp() override { - meta_graph = LoadAndConvert("./greater.tflite"); + meta_graph = LoadAndConvert("./softmax.tflite"); } }; -TEST_F(TestTfliteParserGreater, OpType) { +TEST_F(TestTfliteParserSoftmax, 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"; + ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_SoftMax) << "wrong Op Type"; } + +TEST_F(TestTfliteParserSoftmax, 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.AsSoftMax(), nullptr); +ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsSoftMax()->axis, -1); +} + } // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sqrt_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sqrt_parser_test.cc deleted file mode 100644 index e66b0cb938..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sqrt_parser_test.cc +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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 TestTfliteParserSqrt : public TestTfliteParser { - public: - TestTfliteParserSqrt() = default; - void SetUp() override { meta_graph = LoadAndConvert("./sqrt.tflite", ""); } -}; - -TEST_F(TestTfliteParserSqrt, 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_Sqrt) << "wrong Op Type"; -} - -} // 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 deleted file mode 100644 index 7bbfeb3eae..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_square_parser_test.cc +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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 TestTfliteParserSquare : public TestTfliteParser { - public: - TestTfliteParserSquare() = default; - void SetUp() override { meta_graph = LoadAndConvert("./square.tflite", ""); } -}; - -TEST_F(TestTfliteParserSquare, 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_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 deleted file mode 100644 index 74548b4d76..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_squared_difference_parser_test.cc +++ /dev/null @@ -1,37 +0,0 @@ -/** - * 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() = default; - 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_sub_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sub_parser_test.cc deleted file mode 100644 index 3b9c0e26a6..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sub_parser_test.cc +++ /dev/null @@ -1,78 +0,0 @@ -/** - * 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 TestTfliteParserSub1 : public TestTfliteParser { - public: - TestTfliteParserSub1() = default; - void SetUp() override { meta_graph = LoadAndConvert("./sub1.tflite", ""); } -}; - -TEST_F(TestTfliteParserSub1, OpType) { - 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_Sub) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserSub1, Tensor) { - ASSERT_GT(meta_graph->allTensors.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); - ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); -} - -class TestTfliteParserSub2 : public TestTfliteParser { - public: - TestTfliteParserSub2() = default; - void SetUp() override { meta_graph = LoadAndConvert("./sub2.tflite", ""); } -}; - -TEST_F(TestTfliteParserSub2, OpType) { - 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_Sub) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserSub2, Tensor) { - ASSERT_GT(meta_graph->allTensors.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); - ASSERT_GT(meta_graph->allTensors.at(1)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); -} - -class TestTfliteParserSub3 : public TestTfliteParser { - public: - TestTfliteParserSub3() = default; - void SetUp() override { meta_graph = LoadAndConvert("./sub3.tflite", ""); } -}; - -TEST_F(TestTfliteParserSub3, OpType) { - 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_Sub) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserSub3, Tensor) { - ASSERT_GT(meta_graph->allTensors.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(0)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(1)->data.size(), 0); - ASSERT_EQ(meta_graph->allTensors.at(2)->data.size(), 0); -} - -} // namespace mindspore diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sum_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sum_parser_test.cc deleted file mode 100644 index 49a5a2f091..0000000000 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sum_parser_test.cc +++ /dev/null @@ -1,47 +0,0 @@ -/** - * 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 TestTfliteParserSum : public TestTfliteParser { - public: - TestTfliteParserSum() = default; - - void SetUp() override { meta_graph = LoadAndConvert("./sum.tflite"); } -}; - -TEST_F(TestTfliteParserSum, 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_Reduce) << "wrong Op Type"; -} - -TEST_F(TestTfliteParserSum, 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.AsReduce(), nullptr); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->mode, schema::ReduceMode_ReduceSum) - << "wrong reduce mode"; - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->keepDims, false); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->axes.size(), 1); - ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReduce()->axes[0], 2); -} - -} // namespace mindspore diff --git a/mindspore/lite/tools/converter/parser/caffe/caffe_innerproduct_parser.cc b/mindspore/lite/tools/converter/parser/caffe/caffe_innerproduct_parser.cc index 81c0a71c0d..5667132b40 100644 --- a/mindspore/lite/tools/converter/parser/caffe/caffe_innerproduct_parser.cc +++ b/mindspore/lite/tools/converter/parser/caffe/caffe_innerproduct_parser.cc @@ -31,8 +31,9 @@ STATUS CaffeInnerProductParser::Parse(const caffe::LayerParameter &proto, const if (innerProductParam.axis() == 1) { attr->axis = 1; + attr->useAxis = true; } else { - // MS_LOGE("InnerProduct Parse axis only support default 1, but actually %d.", innerProductParam.axis()); + // MS_LOG(ERROR) << "InnerProduct Parse axis only support default 1, but actually " << innerProductParam.axis(); return RET_ERROR; } diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_fullyconnected_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_fullyconnected_parser.cc index 21664183f5..9a6341b148 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_fullyconnected_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_fullyconnected_parser.cc @@ -65,6 +65,7 @@ STATUS TfliteFullyConnectedParser::Parse(const std::unique_ptraxis = 1; + attr->useAxis = false; op->primitive->value.type = schema::PrimitiveType_FullConnection; op->primitive->value.value = attr.release(); diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_gather_nd_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_gather_nd_parser.cc index 3d277cd986..044c3f5371 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_gather_nd_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_gather_nd_parser.cc @@ -40,6 +40,30 @@ STATUS TfliteGatherNdParser::Parse(const std::unique_ptr &tfl MS_LOG(DEBUG) << "parse TfliteGatherNdParser"; std::unique_ptr attr(new schema::GatherNdT()); + if (tfliteOp->inputs.size() != 2) { + MS_LOG(ERROR) << "The input size of gather_nd should be 2"; + return RET_ERROR; + } + + auto y_index = tfliteOp->inputs[1]; + const auto &y_tensor = tfliteTensors[y_index]; + if (y_tensor == nullptr) { + MS_LOG(ERROR) << "the second input is null"; + return RET_NULL_PTR; + } + auto &y_data = tfliteModelBuffer.at(y_tensor->buffer); + if (y_data == nullptr) { + MS_LOG(ERROR) << "the data of the second input is null"; + return RET_NULL_PTR; + } + if (!y_data->data.empty()) { + std::vector y_tensors{y_tensor.get()}; + if (RET_OK != ParseTensor(y_tensors, tfliteModelBuffer, tensor_cache, TF_CONST)) { + MS_LOG(ERROR) << "parse the second tensor failed"; + return RET_ERROR; + } + } + attr->batchDims = 0; op->primitive->value.type = schema::PrimitiveType_GatherNd; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_pooling_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_pooling_parser.cc index 15e67a9d34..f2c51fcd51 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_pooling_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_pooling_parser.cc @@ -63,9 +63,39 @@ STATUS TflitePoolingParser::Parse(const std::unique_ptr &tfli attr->strideH = tflite_attr->stride_h; attr->padMode = GetPadMode(tflite_attr->padding); attr->format = schema::Format_NHWC; - // attr->global + + // by default + attr->global = false; + attr->roundMode = schema::RoundMode_FLOOR; // calculate pad params + if (attr->padMode == schema::PadMode_VALID || attr->padMode == schema::PadMode_NOTSET) { + attr->padUp = 0; + attr->padDown = 0; + attr->padLeft = 0; + attr->padRight = 0; + } else if (attr->padMode == schema::PadMode_SAME) { + auto data_index = tflite_op->inputs[0]; + const auto &data_tensor = tfliteTensors[data_index]; + if (data_tensor == nullptr) { + MS_LOG(ERROR) << "the first input is null"; + return RET_NULL_PTR; + } + + auto shape = data_tensor->shape; + int H_input = shape.at(1); + int W_input = shape.at(2); + + int H_output = ceil(H_input / attr->strideH); + int pad_needed_H = (H_output - 1) * attr->strideH + attr->windowH - H_input; + attr->padUp = floor(pad_needed_H / 2.0); + attr->padDown = pad_needed_H - attr->padUp; + + int W_output = ceil(W_input / attr->strideW); + int pad_needed_W = (W_output - 1) * attr->strideW + attr->windowW - W_input; + attr->padLeft = floor(pad_needed_W / 2.0); + attr->padRight = pad_needed_W - attr->padLeft; + } op->primitive->value.type = schema::PrimitiveType_Pooling; op->primitive->value.value = attr.release(); diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_reshape_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_reshape_parser.cc index c78c51f1bc..c67b113c37 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_reshape_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_reshape_parser.cc @@ -50,9 +50,8 @@ STATUS TfliteReshapeParser::Parse(const std::unique_ptr &tfli MS_LOG(ERROR) << "shape_tensor is null"; return RET_NULL_PTR; } - std::vector shape_tensors{shape_tensor.get()}; - if (RET_OK != ParseTensor(shape_tensors, tfliteModelBuffer, tensor_cache, TF_CONST)) { - MS_LOG(ERROR) << "parse shape tensor error"; + if (GetTfliteData(tfliteOp->inputs[1], tfliteTensors, tfliteModelBuffer, attr->shape)) { + MS_LOG(ERROR) << "get reshape->shape error"; return RET_ERROR; } } else { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_util.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_util.cc index 08d7a8932a..1ade0e5dfe 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_util.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_util.cc @@ -145,6 +145,7 @@ std::map type_map = { {tflite::TensorType_UINT8, TypeId::kNumberTypeUInt8}, {tflite::TensorType_INT16, TypeId::kNumberTypeInt16}, {tflite::TensorType_INT8, TypeId::kNumberTypeInt8}, + {tflite::TensorType_INT64, TypeId::kNumberTypeInt64}, }; TypeId GetTfliteDataType(const tflite::TensorType &tflite_data_type) { @@ -179,7 +180,10 @@ size_t GetDataTypeSize(const TypeId &data_type) { return sizeof(uint8_t); case TypeId::kNumberTypeUInt32: return sizeof(uint32_t); + case TypeId::kNumberTypeInt64: + return sizeof(int64_t); default: + MS_LOG(ERROR) << data_type; MS_LOG(ERROR) << "unsupport datatype"; return RET_ERROR; }