Browse Source

supplement some parser ut and modify tflite parser

supplement some tflite parser ut.

format tflite parsers and ut
tags/v0.7.0-beta
lyvette 5 years ago
parent
commit
3b94bef00c
100 changed files with 1025 additions and 65 deletions
  1. +3
    -0
      mindspore/lite/test/CMakeLists.txt
  2. +2
    -0
      mindspore/lite/test/run_test.sh
  3. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/add1.tflite
  4. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/add2.tflite
  5. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/add3.tflite
  6. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/argmin.tflite
  7. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/ceil.tflite
  8. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/div1.tflite
  9. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/div2.tflite
  10. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/div3.tflite
  11. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/expand_dims.tflite
  12. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/fill.tflite
  13. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/floor.tflite
  14. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/floor_div.tflite
  15. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/floor_mod.tflite
  16. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/gather.tflite
  17. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/gather_nd.tflite
  18. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/leaky_relu.tflite
  19. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/lrn.tflite
  20. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/mul1.tflite
  21. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/mul2.tflite
  22. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/mul3.tflite
  23. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/pad.tflite
  24. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/pow.tflite
  25. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/range.tflite
  26. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/rank.tflite
  27. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/relu.tflite
  28. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/resize_nearest_neighbor.tflite
  29. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/reverse.tflite
  30. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/sigmoid.tflite
  31. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/squeeze.tflite
  32. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/sub1.tflite
  33. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/sub2.tflite
  34. BIN
      mindspore/lite/test/ut/tools/converter/parser/tflite/test_data/sub3.tflite
  35. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_abs_parser_test.cc
  36. +78
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_add_parser_test.cc
  37. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_addn_parser_test.cc
  38. +45
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_argmin_parser_test.cc
  39. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_batch_to_space_nd_parser_test.cc
  40. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cast_parser_test.cc
  41. +33
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_ceil_parser_test.cc
  42. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cos_parser_test.cc
  43. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_depth_to_space_parser_test.cc
  44. +78
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_div_parser_test.cc
  45. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_equal_parser_test.cc
  46. +42
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_fill_parser_test.cc
  47. +33
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_div_parser_test.cc
  48. +33
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_mod_parser_test.cc
  49. +33
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_floor_parser_test.cc
  50. +41
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_gather_nd_parser_test.cc
  51. +42
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_gather_parser_test.cc
  52. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_equal_parser_test.cc
  53. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_parser_test.cc
  54. +42
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_leaky_relu_parser_test.cc
  55. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_equal_parser_test.cc
  56. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_less_parser_test.cc
  57. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_log_parser_test.cc
  58. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_and_parser_test.cc
  59. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_not_parser_test.cc
  60. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_or_parser_test.cc
  61. +45
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_lrn_parser_test.cc
  62. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_maximum_parser_test.cc
  63. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_minimum_parser_test.cc
  64. +78
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_mul_parser_test.cc
  65. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_not_equal_parser_test.cc
  66. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_one_hot_parser_test.cc
  67. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_p_relu_parser_test.cc
  68. +43
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_pad_parser_test.cc
  69. +4
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_parsers_test_utils.cc
  70. +2
    -2
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h
  71. +44
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_pow_parser_test.cc
  72. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_max_parser_test.cc
  73. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_min_parser_test.cc
  74. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reduce_prod_parser_test.cc
  75. +33
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_relu_parser_test.cc
  76. +44
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_resize_nn_parser_test.cc
  77. +43
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reverse_parser_test.cc
  78. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reverse_sequence_parser_test.cc
  79. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_round_parser_test.cc
  80. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_rsqrt_parser_test.cc
  81. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sin_parser_test.cc
  82. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_space_to_batch_nd_parser_test.cc
  83. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_space_to_depth_parser_test.cc
  84. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sparse_to_dense_parser_test.cc
  85. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_split_parser_test.cc
  86. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_split_v_parser_test.cc
  87. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sqrt_parser_test.cc
  88. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_square_parser_test.cc
  89. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_squared_difference_parser_test.cc
  90. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_strided_slice_parser_test.cc
  91. +78
    -0
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sub_parser_test.cc
  92. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sum_parser_test.cc
  93. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_tile_parser_test.cc
  94. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_topk_v2_parser_test.cc
  95. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_unique_parser_test.cc
  96. +1
    -1
      mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_unstack_parser_test.cc
  97. +1
    -1
      mindspore/lite/tools/converter/parser/tflite/tflite_abs_parser.cc
  98. +39
    -9
      mindspore/lite/tools/converter/parser/tflite/tflite_add_parser.cc
  99. +9
    -9
      mindspore/lite/tools/converter/parser/tflite/tflite_addn_parser.cc
  100. +16
    -2
      mindspore/lite/tools/converter/parser/tflite/tflite_argmax_parser.cc

+ 3
- 0
mindspore/lite/test/CMakeLists.txt View File

@@ -1,5 +1,7 @@
set(TOP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
set(TEST_DIR ${TOP_DIR}/mindspore/lite/test)
set(LITE_DIR ${TOP_DIR}/mindspore/lite)
set(CCSRC_DIR ${TOP_DIR}/mindspore/ccsrc)
include_directories(${TOP_DIR})
include_directories(${TEST_DIR})
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/dependency_gtest.cmake)
@@ -12,6 +14,7 @@ set(ANF_SRC
${CMAKE_CURRENT_SOURCE_DIR}/../../core/base/base.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../core/utils/log_adapter.cc
)

if(BUILD_CONVERTER)
set(ANF_SRC
${ANF_SRC}


+ 2
- 0
mindspore/lite/test/run_test.sh View File

@@ -26,3 +26,5 @@ cp -fr $TEST_DATA_DIR/testPK ./data

./lite-test --gtest_filter=TestPadInt8.*
./lite-test --gtest_filter=TestDeconvInt8.*

./lite-test --gtest_filter="TestTfliteParser*"

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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserAbs : public TestTfliteParser {
public:
TestTfliteParserAbs() {}
TestTfliteParserAbs() = default;
void SetUp() override { meta_graph = LoadAndConvert("./abs.tflite", ""); }
};



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

@@ -0,0 +1,78 @@
/**
* 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

+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_addn_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserAddN : public TestTfliteParser {
public:
TestTfliteParserAddN() {}
TestTfliteParserAddN() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./addn.tflite");
}


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

@@ -0,0 +1,45 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h"
#include <iostream>
#include "common/common_test.h"

namespace mindspore {
class TestTfliteParserArgmin : public TestTfliteParser {
public:
TestTfliteParserArgmin() = default;
void SetUp() override { meta_graph = LoadAndConvert("./argmin.tflite", ""); }
};

TEST_F(TestTfliteParserArgmin, 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_ArgMin) << "wrong Op Type";
}

TEST_F(TestTfliteParserArgmin, 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.AsArgMin();
ASSERT_EQ(val->axis, 1);
ASSERT_EQ(val->topK, 1);
ASSERT_EQ(val->axisType, 1);
ASSERT_EQ(val->keepDims, false);
ASSERT_EQ(val->outMaxValue, false);
}

} // namespace mindspore

+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_batch_to_space_nd_parser_test.cc View File

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserBatchToSpaceNd : public TestTfliteParser {
public:
TestTfliteParserBatchToSpaceNd() {}
TestTfliteParserBatchToSpaceNd() = default;
void SetUp() override { meta_graph = LoadAndConvert("./batch_to_space_nd.tflite"); }
};



+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_cast_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserCast : public TestTfliteParser {
public:
TestTfliteParserCast() {}
TestTfliteParserCast() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./cast.tflite");
}


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

@@ -0,0 +1,33 @@
/**
* 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

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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserCos : public TestTfliteParser {
public:
TestTfliteParserCos() {}
TestTfliteParserCos() = default;
void SetUp() override { meta_graph = LoadAndConvert("./cos.tflite", ""); }
};



+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_depth_to_space_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserDepthToSpace : public TestTfliteParser {
public:
TestTfliteParserDepthToSpace() {}
TestTfliteParserDepthToSpace() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./depth_to_space.tflite");
}


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

@@ -0,0 +1,78 @@
/**
* 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

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

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserEqual : public TestTfliteParser {
public:
TestTfliteParserEqual() {}
TestTfliteParserEqual() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./equal.tflite");
}


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

@@ -0,0 +1,42 @@
/**
* 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 TestTfliteParserFill : public TestTfliteParser {
public:
TestTfliteParserFill() = default;
void SetUp() override { meta_graph = LoadAndConvert("./fill.tflite", ""); }
};

TEST_F(TestTfliteParserFill, 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_Fill) << "wrong Op Type";
}

TEST_F(TestTfliteParserFill, 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.AsFill();

std::vector<int32_t> dims = {9};
ASSERT_EQ(val->dims, dims);
}
} // namespace mindspore

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

@@ -0,0 +1,33 @@
/**
* 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

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

@@ -0,0 +1,33 @@
/**
* 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

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

@@ -0,0 +1,33 @@
/**
* 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

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

@@ -0,0 +1,41 @@
/**
* 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 TestTfliteParserGatherNd : public TestTfliteParser {
public:
TestTfliteParserGatherNd() = default;
void SetUp() override { meta_graph = LoadAndConvert("./gather_nd.tflite", ""); }
};

TEST_F(TestTfliteParserGatherNd, 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_GatherNd) << "wrong Op Type";
}

TEST_F(TestTfliteParserGatherNd, 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.AsGatherNd();
ASSERT_EQ(val->batchDims, 0);
}

} // namespace mindspore

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

@@ -0,0 +1,42 @@
/**
* 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 TestTfliteParserGather : public TestTfliteParser {
public:
TestTfliteParserGather() = default;
void SetUp() override { meta_graph = LoadAndConvert("./gather.tflite", ""); }
};

TEST_F(TestTfliteParserGather, 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_Gather) << "wrong Op Type";
}

TEST_F(TestTfliteParserGather, 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.AsGather();
ASSERT_EQ(val->axis, 0);
ASSERT_EQ(val->batchDims, 0);
}

} // namespace mindspore

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

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserGreaterEqual : public TestTfliteParser {
public:
TestTfliteParserGreaterEqual() {}
TestTfliteParserGreaterEqual() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./greater_equal.tflite");
}


+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_greater_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserGreater : public TestTfliteParser {
public:
TestTfliteParserGreater() {}
TestTfliteParserGreater() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./greater.tflite");
}


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

@@ -0,0 +1,42 @@
/**
* 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

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

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserLessEqual : public TestTfliteParser {
public:
TestTfliteParserLessEqual() {}
TestTfliteParserLessEqual() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./less_equal.tflite");
}


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

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserLess : public TestTfliteParser {
public:
TestTfliteParserLess() {}
TestTfliteParserLess() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./less.tflite");
}


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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserLog : public TestTfliteParser {
public:
TestTfliteParserLog() {}
TestTfliteParserLog() = default;
void SetUp() override { meta_graph = LoadAndConvert("./log.tflite", ""); }
};



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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteLogicalParserAnd : public TestTfliteParser {
public:
TestTfliteLogicalParserAnd() {}
TestTfliteLogicalParserAnd() = default;
void SetUp() override { meta_graph = LoadAndConvert("./logical_and.tflite", ""); }
};



+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_logical_not_parser_test.cc View File

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserLogicalNot : public TestTfliteParser {
public:
TestTfliteParserLogicalNot() {}
TestTfliteParserLogicalNot() = default;
void SetUp() override { meta_graph = LoadAndConvert("./logical_not.tflite", ""); }
};



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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserLogicalOr : public TestTfliteParser {
public:
TestTfliteParserLogicalOr() {}
TestTfliteParserLogicalOr() = default;
void SetUp() override { meta_graph = LoadAndConvert("./logical_or.tflite", ""); }
};



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

@@ -0,0 +1,45 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h"
#include <iostream>
#include "common/common_test.h"

namespace mindspore {
class TestTfliteParserLRN : public TestTfliteParser {
public:
TestTfliteParserLRN() = default;
void SetUp() override { meta_graph = LoadAndConvert("./lrn.tflite", ""); }
};

TEST_F(TestTfliteParserLRN, 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_LocalResponseNormalization) << "wrong Op Type";
}

TEST_F(TestTfliteParserLRN, 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.AsLocalResponseNormalization();
ASSERT_EQ(val->alpha, 1);
ASSERT_EQ(val->beta, 0.5);
ASSERT_EQ(val->bias, 1);
ASSERT_EQ(val->depth_radius, 5);
}

} // namespace mindspore

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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserMaximum : public TestTfliteParser {
public:
TestTfliteParserMaximum() {}
TestTfliteParserMaximum() = default;
void SetUp() override { meta_graph = LoadAndConvert("./maximum.tflite"); }
};



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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserMinimum : public TestTfliteParser {
public:
TestTfliteParserMinimum() {}
TestTfliteParserMinimum() = default;
void SetUp() override { meta_graph = LoadAndConvert("./minimum.tflite"); }
};



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

@@ -0,0 +1,78 @@
/**
* 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

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

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserNotEqual : public TestTfliteParser {
public:
TestTfliteParserNotEqual() {}
TestTfliteParserNotEqual() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./not_equal.tflite");
}


+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_one_hot_parser_test.cc View File

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserOneHot : public TestTfliteParser {
public:
TestTfliteParserOneHot() {}
TestTfliteParserOneHot() = default;
void SetUp() override { meta_graph = LoadAndConvert("./one_hot.tflite"); }
};



+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_p_relu_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserPrelu : public TestTfliteParser {
public:
TestTfliteParserPrelu() {}
TestTfliteParserPrelu() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./prelu.tflite");
}


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

@@ -0,0 +1,43 @@
/**
* 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 TestTfliteParserPad : public TestTfliteParser {
public:
TestTfliteParserPad() = default;
void SetUp() override { meta_graph = LoadAndConvert("./pad.tflite", ""); }
};

TEST_F(TestTfliteParserPad, 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_Pad) << "wrong Op Type";
}

TEST_F(TestTfliteParserPad, 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.AsPad();

std::vector<int32_t> paddings = {1, 1, 2, 2, 3, 3, 4, 4};
ASSERT_EQ(val->paddings, paddings);
}

} // namespace mindspore

+ 4
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_parsers_test_utils.cc View File

@@ -22,9 +22,12 @@
namespace mindspore {

schema::MetaGraphT *TestTfliteParser::LoadAndConvert(const string &model_path, const string &weight_path) {
schema::MetaGraphT *meta_graph = nullptr;
lite::TfliteModelParser parser;
meta_graph = parser.Parse(model_path, weight_path);
if (meta_graph == nullptr) {
MS_LOG(ERROR) << "Parse to metaGraph return nullptr";
return nullptr;
}
return meta_graph;
}



+ 2
- 2
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h View File

@@ -24,10 +24,10 @@
namespace mindspore {
class TestTfliteParser : public Common {
public:
TestTfliteParser() {}
TestTfliteParser() = default;
void TearDown() override;
schema::MetaGraphT *LoadAndConvert(const std::string &model_path, const std::string &weight_path = "");
schema::MetaGraphT *meta_graph;
schema::MetaGraphT *meta_graph = nullptr;
};

} // namespace mindspore


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

@@ -0,0 +1,44 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h"
#include <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

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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserReduceMax : public TestTfliteParser {
public:
TestTfliteParserReduceMax() {}
TestTfliteParserReduceMax() = default;
void SetUp() override { meta_graph = LoadAndConvert("./reduce_max.tflite"); }
};



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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserReduceMin : public TestTfliteParser {
public:
TestTfliteParserReduceMin() {}
TestTfliteParserReduceMin() = default;
void SetUp() override { meta_graph = LoadAndConvert("./reduce_min.tflite"); }
};



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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserReduceProd : public TestTfliteParser {
public:
TestTfliteParserReduceProd() {}
TestTfliteParserReduceProd() = default;
void SetUp() override { meta_graph = LoadAndConvert("./reduce_prod.tflite"); }
};



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

@@ -0,0 +1,33 @@
/**
* 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

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

@@ -0,0 +1,44 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ut/tools/converter/parser/tflite/tflite_parsers_test_utils.h"
#include <iostream>
#include "common/common_test.h"

namespace mindspore {
class TestTfliteParserResizeNN : public TestTfliteParser {
public:
TestTfliteParserResizeNN() = default;
void SetUp() override { meta_graph = LoadAndConvert("./resize_nearest_neighbor.tflite", ""); }
};

TEST_F(TestTfliteParserResizeNN, 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(TestTfliteParserResizeNN, 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_EQ(val->alignCorners, false);
ASSERT_EQ(val->newHeight, 3);
ASSERT_EQ(val->newWidth, 100);
}

} // namespace mindspore

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

@@ -0,0 +1,43 @@
/**
* 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 TestTfliteParserReverse : public TestTfliteParser {
public:
TestTfliteParserReverse() = default;
void SetUp() override { meta_graph = LoadAndConvert("./reverse.tflite", ""); }
};

TEST_F(TestTfliteParserReverse, 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_Reverse) << "wrong Op Type";
}

TEST_F(TestTfliteParserReverse, 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.AsReverse();

std::vector<int32_t> axis = {3};
ASSERT_EQ(val->axis, axis);
}

} // namespace mindspore

+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_reverse_sequence_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserReverseSequence : public TestTfliteParser {
public:
TestTfliteParserReverseSequence() {}
TestTfliteParserReverseSequence() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./reverse_sequence.tflite");
}


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

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserRound : public TestTfliteParser {
public:
TestTfliteParserRound() {}
TestTfliteParserRound() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./round.tflite");
}


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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserRsqrt : public TestTfliteParser {
public:
TestTfliteParserRsqrt() {}
TestTfliteParserRsqrt() = default;
void SetUp() override { meta_graph = LoadAndConvert("./rsqrt.tflite", ""); }
};



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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserSin : public TestTfliteParser {
public:
TestTfliteParserSin() {}
TestTfliteParserSin() = default;
void SetUp() override { meta_graph = LoadAndConvert("./sin.tflite", ""); }
};



+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_space_to_batch_nd_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserSpaceToBatchND : public TestTfliteParser {
public:
TestTfliteParserSpaceToBatchND() {}
TestTfliteParserSpaceToBatchND() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./space_to_batch_nd.tflite");
}


+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_space_to_depth_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserSpaceToDepth : public TestTfliteParser {
public:
TestTfliteParserSpaceToDepth() {}
TestTfliteParserSpaceToDepth() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./space_to_depth.tflite");
}


+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_sparse_to_dense_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserSparseToDense : public TestTfliteParser {
public:
TestTfliteParserSparseToDense() {}
TestTfliteParserSparseToDense() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./sparse_to_dense.tflite");
}


+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_split_parser_test.cc View File

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserSplit : public TestTfliteParser {
public:
TestTfliteParserSplit() {}
TestTfliteParserSplit() = default;

void SetUp() override { meta_graph = LoadAndConvert("./split.tflite"); }
};


+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_split_v_parser_test.cc View File

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserSplitV : public TestTfliteParser {
public:
TestTfliteParserSplitV() {}
TestTfliteParserSplitV() = default;

void SetUp() override { meta_graph = LoadAndConvert("./split_v.tflite"); }
};


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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserSqrt : public TestTfliteParser {
public:
TestTfliteParserSqrt() {}
TestTfliteParserSqrt() = default;
void SetUp() override { meta_graph = LoadAndConvert("./sqrt.tflite", ""); }
};



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

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserSquare : public TestTfliteParser {
public:
TestTfliteParserSquare() {}
TestTfliteParserSquare() = default;
void SetUp() override { meta_graph = LoadAndConvert("./square.tflite", ""); }
};



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

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserSquaredDifference : public TestTfliteParser {
public:
TestTfliteParserSquaredDifference() {}
TestTfliteParserSquaredDifference() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./squared_difference.tflite");
}


+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_strided_slice_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserStridedSlice : public TestTfliteParser {
public:
TestTfliteParserStridedSlice() {}
TestTfliteParserStridedSlice() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./strided_slice.tflite");
}


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

@@ -0,0 +1,78 @@
/**
* 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

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

@@ -20,7 +20,7 @@
namespace mindspore {
class TestTfliteParserSum : public TestTfliteParser {
public:
TestTfliteParserSum() {}
TestTfliteParserSum() = default;

void SetUp() override { meta_graph = LoadAndConvert("./sum.tflite"); }
};


+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_tile_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserTile : public TestTfliteParser {
public:
TestTfliteParserTile() {}
TestTfliteParserTile() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./tile.tflite");
}


+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_topk_v2_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserTopKV2 : public TestTfliteParser {
public:
TestTfliteParserTopKV2() {}
TestTfliteParserTopKV2() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./topk_v2.tflite");
}


+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_unique_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserUnique : public TestTfliteParser {
public:
TestTfliteParserUnique() {}
TestTfliteParserUnique() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./unique.tflite");
}


+ 1
- 1
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_unstack_parser_test.cc View File

@@ -21,7 +21,7 @@
namespace mindspore {
class TestTfliteParserUnstack : public TestTfliteParser {
public:
TestTfliteParserUnstack() {}
TestTfliteParserUnstack() = default;
void SetUp() override {
meta_graph = LoadAndConvert("./unstack.tflite");
}


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

@@ -14,9 +14,9 @@
* limitations under the License.
*/

#include "tools/converter/parser/tflite/tflite_abs_parser.h"
#include <vector>
#include <memory>
#include "tools/converter/parser/tflite/tflite_abs_parser.h"

namespace mindspore {
namespace lite {


+ 39
- 9
mindspore/lite/tools/converter/parser/tflite/tflite_add_parser.cc View File

@@ -24,9 +24,7 @@ STATUS TfliteAddParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfliteOp
const std::vector<std::unique_ptr<tflite::TensorT>> &tfliteTensors,
const std::vector<std::unique_ptr<tflite::BufferT>> &tfliteModelBuffer,
const std::vector<std::unique_ptr<tflite::OperatorCodeT>> &tfliteOpSet,
schema::CNodeT *op,
TensorCache *tensor_cache,
bool quantizedModel) {
schema::CNodeT *op, TensorCache *tensor_cache, bool quantizedModel) {
MS_LOG(DEBUG) << "parse TfliteAddParser";
std::unique_ptr<schema::AddT> attr(new schema::AddT());
const auto &tfliteAttr = tfliteOp->builtin_options.AsAddOptions();
@@ -34,14 +32,46 @@ STATUS TfliteAddParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfliteOp
MS_LOG(ERROR) << "get op: " << op->name.c_str() << " attr failed";
return RET_NULL_PTR;
}
attr->activationType = GetActivationFunctionType(tfliteAttr->fused_activation_function);

auto weight_index = tfliteOp->inputs[1];
const auto &weight_tensor = tfliteTensors[weight_index];
std::vector<tflite::TensorT *> weight_tensors{weight_tensor.get()};
if (RET_OK != ParseWeight(weight_tensors, tfliteModelBuffer, tensor_cache, schema::Format_KHWC)) {
return RET_ERROR;
auto x_index = tfliteOp->inputs[0];
const auto &x_tensor = tfliteTensors[x_index];
if (x_tensor == nullptr) {
MS_LOG(ERROR) << "the first input is null";
return RET_NULL_PTR;
}
attr->activationType = GetActivationFunctionType(tfliteAttr->fused_activation_function);
auto &x_data = tfliteModelBuffer.at(x_tensor->buffer);
if (x_data == nullptr) {
MS_LOG(ERROR) << "the data of the first input is null";
return RET_NULL_PTR;
}
if (x_data->data.size() > 0) {
std::vector<tflite::TensorT *> x_tensors{x_tensor.get()};
if (RET_OK != ParseTensor(x_tensors, tfliteModelBuffer, tensor_cache, TF_CONST, true)) {
MS_LOG(ERROR) << "parse the first tensor failed";
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.size() > 0) {
std::vector<tflite::TensorT *> y_tensors{y_tensor.get()};
if (RET_OK != ParseTensor(y_tensors, tfliteModelBuffer, tensor_cache, TF_CONST, true)) {
MS_LOG(ERROR) << "parse the second tensor failed";
return RET_ERROR;
}
}

if (op != nullptr) {
op->primitive = std::make_unique<schema::PrimitiveT>();
op->primitive->value.type = schema::PrimitiveType_Add;


+ 9
- 9
mindspore/lite/tools/converter/parser/tflite/tflite_addn_parser.cc View File

@@ -15,22 +15,22 @@
* limitations under the License.
*/

#include "tools/converter/parser/tflite/tflite_addn_parser.h"
#include <vector>
#include <memory>
#include "tools/converter/parser/tflite/tflite_addn_parser.h"

namespace mindspore {
namespace lite {
STATUS TfliteAddNParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite_op,
const std::vector<std::unique_ptr<tflite::TensorT>> &tflite_tensors,
const std::vector<std::unique_ptr<tflite::BufferT>> &tflite_model_buffer,
const std::vector<std::unique_ptr<tflite::OperatorCodeT>> &tflite_opset,
schema::CNodeT *op,
TensorCache *tensor_cache,
bool quantized_model) {
STATUS TfliteAddNParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfliteOp,
const std::vector<std::unique_ptr<tflite::TensorT>> &tfliteTensors,
const std::vector<std::unique_ptr<tflite::BufferT>> &tfliteModelBuffer,
const std::vector<std::unique_ptr<tflite::OperatorCodeT>> &tfliteOpSet,
schema::CNodeT *op, TensorCache *tensor_cache, bool quantizedModel) {
MS_LOG(DEBUG) << "parse TfliteAddNParser";
std::unique_ptr<schema::AddNT> attr(new schema::AddNT());
attr->N = tflite_tensors.size() - 1;

attr->N = tfliteTensors.size() - 1;

if (op != nullptr) {
op->primitive = std::make_unique<schema::PrimitiveT>();
op->primitive->value.type = schema::PrimitiveType_AddN;


+ 16
- 2
mindspore/lite/tools/converter/parser/tflite/tflite_argmax_parser.cc View File

@@ -29,11 +29,25 @@ STATUS TfliteArgmaxParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit
bool quantizedModel) {
MS_LOG(DEBUG) << "parse TfliteArgmaxParser";
std::unique_ptr<schema::ArgMaxT> attr(new schema::ArgMaxT());
// These are caffe attributes, set to default value.
attr->axisType = 1;

attr->outMaxValue = false;
attr->topK = 1;
attr->keepDims = false;
attr->axisType = 1;

auto axis_idx = tfliteOp->inputs[1];
std::for_each(tfliteTensors[axis_idx]->shape.begin(), tfliteTensors[axis_idx]->shape.end(), [&](int32_t sha){});
auto &buf_data = tfliteModelBuffer[tfliteTensors[axis_idx]->buffer];
if (buf_data == nullptr) {
MS_LOG(ERROR) << "the buf data is null";
return RET_NULL_PTR;
}
auto data_ptr = buf_data->data.data();
if (data_ptr == nullptr) {
MS_LOG(ERROR) << "the data is null";
return RET_NULL_PTR;
}
attr->axis = *(static_cast<int32_t *>(static_cast<void *>(data_ptr)));

if (op != nullptr) {
op->primitive = std::make_unique<schema::PrimitiveT>();


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save