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.

graph_executor_test.cc 2.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * Copyright 2022 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 <memory>
  18. #include "common/common_test.h"
  19. #include "utils/log_adapter.h"
  20. #include "pipeline/jit/action.h"
  21. #include "pipeline/jit/pipeline.h"
  22. namespace mindspore {
  23. namespace pipeline {
  24. class TestGraphExecutor : public UT::Common {
  25. public:
  26. TestGraphExecutor() {}
  27. };
  28. /// Feature: Test jit_config
  29. /// Description: Test set jit_level = o0
  30. /// Expectation: success
  31. TEST_F(TestGraphExecutor, test_jit_config_with_jit_level_equal_o0) {
  32. py::dict obj = python_adapter::CallPyFn("gtest_input.pipeline.graph_executor_test", "get_jit_config_o0");
  33. pipeline::GraphExecutorPy::GetInstance()->SetJitConfig(obj);
  34. auto jit_level = pipeline::GetJitLevel();
  35. ASSERT_TRUE(jit_level == "o0");
  36. auto actions = GePipeline();
  37. bool ret = false;
  38. for (auto action : actions) {
  39. if (action.first == "combine_like_graphs") {
  40. ret = true;
  41. }
  42. }
  43. ASSERT_TRUE(ret == false);
  44. }
  45. /// Feature: Test jit_config
  46. /// Description: Test set jit_level = o1
  47. /// Expectation: success
  48. TEST_F(TestGraphExecutor, test_jit_config_with_jit_level_equal_o1) {
  49. py::dict obj = python_adapter::CallPyFn("gtest_input.pipeline.graph_executor_test", "get_jit_config_o1");
  50. pipeline::GraphExecutorPy::GetInstance()->SetJitConfig(obj);
  51. auto jit_level = pipeline::GetJitLevel();
  52. ASSERT_TRUE(jit_level == "o1");
  53. auto actions = GePipeline();
  54. bool ret = false;
  55. for (auto action : actions) {
  56. if (action.first == "combine_like_graphs") {
  57. ret = true;
  58. }
  59. }
  60. ASSERT_TRUE(ret == true);
  61. }
  62. /// Feature: Test jit_config
  63. /// Description: Test jit_level with unused config
  64. /// Expectation: success
  65. TEST_F(TestGraphExecutor, test_jit_config_with_unused_config) {
  66. py::dict obj = python_adapter::CallPyFn("gtest_input.pipeline.graph_executor_test", "get_unused_config");
  67. pipeline::GraphExecutorPy::GetInstance()->SetJitConfig(obj);
  68. auto jit_level = pipeline::GetJitLevel();
  69. ASSERT_TRUE(jit_level == "");
  70. auto actions = GePipeline();
  71. bool ret = false;
  72. for (auto action : actions) {
  73. if (action.first == "combine_like_graphs") {
  74. ret = true;
  75. }
  76. }
  77. ASSERT_TRUE(ret == true);
  78. }
  79. } // namespace pipeline
  80. } // namespace mindspore