Browse Source

!4294 modify pooling & fc & gatherND parser and merge ut.

Merge pull request !4294 from lyvette/tflite_parser
tags/v0.7.0-beta
mindspore-ci-bot Gitee 5 years ago
parent
commit
73c3be480e
57 changed files with 1078 additions and 1395 deletions
  1. +1
    -0
      mindspore/lite/schema/ops.fbs
  2. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/avg_pooling.tflite
  3. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/exp.tflite
  4. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/max_pooling.tflite
  5. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/mean.tflite
  6. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/relu6.tflite
  7. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/reshape.tflite
  8. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/resize_bilinear.tflite
  9. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/softmax.tflite
  10. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/tanh.tflite
  11. +0
    -34
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_abs_parser_test.cc
  12. +105
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_activation_parser_test.cc
  13. +0
    -78
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_add_parser_test.cc
  14. +576
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_arithmetic_parser_test.cc
  15. +0
    -33
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_ceil_parser_test.cc
  16. +0
    -34
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cos_parser_test.cc
  17. +0
    -78
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_div_parser_test.cc
  18. +0
    -36
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_equal_parser_test.cc
  19. +0
    -33
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_div_parser_test.cc
  20. +0
    -33
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_mod_parser_test.cc
  21. +0
    -33
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_parser_test.cc
  22. +0
    -36
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_equal_parser_test.cc
  23. +0
    -42
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_leaky_relu_parser_test.cc
  24. +0
    -36
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_equal_parser_test.cc
  25. +0
    -36
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_parser_test.cc
  26. +0
    -34
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_log_parser_test.cc
  27. +0
    -34
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_and_parser_test.cc
  28. +0
    -34
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_or_parser_test.cc
  29. +27
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_parser_test.cc
  30. +0
    -34
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_maximum_parser_test.cc
  31. +0
    -34
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_minimum_parser_test.cc
  32. +0
    -78
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_mul_parser_test.cc
  33. +0
    -36
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_not_equal_parser_test.cc
  34. +95
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_pooling_parser_test.cc
  35. +0
    -44
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_pow_parser_test.cc
  36. +0
    -46
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_max_parser_test.cc
  37. +0
    -46
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_min_parser_test.cc
  38. +155
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_parser_test.cc
  39. +0
    -46
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_prod_parser_test.cc
  40. +0
    -33
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_relu_parser_test.cc
  41. +10
    -9
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reshape_parser_test.cc
  42. +31
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_resize_parser_test.cc
  43. +0
    -36
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_round_parser_test.cc
  44. +0
    -34
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_rsqrt_parser_test.cc
  45. +0
    -34
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sin_parser_test.cc
  46. +14
    -5
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_softmax_parser_test.cc
  47. +0
    -34
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sqrt_parser_test.cc
  48. +0
    -34
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_square_parser_test.cc
  49. +0
    -37
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_squared_difference_parser_test.cc
  50. +0
    -78
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sub_parser_test.cc
  51. +0
    -47
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sum_parser_test.cc
  52. +2
    -1
      mindspore/lite/tools/converter/parser/caffe/caffe_innerproduct_parser.cc
  53. +1
    -0
      mindspore/lite/tools/converter/parser/tflite/tflite_fullyconnected_parser.cc
  54. +24
    -0
      mindspore/lite/tools/converter/parser/tflite/tflite_gather_nd_parser.cc
  55. +31
    -1
      mindspore/lite/tools/converter/parser/tflite/tflite_pooling_parser.cc
  56. +2
    -3
      mindspore/lite/tools/converter/parser/tflite/tflite_reshape_parser.cc
  57. +4
    -0
      mindspore/lite/tools/converter/parser/tflite/tflite_util.cc

+ 1
- 0
mindspore/lite/schema/ops.fbs View File

@@ -351,6 +351,7 @@ table DetectionPostProcess {
table FullConnection {
hasBias: bool;
axis: int;
useAxis: bool;
}

// Mean(input_tensor, axis, keep_dims)


BIN
mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/avg_pooling.tflite View File


BIN
mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/exp.tflite View File


BIN
mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/max_pooling.tflite View File


BIN
mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/mean.tflite View File


BIN
mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/relu6.tflite View File


BIN
mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/reshape.tflite View File


BIN
mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/resize_bilinear.tflite View File


BIN
mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/softmax.tflite View File


BIN
mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/tanh.tflite View File


+ 0
- 34
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_abs_parser_test.cc View File

@@ -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 <iostream>
#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

+ 105
- 0
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_activation_parser_test.cc View File

@@ -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 <iostream>
#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<float> 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

+ 0
- 78
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_add_parser_test.cc View File

@@ -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 <iostream>
#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

+ 576
- 0
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_arithmetic_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 33
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_ceil_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 34
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cos_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 78
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_div_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 36
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_equal_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 33
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_div_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 33
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_mod_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 33
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 36
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_equal_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 42
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_leaky_relu_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 36
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_equal_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 36
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 34
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_log_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 34
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_and_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 34
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_or_parser_test.cc View File

@@ -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 <iostream>
#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

mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_not_parser_test.cc → mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_parser_test.cc View File

@@ -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

+ 0
- 34
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_maximum_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 34
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_minimum_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 78
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_mul_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 36
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_not_equal_parser_test.cc View File

@@ -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 <iostream>
#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

+ 95
- 0
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_pooling_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 44
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_pow_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 46
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_max_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 46
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_min_parser_test.cc View File

@@ -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 <iostream>
#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

+ 155
- 0
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_parser_test.cc View File

@@ -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 <iostream>
#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<int32_t> 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<int32_t> 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<int32_t> 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<int32_t> 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<int32_t> axes = {2, 3};
ASSERT_EQ(val->axes, axes);
}

// reduceAny

} // namespace mindspore

+ 0
- 46
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_prod_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 33
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_relu_parser_test.cc View File

@@ -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 <iostream>
#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

mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_p_relu_parser_test.cc → mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reshape_parser_test.cc View File

@@ -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<float> 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<int64_t> shape = {3, 5, 20};
ASSERT_EQ(meta_graph->nodes.front()->primitive->value.AsReshape()->shape, shape); // int32
}
} // namespace mindspore

mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_resize_nn_parser_test.cc → mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_resize_parser_test.cc View File

@@ -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

+ 0
- 36
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_round_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 34
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_rsqrt_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 34
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sin_parser_test.cc View File

@@ -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 <iostream>
#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

mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_parser_test.cc → mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_softmax_parser_test.cc View File

@@ -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

+ 0
- 34
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sqrt_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 34
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_square_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 37
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_squared_difference_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 78
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sub_parser_test.cc View File

@@ -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 <iostream>
#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

+ 0
- 47
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sum_parser_test.cc View File

@@ -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 <iostream>
#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

+ 2
- 1
mindspore/lite/tools/converter/parser/caffe/caffe_innerproduct_parser.cc View File

@@ -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;
}



+ 1
- 0
mindspore/lite/tools/converter/parser/tflite/tflite_fullyconnected_parser.cc View File

@@ -65,6 +65,7 @@ STATUS TfliteFullyConnectedParser::Parse(const std::unique_ptr<tflite::OperatorT
}
}
attr->axis = 1;
attr->useAxis = false;

op->primitive->value.type = schema::PrimitiveType_FullConnection;
op->primitive->value.value = attr.release();


+ 24
- 0
mindspore/lite/tools/converter/parser/tflite/tflite_gather_nd_parser.cc View File

@@ -40,6 +40,30 @@ STATUS TfliteGatherNdParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfl
MS_LOG(DEBUG) << "parse TfliteGatherNdParser";
std::unique_ptr<schema::GatherNdT> 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<tflite::TensorT *> 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;


+ 31
- 1
mindspore/lite/tools/converter/parser/tflite/tflite_pooling_parser.cc View File

@@ -63,9 +63,39 @@ STATUS TflitePoolingParser::Parse(const std::unique_ptr<tflite::OperatorT> &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();


+ 2
- 3
mindspore/lite/tools/converter/parser/tflite/tflite_reshape_parser.cc View File

@@ -50,9 +50,8 @@ STATUS TfliteReshapeParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfli
MS_LOG(ERROR) << "shape_tensor is null";
return RET_NULL_PTR;
}
std::vector<tflite::TensorT *> 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 {


+ 4
- 0
mindspore/lite/tools/converter/parser/tflite/tflite_util.cc View File

@@ -145,6 +145,7 @@ std::map<int, TypeId> 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;
}


Loading…
Cancel
Save