| @@ -95,6 +95,7 @@ else () | |||||
| #find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) | #find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) | ||||
| else() | else() | ||||
| find_module(slog libalog.so ${ASCEND_ATC_DIR}) | find_module(slog libalog.so ${ASCEND_ATC_DIR}) | ||||
| find_module(opt_feature libopt_feature.so ${ASCEND_ATC_DIR}) | |||||
| find_module(static_mmpa libmmpa.a ${ASCEND_ATC_DIR}) | find_module(static_mmpa libmmpa.a ${ASCEND_ATC_DIR}) | ||||
| if(PLATFORM STREQUAL "train") | if(PLATFORM STREQUAL "train") | ||||
| find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) | find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) | ||||
| @@ -434,6 +434,7 @@ set(TRAIN_SRC_LIST | |||||
| "graph/build/memory/max_block_mem_assigner.cc" | "graph/build/memory/max_block_mem_assigner.cc" | ||||
| "graph/build/memory/var_mem_assign_util.cc" | "graph/build/memory/var_mem_assign_util.cc" | ||||
| "graph/build/memory/buffer_pool_mem_assigner.cc" | "graph/build/memory/buffer_pool_mem_assigner.cc" | ||||
| "ge_opt_info/ge_opt_info.cc" | |||||
| ) | ) | ||||
| set(INFER_SRC_LIST | set(INFER_SRC_LIST | ||||
| @@ -711,6 +712,7 @@ set(INFER_SRC_LIST | |||||
| "graph/build/memory/max_block_mem_assigner.cc" | "graph/build/memory/max_block_mem_assigner.cc" | ||||
| "graph/build/memory/var_mem_assign_util.cc" | "graph/build/memory/var_mem_assign_util.cc" | ||||
| "graph/build/memory/buffer_pool_mem_assigner.cc" | "graph/build/memory/buffer_pool_mem_assigner.cc" | ||||
| "ge_opt_info/ge_opt_info.cc" | |||||
| ) | ) | ||||
| if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) | if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) | ||||
| @@ -765,11 +767,13 @@ target_include_directories(ge_runner SYSTEM PRIVATE | |||||
| ${GE_CODE_DIR}/../inc | ${GE_CODE_DIR}/../inc | ||||
| ${GE_CODE_DIR}/../toolchain/ide/ide-daemon/external | ${GE_CODE_DIR}/../toolchain/ide/ide-daemon/external | ||||
| ${GE_CODE_DIR}/../abl/adump/external | ${GE_CODE_DIR}/../abl/adump/external | ||||
| ${GE_CODE_DIR}/../abl/licctrl | |||||
| #### blue zone | #### blue zone | ||||
| ${ASCEND_DIR}/driver/include | ${ASCEND_DIR}/driver/include | ||||
| ${ASCEND_DIR}/fwkacllib/include | ${ASCEND_DIR}/fwkacllib/include | ||||
| ${GE_CODE_DIR}/third_party/fwkacllib/inc | ${GE_CODE_DIR}/third_party/fwkacllib/inc | ||||
| ${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain | ${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain | ||||
| ${GE_CODE_DIR}/third_party/fwkacllib/inc/opt_info | |||||
| ) | ) | ||||
| target_link_options(ge_runner PRIVATE | target_link_options(ge_runner PRIVATE | ||||
| @@ -792,6 +796,7 @@ target_link_libraries(ge_runner PRIVATE | |||||
| runtime | runtime | ||||
| error_manager | error_manager | ||||
| ascend_hal_stub | ascend_hal_stub | ||||
| opt_feature | |||||
| -Wl,--as-needed | -Wl,--as-needed | ||||
| json | json | ||||
| -lrt | -lrt | ||||
| @@ -839,11 +844,13 @@ target_include_directories(ge_compiler SYSTEM PRIVATE | |||||
| ${GE_CODE_DIR}/../inc | ${GE_CODE_DIR}/../inc | ||||
| ${GE_CODE_DIR}/../toolchain/ide/ide-daemon/external | ${GE_CODE_DIR}/../toolchain/ide/ide-daemon/external | ||||
| ${GE_CODE_DIR}/../abl/adump/external | ${GE_CODE_DIR}/../abl/adump/external | ||||
| ${GE_CODE_DIR}/../abl/licctrl | |||||
| #### blue zone #### | #### blue zone #### | ||||
| ${ASCEND_DIR}/driver/include | ${ASCEND_DIR}/driver/include | ||||
| ${ASCEND_DIR}/fwkacllib/include | ${ASCEND_DIR}/fwkacllib/include | ||||
| ${GE_CODE_DIR}/third_party/fwkacllib/inc | ${GE_CODE_DIR}/third_party/fwkacllib/inc | ||||
| ${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain | ${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain | ||||
| ${GE_CODE_DIR}/third_party/fwkacllib/inc/opt_info | |||||
| ) | ) | ||||
| target_link_options(ge_compiler PRIVATE | target_link_options(ge_compiler PRIVATE | ||||
| @@ -863,6 +870,7 @@ target_link_libraries(ge_compiler PRIVATE | |||||
| error_manager | error_manager | ||||
| slog | slog | ||||
| runtime_compile | runtime_compile | ||||
| opt_feature | |||||
| -Wl,--as-needed | -Wl,--as-needed | ||||
| json | json | ||||
| -lrt | -lrt | ||||
| @@ -0,0 +1,58 @@ | |||||
| /** | |||||
| * Copyright 2021 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 "ge_opt_info/ge_opt_info.h" | |||||
| #include <string> | |||||
| #include <map> | |||||
| #include "graph/ge_local_context.h" | |||||
| #include "ge/ge_api_types.h" | |||||
| #include "common/debug/ge_log.h" | |||||
| #include "opt_info.h" | |||||
| namespace ge { | |||||
| Status GeOptInfo::SetOptInfo() { | |||||
| std::string soc_ver; | |||||
| graphStatus ret = GetThreadLocalContext().GetOption(SOC_VERSION, soc_ver); | |||||
| if (ret != GRAPH_SUCCESS) { | |||||
| REPORT_CALL_ERROR("E19999", "Get soc version failed."); | |||||
| GELOGE(FAILED, "[Get][SocVersion]Get soc version failed."); | |||||
| return FAILED; | |||||
| } | |||||
| GELOGD("Soc version:%s.", soc_ver.c_str()); | |||||
| std::map<std::string, std::string> opt_info; | |||||
| // the first arg does not work at present. | |||||
| if (gelc::GetOptInfo(gelc::kOffline, soc_ver, opt_info) != gelc::SUCCESS) { | |||||
| REPORT_CALL_ERROR("E19999", "Get optional information failed, is_offline:%d, soc version:%s", | |||||
| gelc::kOffline, soc_ver.c_str()); | |||||
| GELOGE(FAILED, "[Get][OptInfo]Get optional information failed, is_offline:%d, soc version:%s", | |||||
| gelc::kOffline, soc_ver.c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| // do nothing if get empty information | |||||
| if (opt_info.empty()) { | |||||
| GELOGI("Optional information is empty."); | |||||
| return SUCCESS; | |||||
| } | |||||
| std::map<std::string, std::string> graph_options = GetThreadLocalContext().GetAllGraphOptions(); | |||||
| for (const auto &itr : opt_info) { | |||||
| graph_options.emplace(itr.first, itr.second); | |||||
| GELOGI("Get optional information success, key:%s, value:%s.", itr.first.c_str(), itr.second.c_str()); | |||||
| } | |||||
| GetThreadLocalContext().SetGraphOption(graph_options); | |||||
| return SUCCESS; | |||||
| } | |||||
| } // namespace ge | |||||
| @@ -0,0 +1,31 @@ | |||||
| /** | |||||
| * Copyright 2021 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. | |||||
| */ | |||||
| #ifndef GE_OPT_INFO_GE_OPT_INFO_H_ | |||||
| #define GE_OPT_INFO_GE_OPT_INFO_H_ | |||||
| #include "ge/ge_api_error_codes.h" | |||||
| #include "register/register_types.h" | |||||
| namespace ge { | |||||
| class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY GeOptInfo { | |||||
| public: | |||||
| GeOptInfo() = default; | |||||
| static Status SetOptInfo(); | |||||
| }; | |||||
| } // namespace ge | |||||
| #endif // GE_OPT_INFO_GE_OPT_INFO_H_ | |||||
| @@ -27,6 +27,7 @@ | |||||
| #include "common/math/math_util.h" | #include "common/math/math_util.h" | ||||
| #include "common/thread_pool.h" | #include "common/thread_pool.h" | ||||
| #include "common/dump/dump_manager.h" | #include "common/dump/dump_manager.h" | ||||
| #include "ge_opt_info/ge_opt_info.h" | |||||
| #include "analyzer/analyzer.h" | #include "analyzer/analyzer.h" | ||||
| #include "graph/common/ge_call_wrapper.h" | #include "graph/common/ge_call_wrapper.h" | ||||
| #include "graph/common/local_context.h" | #include "graph/common/local_context.h" | ||||
| @@ -1001,6 +1002,12 @@ Status GraphManager::PreRun(const GraphNodePtr &graph_node, const std::vector<Ge | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| ret = GeOptInfo::SetOptInfo(); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "[Set][OptInfo] Set optional information failed."); | |||||
| return ret; | |||||
| } | |||||
| /// 1. BUILD_MODE_TUNING with BUILD_STEP_AFTER_UB_MATCH no need PreRunOptimizeOriginalGraph; | /// 1. BUILD_MODE_TUNING with BUILD_STEP_AFTER_UB_MATCH no need PreRunOptimizeOriginalGraph; | ||||
| /// 2. BUILD_MODE_TUNING with BUILD_STEP_AFTER_MERGE no need PreRunOptimizeOriginalGraph. | /// 2. BUILD_MODE_TUNING with BUILD_STEP_AFTER_MERGE no need PreRunOptimizeOriginalGraph. | ||||
| /// 3. BUILD_MODE_TUNING with BUILD_STEP_AFTER_BUILDER_SUB no need PreRunOptimizeOriginalGraph. | /// 3. BUILD_MODE_TUNING with BUILD_STEP_AFTER_BUILDER_SUB no need PreRunOptimizeOriginalGraph. | ||||
| @@ -22,6 +22,7 @@ add_subdirectory(depends/runtime) | |||||
| add_subdirectory(depends/hccl) | add_subdirectory(depends/hccl) | ||||
| add_subdirectory(depends/profiler) | add_subdirectory(depends/profiler) | ||||
| add_subdirectory(depends/error_manager) | add_subdirectory(depends/error_manager) | ||||
| add_subdirectory(depends/opt_info) | |||||
| if (ENABLE_GE_COV OR ENABLE_GE_UT) | if (ENABLE_GE_COV OR ENABLE_GE_UT) | ||||
| add_subdirectory(ut) | add_subdirectory(ut) | ||||
| @@ -0,0 +1,37 @@ | |||||
| # Copyright 2021 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. | |||||
| # ============================================================================ | |||||
| #cmake_minimum_required(VERSION 2.8) | |||||
| project(opt_feature_stub) | |||||
| file(GLOB_RECURSE SRCS RELATIVE ${CMAKE_CURRENT_LIST_DIR} | |||||
| "src/opt_info_stub.cc" | |||||
| ) | |||||
| include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/opt_info) | |||||
| add_library(opt_feature_stub SHARED ${SRCS}) | |||||
| target_compile_options(opt_feature_stub PRIVATE | |||||
| -g | |||||
| ) | |||||
| target_link_libraries(opt_feature_stub PRIVATE | |||||
| $<BUILD_INTERFACE:intf_pub> | |||||
| c_sec | |||||
| ) | |||||
| target_include_directories(opt_feature_stub INTERFACE ${CMAKE_CURRENT_LIST_DIR}/src) | |||||
| @@ -0,0 +1,46 @@ | |||||
| /** | |||||
| * Copyright 2021 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 "opt_info.h" | |||||
| #include <string> | |||||
| #include <map> | |||||
| #include <vector> | |||||
| #include <algorithm> | |||||
| namespace gelc { | |||||
| namespace { | |||||
| const std::vector<std::string> kSocVersions = {"Ascend910"}; | |||||
| } | |||||
| void SetAllOptInfo(std::map<std::string, std::string> &opt_infos) { | |||||
| opt_infos.emplace("opt_module.fe", "all"); | |||||
| opt_infos.emplace("opt_module.pass", "all"); | |||||
| opt_infos.emplace("opt_module.op_tune", "all"); | |||||
| opt_infos.emplace("opt_module.rl_tune", "all"); | |||||
| opt_infos.emplace("opt_module.aoe", "all"); | |||||
| } | |||||
| Status GetOptInfo(WorkMode mode, const std::string &soc_ver, | |||||
| std::map<std::string, std::string> &opt_infos) { | |||||
| if (std::find(kSocVersions.begin(), kSocVersions.end(), soc_ver)== kSocVersions.end()) { | |||||
| SetAllOptInfo(opt_infos); | |||||
| return SUCCESS; | |||||
| } | |||||
| opt_infos.emplace("opt_module.fe", "all"); | |||||
| opt_infos.emplace("opt_module.pass", "all"); | |||||
| opt_infos.emplace("opt_module.op_tune", "all"); | |||||
| return SUCCESS; | |||||
| } | |||||
| } // namespace gelc | |||||
| @@ -103,6 +103,7 @@ list(APPEND INCLUDE_DIRECTORIES | |||||
| "${GE_CODE_DIR}/third_party/fwkacllib/inc/cce" | "${GE_CODE_DIR}/third_party/fwkacllib/inc/cce" | ||||
| "${GE_CODE_DIR}/third_party/fwkacllib/inc/ops" | "${GE_CODE_DIR}/third_party/fwkacllib/inc/ops" | ||||
| "${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain" | "${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain" | ||||
| "${GE_CODE_DIR}/third_party/fwkacllib/inc/opt_info" | |||||
| "${GE_CODE_DIR}/tests/ut/ge" | "${GE_CODE_DIR}/tests/ut/ge" | ||||
| "${GE_CODE_DIR}/tests/ut/common" | "${GE_CODE_DIR}/tests/ut/common" | ||||
| "${CMAKE_BINARY_DIR}" | "${CMAKE_BINARY_DIR}" | ||||
| @@ -117,6 +118,7 @@ list(APPEND STUB_LIBS | |||||
| runtime_stub | runtime_stub | ||||
| profiler_stub | profiler_stub | ||||
| hccl_stub | hccl_stub | ||||
| opt_feature_stub | |||||
| error_manager_stub | error_manager_stub | ||||
| ascend_protobuf | ascend_protobuf | ||||
| json | json | ||||
| @@ -0,0 +1,123 @@ | |||||
| /** | |||||
| * Copyright 2021 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 <gtest/gtest.h> | |||||
| #include "easy_graph/graph/box.h" | |||||
| #include "easy_graph/graph/node.h" | |||||
| #include "easy_graph/builder/graph_dsl.h" | |||||
| #include "easy_graph/builder/box_builder.h" | |||||
| #include "easy_graph/layout/graph_layout.h" | |||||
| #include "easy_graph/layout/engines/graph_easy/graph_easy_option.h" | |||||
| #include "easy_graph/layout/engines/graph_easy/graph_easy_executor.h" | |||||
| #include "graph/graph.h" | |||||
| #include "graph/compute_graph.h" | |||||
| #include "framework/common/types.h" | |||||
| #include "graph/debug/ge_attr_define.h" | |||||
| #include "ge_graph_dsl/graph_dsl.h" | |||||
| #include "ge_graph_dsl/op_desc/op_desc_cfg_box.h" | |||||
| #define protected public | |||||
| #define private public | |||||
| #include "ge_opt_info/ge_opt_info.h" | |||||
| #undef private | |||||
| #undef protected | |||||
| namespace ge { | |||||
| class STEST_opt_info : public testing::Test { | |||||
| protected: | |||||
| void SetUp() {} | |||||
| void TearDown() {} | |||||
| }; | |||||
| TEST_F(STEST_opt_info, get_opt_info_all) { | |||||
| std::map<std::string, std::string> options = {{ge::SOC_VERSION, "Ascend310"}}; | |||||
| GetThreadLocalContext().SetGlobalOption(options); | |||||
| /// data1 data2 | |||||
| /// \ / | |||||
| /// add | |||||
| // build graph | |||||
| DEF_GRAPH(g1) { | |||||
| CHAIN(NODE("data1", DATA)->NODE("add", ADD)); | |||||
| CHAIN(NODE("data2", DATA)->NODE("add")); | |||||
| }); | |||||
| auto graph = ToGeGraph(g1); | |||||
| // new session & add graph | |||||
| Session session(options); | |||||
| auto ret = session.AddGraph(1, graph, options); | |||||
| EXPECT_EQ(ret, SUCCESS); | |||||
| // build input tensor | |||||
| std::vector<InputTensorInfo> inputs; | |||||
| // build_graph through session | |||||
| ret = session.BuildGraph(1, inputs); | |||||
| EXPECT_EQ(ret, SUCCESS); | |||||
| std::map<std::string, std::string> graph_options = GetThreadLocalContext().GetAllGraphOptions(); | |||||
| auto itr = graph_options.find("opt_module.fe"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| itr = graph_options.find("opt_module.pass"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| itr = graph_options.find("opt_module.op_tune"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| itr = graph_options.find("opt_module.rl_tune"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| itr = graph_options.find("opt_module.aoe"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| } | |||||
| TEST_F(STEST_opt_info, get_opt_info_success) { | |||||
| std::map<std::string, std::string> options = {{ge::SOC_VERSION, "Ascend910"}}; | |||||
| GetThreadLocalContext().SetGlobalOption(options); | |||||
| /// data1 data2 | |||||
| /// \ / | |||||
| /// add | |||||
| // build graph | |||||
| DEF_GRAPH(g1) { | |||||
| CHAIN(NODE("data1", DATA)->NODE("add", ADD)); | |||||
| CHAIN(NODE("data2", DATA)->NODE("add")); | |||||
| }); | |||||
| auto graph = ToGeGraph(g1); | |||||
| // new session & add graph | |||||
| Session session(options); | |||||
| auto ret = session.AddGraph(1, graph, options); | |||||
| EXPECT_EQ(ret, SUCCESS); | |||||
| // build input tensor | |||||
| std::vector<InputTensorInfo> inputs; | |||||
| // build_graph through session | |||||
| ret = session.BuildGraph(1, inputs); | |||||
| EXPECT_EQ(ret, SUCCESS); | |||||
| std::map<std::string, std::string> graph_options = GetThreadLocalContext().GetAllGraphOptions(); | |||||
| auto itr = graph_options.find("opt_module.fe"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| itr = graph_options.find("opt_module.pass"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| itr = graph_options.find("opt_module.op_tune"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| } | |||||
| } // namespace ge | |||||
| @@ -62,6 +62,7 @@ include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc) | |||||
| include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/cce) | include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/cce) | ||||
| include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/ops) | include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/ops) | ||||
| include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain) | include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain) | ||||
| include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/opt_info) | |||||
| include_directories(${GE_CODE_DIR}/tests/ut/ge) | include_directories(${GE_CODE_DIR}/tests/ut/ge) | ||||
| include_directories(${GE_CODE_DIR}/tests/ut/common) | include_directories(${GE_CODE_DIR}/tests/ut/common) | ||||
| include_directories(${CMAKE_BINARY_DIR}) | include_directories(${CMAKE_BINARY_DIR}) | ||||
| @@ -346,6 +347,7 @@ set(COMMON_SRC_FILES | |||||
| "${GE_CODE_DIR}/ge/common/ge/datatype_util.cc" | "${GE_CODE_DIR}/ge/common/ge/datatype_util.cc" | ||||
| "${GE_CODE_DIR}/ge/ge_local_engine/engine/host_cpu_engine.cc" | "${GE_CODE_DIR}/ge/ge_local_engine/engine/host_cpu_engine.cc" | ||||
| "${GE_CODE_DIR}/ge/session/omg.cc" | "${GE_CODE_DIR}/ge/session/omg.cc" | ||||
| "${GE_CODE_DIR}/ge/ge_opt_info/ge_opt_info.cc" | |||||
| ) | ) | ||||
| set(COMMON_FORMAT_SRC_FILES | set(COMMON_FORMAT_SRC_FILES | ||||
| @@ -453,6 +455,7 @@ set(GRAPH_EXECUTE_COMMON_SRC_FILES | |||||
| "${GE_CODE_DIR}/ge/graph/manager/graph_manager.cc" | "${GE_CODE_DIR}/ge/graph/manager/graph_manager.cc" | ||||
| "${GE_CODE_DIR}/ge/graph/manager/graph_context.cc" | "${GE_CODE_DIR}/ge/graph/manager/graph_context.cc" | ||||
| "${GE_CODE_DIR}/ge/graph/manager/util/rt_context_util.cc" | "${GE_CODE_DIR}/ge/graph/manager/util/rt_context_util.cc" | ||||
| "${GE_CODE_DIR}/ge/ge_opt_info/ge_opt_info.cc" | |||||
| "${GE_CODE_DIR}/ge/graph/manager/graph_context.h" | "${GE_CODE_DIR}/ge/graph/manager/graph_context.h" | ||||
| ) | ) | ||||
| @@ -628,6 +631,10 @@ set(SINGLE_OP_SRC_FILES | |||||
| "${GE_CODE_DIR}/ge/hybrid/hybrid_davinci_model.cc" | "${GE_CODE_DIR}/ge/hybrid/hybrid_davinci_model.cc" | ||||
| ) | ) | ||||
| set(GE_OPT_INFO_SRC_FILES | |||||
| "${GE_CODE_DIR}/ge/ge_opt_info/ge_opt_info.cc" | |||||
| ) | |||||
| # test files | # test files | ||||
| set(COMMON_TEST_FILES | set(COMMON_TEST_FILES | ||||
| "graph/passes/graph_builder_utils.cc" | "graph/passes/graph_builder_utils.cc" | ||||
| @@ -813,6 +820,10 @@ set(MULTI_PARTS_TEST_FILES | |||||
| "common/host_cpu_engine_unittest.cc" | "common/host_cpu_engine_unittest.cc" | ||||
| ) | ) | ||||
| set(GE_OPT_INFO_TEST_FILES | |||||
| "ge_opt_info/ge_opt_info_unittest.cc" | |||||
| ) | |||||
| set(GENERATOR_TEST_FILES | set(GENERATOR_TEST_FILES | ||||
| "generator/ge_generator_unittest.cc" | "generator/ge_generator_unittest.cc" | ||||
| ) | ) | ||||
| @@ -864,6 +875,7 @@ list(APPEND COMMON_SHARED_LIBRARIES | |||||
| mmpa_stub | mmpa_stub | ||||
| hccl_stub | hccl_stub | ||||
| error_manager_stub | error_manager_stub | ||||
| opt_feature_stub | |||||
| ascend_protobuf | ascend_protobuf | ||||
| json | json | ||||
| ) | ) | ||||
| @@ -1109,10 +1121,12 @@ target_link_libraries(ut_libge_multiparts_utest | |||||
| # libge_others_utest | # libge_others_utest | ||||
| add_executable(ut_libge_others_utest | add_executable(ut_libge_others_utest | ||||
| ${GE_OPT_INFO_SRC_FILES} | |||||
| ${COMMON_TEST_FILES} | ${COMMON_TEST_FILES} | ||||
| ${PASS_TEST_FILES} | ${PASS_TEST_FILES} | ||||
| ${EXECUTE_TEST_FILES} | ${EXECUTE_TEST_FILES} | ||||
| ${OTHERS_TEST_FILES} | ${OTHERS_TEST_FILES} | ||||
| ${GE_OPT_INFO_TEST_FILES} | |||||
| ) | ) | ||||
| target_compile_options(ut_libge_others_utest PRIVATE | target_compile_options(ut_libge_others_utest PRIVATE | ||||
| @@ -0,0 +1,82 @@ | |||||
| /** | |||||
| * Copyright 2021 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 <gtest/gtest.h> | |||||
| #include <gmock/gmock.h> | |||||
| #define protected public | |||||
| #define private public | |||||
| #include "ge_opt_info/ge_opt_info.h" | |||||
| #include "graph/ge_local_context.h" | |||||
| #include "external/ge/ge_api_types.h" | |||||
| #undef private | |||||
| #undef protected | |||||
| namespace ge { | |||||
| class UTEST_opt_info : public testing::Test { | |||||
| protected: | |||||
| void SetUp() {} | |||||
| void TearDown() {} | |||||
| }; | |||||
| TEST_F(UTEST_opt_info, get_opt_info_success) { | |||||
| std::map<std::string, std::string> options = {{ge::SOC_VERSION, "Ascend910"}}; | |||||
| GetThreadLocalContext().SetGlobalOption(options); | |||||
| auto ret = GeOptInfo::SetOptInfo(); | |||||
| EXPECT_EQ(ret, ge::SUCCESS); | |||||
| std::map<std::string, std::string> graph_options = GetThreadLocalContext().GetAllGraphOptions(); | |||||
| auto itr = graph_options.find("opt_module.fe"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| itr = graph_options.find("opt_module.pass"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| itr = graph_options.find("opt_module.op_tune"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| } | |||||
| TEST_F(UTEST_opt_info, get_opt_info_all) { | |||||
| std::map<std::string, std::string> global_options = {{ge::SOC_VERSION, "Ascend310"}}; | |||||
| GetThreadLocalContext().SetGlobalOption(global_options); | |||||
| auto ret = GeOptInfo::SetOptInfo(); | |||||
| EXPECT_EQ(ret, ge::SUCCESS); | |||||
| std::map<std::string, std::string> graph_options = GetThreadLocalContext().GetAllGraphOptions(); | |||||
| auto itr = graph_options.find("opt_module.fe"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| itr = graph_options.find("opt_module.pass"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| itr = graph_options.find("opt_module.op_tune"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| itr = graph_options.find("opt_module.rl_tune"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| itr = graph_options.find("opt_module.aoe"); | |||||
| EXPECT_NE(itr, graph_options.end()); | |||||
| EXPECT_EQ(itr->second, "all"); | |||||
| } | |||||
| TEST_F(UTEST_opt_info, get_opt_info_failed) { | |||||
| std::map<std::string, std::string> options; | |||||
| GetThreadLocalContext().SetGlobalOption(options); | |||||
| auto ret = GeOptInfo::SetOptInfo(); | |||||
| EXPECT_EQ(ret, ge::FAILED); | |||||
| } | |||||
| } // namespace ge | |||||
| @@ -0,0 +1,32 @@ | |||||
| /** | |||||
| * Copyright 2021 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 <string> | |||||
| #include <map> | |||||
| namespace gelc { | |||||
| using Status = uint32_t; | |||||
| using WorkMode = uint32_t; | |||||
| const Status SUCCESS = 0x0; | |||||
| const Status FAILED = 0xFFFFFFFF; | |||||
| const WorkMode kOffline = 0x0; | |||||
| const WorkMode kInline = 0x01; | |||||
| __attribute__((visibility ("default"))) | |||||
| Status GetOptInfo(WorkMode mode, const std::string &soc_ver, | |||||
| std::map<std::string, std::string> &opt_info_map); | |||||
| } // namespace gelc | |||||