diff --git a/mindspore/lite/schema/ops.fbs b/mindspore/lite/schema/ops.fbs index 44a053cce19..f07fccd0df6 100644 --- a/mindspore/lite/schema/ops.fbs +++ b/mindspore/lite/schema/ops.fbs @@ -351,6 +351,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 00000000000..9f002540371 Binary files /dev/null and b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/avg_pooling.tflite differ diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/exp.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/exp.tflite new file mode 100644 index 00000000000..e06ada97e35 Binary files /dev/null and b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/exp.tflite differ 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 00000000000..c60b183b414 Binary files /dev/null and b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/max_pooling.tflite differ diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/mean.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/mean.tflite new file mode 100644 index 00000000000..9c2c9dc5151 Binary files /dev/null and b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/mean.tflite differ 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 00000000000..530e0262567 Binary files /dev/null and b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/relu6.tflite differ 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 00000000000..0599e6ee9b7 Binary files /dev/null and b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/reshape.tflite differ diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/resize_bilinear.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/resize_bilinear.tflite new file mode 100644 index 00000000000..18d615d8809 Binary files /dev/null and b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/resize_bilinear.tflite differ diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/softmax.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/softmax.tflite new file mode 100644 index 00000000000..07b60f59259 Binary files /dev/null and b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/softmax.tflite differ diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/tanh.tflite b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/tanh.tflite new file mode 100644 index 00000000000..9a762247bce Binary files /dev/null and b/mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/tanh.tflite differ 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 7f0453bd118..00000000000 --- 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 00000000000..24f2a34899b --- /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 d590be81317..00000000000 --- 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 00000000000..64056ecde41 --- /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 59d8664be19..00000000000 --- 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 756cd626c69..00000000000 --- 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 8ee47212a4d..00000000000 --- 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 ba2e4b0f510..00000000000 --- 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 d92c1608a7e..00000000000 --- 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 f8cf0fdf037..00000000000 --- 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 d7777f24b92..00000000000 --- 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 c65b80cc88e..00000000000 --- 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 80c88260880..00000000000 --- 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 06f57a4bab6..00000000000 --- 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 1872d2d3f1d..00000000000 --- 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 22976eceb8a..00000000000 --- 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 a1a5159ae02..00000000000 --- 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 508293542fa..00000000000 --- 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 cb2c21411e8..5a969bfe41e 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 b99119df5a9..00000000000 --- 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 431a15e5bda..00000000000 --- 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 140960e53b0..00000000000 --- 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 3e697c862ed..00000000000 --- 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 00000000000..d234a76a323 --- /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 52188a5d9bb..00000000000 --- 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 8b5c97a3f84..00000000000 --- 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 01995e9bbad..00000000000 --- 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 00000000000..bf790bd842f --- /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 2b0352231fa..00000000000 --- 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 a0d44c30cd7..00000000000 --- 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 7b64cb1d02a..a4eef7898b3 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 199c560f13e..ab0c9a9a256 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 9ec5ed9b214..00000000000 --- 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 9b8afe78b3b..00000000000 --- 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 6ad75bb28c1..00000000000 --- 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 b765fc8d85d..c6fb258e6ee 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 e66b0cb938f..00000000000 --- 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 7bbfeb3eae0..00000000000 --- 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 74548b4d76b..00000000000 --- 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 3b9c0e26a6d..00000000000 --- 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 49a5a2f0916..00000000000 --- 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 81c0a71c0d5..5667132b40b 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 21664183f57..9a6341b148c 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 3d277cd986d..044c3f53718 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 15e67a9d342..f2c51fcd515 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 c78c51f1bcf..c67b113c376 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 08d7a8932af..1ade0e5dfef 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; }