You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

parser_integrate_test.cc 3.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <iostream>
  17. #include <string>
  18. #include "common/common_test.h"
  19. #include "common/py_func_graph_fetcher.h"
  20. #include "utils/log_adapter.h"
  21. #include "pipeline/parse/parse.h"
  22. #include "debug/draw.h"
  23. namespace mindspore {
  24. namespace parse {
  25. class TestParserIntegrate : public UT::Common {
  26. public:
  27. TestParserIntegrate() : getPyFun("gtest_input.pipeline.parse.parser_integrate") {}
  28. virtual void SetUp();
  29. virtual void TearDown();
  30. py::function GetPythonFunction(std::string function);
  31. public:
  32. UT::PyFuncGraphFetcher getPyFun;
  33. };
  34. void TestParserIntegrate::SetUp() { UT::InitPythonPath(); }
  35. void TestParserIntegrate::TearDown() {}
  36. TEST_F(TestParserIntegrate, TestParseGraphTestHighOrderFunction) {
  37. auto func_graph = getPyFun("test_high_order_function");
  38. ASSERT_TRUE(func_graph != nullptr);
  39. }
  40. TEST_F(TestParserIntegrate, TestParseGraphTestHofTup) {
  41. auto func_graph = getPyFun("test_hof_tup");
  42. ASSERT_TRUE(func_graph != nullptr);
  43. }
  44. TEST_F(TestParserIntegrate, TestParseGraphTestWhile2) {
  45. auto func_graph = getPyFun("test_while_2");
  46. ASSERT_TRUE(func_graph != nullptr);
  47. }
  48. TEST_F(TestParserIntegrate, TestParseGraphTestNestedClosure) {
  49. auto func_graph = getPyFun("test_nested_closure");
  50. ASSERT_TRUE(func_graph != nullptr);
  51. }
  52. TEST_F(TestParserIntegrate, TestParseGraphTestFunctionsInTuples) {
  53. auto func_graph = getPyFun("test_functions_in_tuples");
  54. ASSERT_TRUE(func_graph != nullptr);
  55. }
  56. TEST_F(TestParserIntegrate, TestParseGraphTestClosuresInTuples) {
  57. auto func_graph = getPyFun("test_closures_in_tuples");
  58. ASSERT_TRUE(func_graph != nullptr);
  59. }
  60. TEST_F(TestParserIntegrate, TestParseGraphTestCompileConv2d) {
  61. py::function fn_ = python_adapter::GetPyFn("gtest_input.pipeline.parse.parser_integrate", "test_compile_conv2d");
  62. // fn_();
  63. }
  64. TEST_F(TestParserIntegrate, TestParseGraphTestNone) {
  65. auto func_graph = getPyFun("test_none");
  66. ASSERT_TRUE(func_graph != nullptr);
  67. }
  68. TEST_F(TestParserIntegrate, TestParseGraphResolveGetAttr) {
  69. getPyFun.SetDoResolve(true);
  70. auto func_graph = getPyFun("test_get_attr");
  71. draw::Draw("getattr.dot", func_graph);
  72. ASSERT_TRUE(func_graph != nullptr);
  73. }
  74. /* skip ut test case temporarily
  75. TEST_F(TestParserIntegrate, TestParseGraphResolveUnknown) {
  76. EXPECT_THROW({ python_adapter::CallPyFn("gtest_input.pipeline.parse.parser_integrate", "test_undefined_symbol"); },
  77. std::runtime_error);
  78. }
  79. */
  80. /* #not supported yet
  81. TEST_F(TestParserIntegrate, TestParseGraphTestModelInside) {
  82. py::function fn_ = python_adapter::GetPyFn(
  83. "gtest_input.pipeline.parse.parser_integrate", "test_model_inside");
  84. fn_();
  85. }
  86. */
  87. /* # infer not supported yet
  88. TEST_F(TestParserIntegrate, TestParseGraphTestTensorAdd) {
  89. py::function fn_ = python_adapter::GetPyFn(
  90. "gtest_input.pipeline.parse.parser_integrate", "test_tensor_add");
  91. fn_();
  92. }
  93. TEST_F(TestParserIntegrate, TestParseGraphTestResnet50Build) {
  94. py::function fn_ = python_adapter::GetPyFn(
  95. "gtest_input.pipeline.parse.parser_integrate", "test_resetnet50_build");
  96. fn_();
  97. }
  98. */
  99. } // namespace parse
  100. } // namespace mindspore