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/jit/parse/parse.h" 22 #include "debug/draw.h" 23 24 namespace mindspore { 25 namespace parse { 26 27 class TestParserIntegrate : public UT::Common { 28 public: 29 TestParserIntegrate() : getPyFun("gtest_input.pipeline.parse.parser_integrate") {} 30 virtual void SetUp(); 31 virtual void TearDown(); 32 py::function GetPythonFunction(std::string function); 33 34 public: 35 UT::PyFuncGraphFetcher getPyFun; 36 }; 37 38 void TestParserIntegrate::SetUp() { UT::InitPythonPath(); } 39 40 void TestParserIntegrate::TearDown() {} 41 42 TEST_F(TestParserIntegrate, TestParseGraphTestHighOrderFunction) { 43 auto func_graph = getPyFun("test_high_order_function"); 44 ASSERT_TRUE(func_graph != nullptr); 45 } 46 47 TEST_F(TestParserIntegrate, TestParseGraphTestHofTup) { 48 auto func_graph = getPyFun("test_hof_tup"); 49 ASSERT_TRUE(func_graph != nullptr); 50 } 51 52 TEST_F(TestParserIntegrate, TestParseGraphTestWhile2) { 53 auto func_graph = getPyFun("test_while_2"); 54 ASSERT_TRUE(func_graph != nullptr); 55 } 56 57 TEST_F(TestParserIntegrate, TestParseGraphTestNestedClosure) { 58 auto func_graph = getPyFun("test_nested_closure"); 59 ASSERT_TRUE(func_graph != nullptr); 60 } 61 62 TEST_F(TestParserIntegrate, TestParseGraphTestFunctionsInTuples) { 63 auto func_graph = getPyFun("test_functions_in_tuples"); 64 ASSERT_TRUE(func_graph != nullptr); 65 } 66 67 TEST_F(TestParserIntegrate, TestParseGraphTestClosuresInTuples) { 68 auto func_graph = getPyFun("test_closures_in_tuples"); 69 ASSERT_TRUE(func_graph != nullptr); 70 } 71 72 TEST_F(TestParserIntegrate, TestParseGraphTestCompileConv2d) { 73 py::function fn_ = python_adapter::GetPyFn("gtest_input.pipeline.parse.parser_integrate", "test_compile_conv2d"); 74 // fn_(); 75 } 76 77 TEST_F(TestParserIntegrate, TestParseGraphTestNone) { 78 auto func_graph = getPyFun("test_none"); 79 ASSERT_TRUE(func_graph != nullptr); 80 } 81 82 TEST_F(TestParserIntegrate, TestParseGraphResolveGetAttr) { 83 getPyFun.SetDoResolve(true); 84 auto func_graph = getPyFun("test_get_attr"); 85 ASSERT_TRUE(func_graph != nullptr); 86 } 87 88 /* skip ut test case temporarily 89 TEST_F(TestParserIntegrate, TestParseGraphResolveUnknown) { 90 EXPECT_THROW({ python_adapter::CallPyFn("gtest_input.pipeline.parse.parser_integrate", "test_undefined_symbol"); }, 91 std::runtime_error); 92 } 93 */ 94 95 /* #not supported yet 96 TEST_F(TestParserIntegrate, TestParseGraphTestModelInside) { 97 py::function fn_ = python_adapter::GetPyFn( 98 "gtest_input.pipeline.parse.parser_integrate", "test_model_inside"); 99 fn_(); 100 101 } 102 */ 103 /* # infer not supported yet 104 TEST_F(TestParserIntegrate, TestParseGraphTestTensorAdd) { 105 py::function fn_ = python_adapter::GetPyFn( 106 "gtest_input.pipeline.parse.parser_integrate", "test_tensor_add"); 107 fn_(); 108 } 109 110 TEST_F(TestParserIntegrate, TestParseGraphTestResnet50Build) { 111 py::function fn_ = python_adapter::GetPyFn( 112 "gtest_input.pipeline.parse.parser_integrate", "test_resetnet50_build"); 113 fn_(); 114 } 115 */ 116 } // namespace parse 117 } // namespace mindspore 118