From 70beda36e4bdaacd6348a90df56326a33d077485 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 26 Feb 2021 17:28:44 +0800 Subject: [PATCH 1/3] single_op doesn't execute atomic. --- ge/hybrid/node_executor/aicore/aicore_op_task.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ge/hybrid/node_executor/aicore/aicore_op_task.cc b/ge/hybrid/node_executor/aicore/aicore_op_task.cc index f3699b6c..f7f36a59 100644 --- a/ge/hybrid/node_executor/aicore/aicore_op_task.cc +++ b/ge/hybrid/node_executor/aicore/aicore_op_task.cc @@ -131,7 +131,7 @@ Status AiCoreOpTask::RegisterKernelHandle(const OpDesc &op_desc) { } void *bin_handle = nullptr; - GELOGD("Start to register kernel for node: [%s].", op_desc.GetName().c_str()); + GELOGD("Start to register kernel for node[%s].", op_desc.GetName().c_str()); rtDevBinary_t binary; std::string json_string; GE_IF_BOOL_EXEC(AttrUtils::GetStr(&op_desc, TVM_ATTR_NAME_MAGIC, json_string), @@ -149,7 +149,7 @@ Status AiCoreOpTask::RegisterKernelHandle(const OpDesc &op_desc) { binary.version = 0; binary.data = tbe_kernel->GetBinData(); binary.length = tbe_kernel->GetBinDataSize(); - GELOGI("TBE: binary.length: %lu", binary.length); + GELOGI("TBE: binary.length: %lu.", binary.length); GE_CHK_RT_RET(rtRegisterAllKernel(&binary, &bin_handle)); handle_ = bin_handle; auto holder = std::unique_ptr(new (std::nothrow) TbeHandleHolder(handle_)); @@ -351,6 +351,9 @@ Status AiCoreOpTask::CalcTilingInfo(const NodePtr &node, OpRunInfo &tiling_info) GE_CHK_STATUS_RET(OpParaCalculate(*node, tiling_info), "Failed calc tiling data of node %s.", node->GetName().c_str()); + if (is_single_op_) { + tiling_info.clear_atomic = false; + } GELOGD("[%s] Done invoking OpParaCalculate successfully.", node->GetName().c_str()); return SUCCESS; } From 8da56f278353b75ae8be13bdd77b5359f5aaedc3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 27 Feb 2021 11:39:26 +0800 Subject: [PATCH 2/3] Add ut. --- .../node_executor/aicore/aicore_op_task.cc | 4 +- tests/ut/ge/CMakeLists.txt | 5 +++ tests/ut/ge/exeutor/ge_exeutor_unittest.cc | 43 +++++++++++++++++++ tests/ut/ge/hybrid/ge_hybrid_unittest.cc | 12 ++++++ 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 tests/ut/ge/exeutor/ge_exeutor_unittest.cc diff --git a/ge/hybrid/node_executor/aicore/aicore_op_task.cc b/ge/hybrid/node_executor/aicore/aicore_op_task.cc index f7f36a59..07c2ddb5 100644 --- a/ge/hybrid/node_executor/aicore/aicore_op_task.cc +++ b/ge/hybrid/node_executor/aicore/aicore_op_task.cc @@ -131,7 +131,7 @@ Status AiCoreOpTask::RegisterKernelHandle(const OpDesc &op_desc) { } void *bin_handle = nullptr; - GELOGD("Start to register kernel for node[%s].", op_desc.GetName().c_str()); + GELOGD("Start to register kernel for node: [%s].", op_desc.GetName().c_str()); rtDevBinary_t binary; std::string json_string; GE_IF_BOOL_EXEC(AttrUtils::GetStr(&op_desc, TVM_ATTR_NAME_MAGIC, json_string), @@ -149,7 +149,7 @@ Status AiCoreOpTask::RegisterKernelHandle(const OpDesc &op_desc) { binary.version = 0; binary.data = tbe_kernel->GetBinData(); binary.length = tbe_kernel->GetBinDataSize(); - GELOGI("TBE: binary.length: %lu.", binary.length); + GELOGI("TBE: binary.length: %lu", binary.length); GE_CHK_RT_RET(rtRegisterAllKernel(&binary, &bin_handle)); handle_ = bin_handle; auto holder = std::unique_ptr(new (std::nothrow) TbeHandleHolder(handle_)); diff --git a/tests/ut/ge/CMakeLists.txt b/tests/ut/ge/CMakeLists.txt index b8eb3e22..d0aa8b21 100755 --- a/tests/ut/ge/CMakeLists.txt +++ b/tests/ut/ge/CMakeLists.txt @@ -760,6 +760,10 @@ set(GENERATOR_TEST_FILES "generator/ge_generator_unittest.cc" ) +set(EXECUTOR_TEST_FILES + "exeutor/ge_exeutor_unittest.cc" +) + set(SINGLE_OP_TEST_FILES "single_op/single_op_model_unittest.cc" "single_op/single_op_manager_unittest.cc" @@ -1066,6 +1070,7 @@ target_link_libraries(ut_libge_kernel_utest add_executable(ut_libge_distinct_load_utest ${COMMON_TEST_FILES} ${GENERATOR_TEST_FILES} + ${EXECUTOR_TEST_FILES} ${DISTINCT_GRAPH_LOAD_TEST_FILES} ${DISTINCT_GRAPH_LOAD_SRC_FILES} ${SINGLE_OP_TEST_FILES} diff --git a/tests/ut/ge/exeutor/ge_exeutor_unittest.cc b/tests/ut/ge/exeutor/ge_exeutor_unittest.cc new file mode 100644 index 00000000..c80b59a5 --- /dev/null +++ b/tests/ut/ge/exeutor/ge_exeutor_unittest.cc @@ -0,0 +1,43 @@ +/** + * Copyright 2019-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 + +#define private public +#define protected public +#include "generator/ge_executor.h" +#include "graph/utils/tensor_utils.h" + +using namespace std; + +namespace ge { +class UtestGeExecutor : public testing::Test { + protected: + void SetUp() {} + + void TearDown() {} +}; + +TEST_F(UtestGeExecutor, test_single_op_exec) { + GeExecutor exeutor; + ModelData model_data; + string model_name = "1234"; + void *stream = nullptr; + SingleOp *single_op = nullptr; + + exeutor.LoadSingleOp(model_name, model_data, stream, single_op); +} +} // namespace ge diff --git a/tests/ut/ge/hybrid/ge_hybrid_unittest.cc b/tests/ut/ge/hybrid/ge_hybrid_unittest.cc index 61f99950..c7e0e2fa 100644 --- a/tests/ut/ge/hybrid/ge_hybrid_unittest.cc +++ b/tests/ut/ge/hybrid/ge_hybrid_unittest.cc @@ -98,4 +98,16 @@ TEST_F(UtestGeHybrid, aicore_op_task_init_success) { aicore_task->handle_ = handle; aicore_task->tiling_key_ = 1; ASSERT_EQ(aicore_task->LaunchKernel(stream), SUCCESS); +} + +TEST_F(UtestGeHybrid, task_update_tiling_info) { + auto aicore_task = std::unique_ptr(new(std::nothrow)hybrid::AiCoreOpTask()); + aicore_task->is_single_op_ = true; + auto graph = make_shared("graph"); + OpDescPtr op_desc = CreateOpDesc("Add", "Add"); + ge::AttrUtils::SetStr(op_desc, "compile_info_key", "key"); + ge::AttrUtils::SetStr(op_desc, "compile_info_json", "json"); + auto node = graph->AddNode(op_desc); + optiling::OpRunInfo tiling_info; + ASSERT_EQ(aicore_task->CalcTilingInfo(node, tiling_info), SUCCESS) } \ No newline at end of file From fb9a4373c76eb97abe9f5a9b70723f80656ccde7 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 27 Feb 2021 11:43:19 +0800 Subject: [PATCH 3/3] Fix ut. --- tests/ut/ge/CMakeLists.txt | 5 --- tests/ut/ge/exeutor/ge_exeutor_unittest.cc | 43 ---------------------- tests/ut/ge/hybrid/ge_hybrid_unittest.cc | 2 +- 3 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 tests/ut/ge/exeutor/ge_exeutor_unittest.cc diff --git a/tests/ut/ge/CMakeLists.txt b/tests/ut/ge/CMakeLists.txt index d0aa8b21..b8eb3e22 100755 --- a/tests/ut/ge/CMakeLists.txt +++ b/tests/ut/ge/CMakeLists.txt @@ -760,10 +760,6 @@ set(GENERATOR_TEST_FILES "generator/ge_generator_unittest.cc" ) -set(EXECUTOR_TEST_FILES - "exeutor/ge_exeutor_unittest.cc" -) - set(SINGLE_OP_TEST_FILES "single_op/single_op_model_unittest.cc" "single_op/single_op_manager_unittest.cc" @@ -1070,7 +1066,6 @@ target_link_libraries(ut_libge_kernel_utest add_executable(ut_libge_distinct_load_utest ${COMMON_TEST_FILES} ${GENERATOR_TEST_FILES} - ${EXECUTOR_TEST_FILES} ${DISTINCT_GRAPH_LOAD_TEST_FILES} ${DISTINCT_GRAPH_LOAD_SRC_FILES} ${SINGLE_OP_TEST_FILES} diff --git a/tests/ut/ge/exeutor/ge_exeutor_unittest.cc b/tests/ut/ge/exeutor/ge_exeutor_unittest.cc deleted file mode 100644 index c80b59a5..00000000 --- a/tests/ut/ge/exeutor/ge_exeutor_unittest.cc +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright 2019-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 - -#define private public -#define protected public -#include "generator/ge_executor.h" -#include "graph/utils/tensor_utils.h" - -using namespace std; - -namespace ge { -class UtestGeExecutor : public testing::Test { - protected: - void SetUp() {} - - void TearDown() {} -}; - -TEST_F(UtestGeExecutor, test_single_op_exec) { - GeExecutor exeutor; - ModelData model_data; - string model_name = "1234"; - void *stream = nullptr; - SingleOp *single_op = nullptr; - - exeutor.LoadSingleOp(model_name, model_data, stream, single_op); -} -} // namespace ge diff --git a/tests/ut/ge/hybrid/ge_hybrid_unittest.cc b/tests/ut/ge/hybrid/ge_hybrid_unittest.cc index c7e0e2fa..97a36894 100644 --- a/tests/ut/ge/hybrid/ge_hybrid_unittest.cc +++ b/tests/ut/ge/hybrid/ge_hybrid_unittest.cc @@ -109,5 +109,5 @@ TEST_F(UtestGeHybrid, task_update_tiling_info) { ge::AttrUtils::SetStr(op_desc, "compile_info_json", "json"); auto node = graph->AddNode(op_desc); optiling::OpRunInfo tiling_info; - ASSERT_EQ(aicore_task->CalcTilingInfo(node, tiling_info), SUCCESS) + ASSERT_EQ(aicore_task->CalcTilingInfo(node, tiling_info), SUCCESS); } \ No newline at end of file