!1134 Add critical path log

From: @zhangxiaokun9
Reviewed-by: @xchu42,@wqtshg
Signed-off-by: @ji_chen
pull/1134/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit e949a7ce48

@ -53,6 +53,7 @@ string PluginManager::GetPath() {
GELOGW("Failed to read the shared library file path!");
return string();
} else {
GE_IF_BOOL_EXEC(dl_info.dli_fname == nullptr, return string());
std::string so_path = dl_info.dli_fname;
char path[MMPA_MAX_PATH] = {0};
if (so_path.length() >= MMPA_MAX_PATH) {

@ -147,7 +147,7 @@ static Status CheckEngineTypeSupport(const OpDescPtr &op_desc, OpEngineType engi
return FAILED;
}
static Status AddInputs(const ComputeGraphPtr &graph, const NodePtr &node, GeTensorDesc &tensor, int32_t index,
static Status AddInputs(const ComputeGraphPtr &graph, const NodePtr &node, const GeTensorDesc &tensor, int32_t index,
bool attr) {
GE_CHECK_NOTNULL_EXEC(graph, return PARAM_INVALID);
GE_CHECK_NOTNULL_EXEC(node, return PARAM_INVALID);
@ -671,6 +671,8 @@ Status GeGenerator::CheckForSingleOp(OpDescPtr &op_desc, const vector<GeTensor>
Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &inputs, const vector<GeTensor> &outputs,
const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff,
bool is_offline) {
GE_CHECK_NOTNULL_EXEC(impl_, return PARAM_INVALID);
impl_->is_offline_ = is_offline;
if (!is_offline) {
(void)AttrUtils::SetBool(op_desc, ATTR_SINGLE_OP_SCENE, true);
}
@ -709,8 +711,6 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &in
GELOGI("ATC parser success in single op build.");
GeRootModelPtr ge_root_model = nullptr;
GE_CHECK_NOTNULL_EXEC(impl_, return PARAM_INVALID);
impl_->is_offline_ = is_offline;
GE_CHK_STATUS_RET_NOLOG(impl_->BuildModel(graph, inputs, ge_root_model));
map<string, GeAttrValue> op_attrs = op_desc_tmp->GetAllAttrs();
GE_CHECK_NOTNULL(ge_root_model);
@ -723,7 +723,7 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &in
const ComputeGraphPtr root_graph = ge_root_model->GetRootGraph();
GeModelPtr &ge_model = name_to_ge_model.begin()->second;
GE_CHK_STATUS_RET_NOLOG(CheckDynamicSupport(ge_model, root_graph));
GELOGD("The opType in op_desc_tmp is [%s]", op_desc_tmp->GetType().c_str());
GELOGI("After build model, The opType in op_desc_tmp is [%s]", op_desc_tmp->GetType().c_str());
bool all_shape = false;
(void)AttrUtils::GetBool(op_desc, kAicpuAllshape, all_shape);
@ -738,6 +738,7 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &in
} else {
GE_CHK_STATUS_RET_NOLOG(impl_->SaveParams(ge_model, op_desc_tmp->GetType(), op_attrs, inputs, outputs));
}
GELOGI("Start save GeModel to Model buffer");
GE_CHK_STATUS_RET_NOLOG(impl_->SaveModel(model_file_name, ge_model, model_buff));
return SUCCESS;
}
@ -753,10 +754,12 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &in
*/
Status GeGenerator::BuildSingleOpModel(OpDescPtr &op_desc, const vector<GeTensor> &inputs,
const vector<GeTensor> &outputs, const string &model_file_name) {
GELOGI("Start to build single op offline model.");
GELOGI("Start to build single op offline model, input size: %zu, output size: %zu", inputs.size(), outputs.size());
ModelBufferData model_buff;
OpEngineType engine_type = ENGINE_SYS;
return BuildSingleOp(op_desc, inputs, outputs, model_file_name, engine_type, model_buff, true);
Status status = BuildSingleOp(op_desc, inputs, outputs, model_file_name, engine_type, model_buff, true);
GELOGI("Finish build single offline model, status: %u", status);
return status;
}
/**
@ -772,8 +775,10 @@ Status GeGenerator::BuildSingleOpModel(OpDescPtr &op_desc, const vector<GeTensor
Status GeGenerator::BuildSingleOpModel(OpDescPtr &op_desc, const vector<GeTensor> &inputs,
const vector<GeTensor> &outputs, OpEngineType engine_type,
ModelBufferData &model_buff) {
GELOGI("Start to build single op online");
return BuildSingleOp(op_desc, inputs, outputs, kFileNameSuffix, engine_type, model_buff, false);
GELOGI("Start to build single op online, input size: %zu, output size: %zu", inputs.size(), outputs.size());
Status status = BuildSingleOp(op_desc, inputs, outputs, kFileNameSuffix, engine_type, model_buff, false);
GELOGI("Finish build single online model, status: %u", status);
return status;
}
Status GeGenerator::BuildSingleOpGraph(OpDescPtr &op_desc, const vector<GeTensor> &inputs,
@ -798,8 +803,7 @@ Status GeGenerator::BuildSingleOpGraph(OpDescPtr &op_desc, const vector<GeTensor
}
} else {
for (const auto &in_desc : inputs) {
GeTensorDesc input_desc = in_desc.GetTensorDesc();
GE_CHK_STATUS_RET_NOLOG(AddInputs(compute_graph, op_node, input_desc, arg_index, true));
GE_CHK_STATUS_RET_NOLOG(AddInputs(compute_graph, op_node, in_desc.GetTensorDesc(), arg_index, true));
arg_index++;
}
}

@ -190,7 +190,7 @@ Status SingleOpModel::LoadAllNodes() {
auto node = nodes.at(i);
auto op_desc = node->GetOpDesc();
GE_CHECK_NOTNULL(op_desc);
op_list_[i] = node;
op_list_[op_desc->GetId()] = node;
auto op_type = op_desc->GetType();
GELOGI("[%s] node[%zu] = %s, type = %s", model_name_.c_str(), i, node->GetName().c_str(), op_type.c_str());

@ -18,23 +18,23 @@ project(ut_ge)
set(CMAKE_CXX_STANDARD 11)
set(PROTO_LIST
"${GE_CODE_DIR}/metadef/proto/om.proto"
"${GE_CODE_DIR}/metadef/proto/ge_ir.proto"
"${GE_CODE_DIR}/metadef/proto/ge_api.proto"
"${GE_CODE_DIR}/metadef/proto/insert_op.proto"
"${GE_CODE_DIR}/metadef/proto/dump_task.proto"
"${GE_CODE_DIR}/metadef/proto/fwk_adapter.proto"
"${GE_CODE_DIR}/metadef/proto/op_mapping_info.proto"
"${GE_CODE_DIR}/metadef/proto/optimizer_priority.proto"
"${GE_CODE_DIR}/metadef/proto/ge_api.proto"
"${GE_CODE_DIR}/metadef/proto/tensorflow/attr_value.proto"
"${GE_CODE_DIR}/metadef/proto/tensorflow/tensor.proto"
"${GE_CODE_DIR}/metadef/proto/tensorflow/resource_handle.proto"
"${GE_CODE_DIR}/metadef/proto/tensorflow/tensor_shape.proto"
"${GE_CODE_DIR}/metadef/proto/tensorflow/types.proto"
"${GE_CODE_DIR}/metadef/proto/tensorflow/node_def.proto"
"${GE_CODE_DIR}/metadef/proto/proto_inner/ge_onnx.proto"
)
"${GE_CODE_DIR}/metadef/proto/om.proto"
"${GE_CODE_DIR}/metadef/proto/ge_ir.proto"
"${GE_CODE_DIR}/metadef/proto/ge_api.proto"
"${GE_CODE_DIR}/metadef/proto/insert_op.proto"
"${GE_CODE_DIR}/metadef/proto/dump_task.proto"
"${GE_CODE_DIR}/metadef/proto/fwk_adapter.proto"
"${GE_CODE_DIR}/metadef/proto/op_mapping_info.proto"
"${GE_CODE_DIR}/metadef/proto/optimizer_priority.proto"
"${GE_CODE_DIR}/metadef/proto/ge_api.proto"
"${GE_CODE_DIR}/metadef/proto/tensorflow/attr_value.proto"
"${GE_CODE_DIR}/metadef/proto/tensorflow/tensor.proto"
"${GE_CODE_DIR}/metadef/proto/tensorflow/resource_handle.proto"
"${GE_CODE_DIR}/metadef/proto/tensorflow/tensor_shape.proto"
"${GE_CODE_DIR}/metadef/proto/tensorflow/types.proto"
"${GE_CODE_DIR}/metadef/proto/tensorflow/node_def.proto"
"${GE_CODE_DIR}/metadef/proto/proto_inner/ge_onnx.proto"
)
protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST})
@ -266,8 +266,8 @@ set(COMMON_SRC_FILES
"${GE_CODE_DIR}/ge/graph/passes/hccl_group_pass.cc"
"${GE_CODE_DIR}/ge/graph/passes/memcpy_addr_async_pass.cc"
"${GE_CODE_DIR}/ge/graph/passes/set_input_output_offset_pass.cc"
"${GE_CODE_DIR}/ge/graph/passes/remove_same_const_pass.cc"
"${GE_CODE_DIR}/ge/graph/passes/useless_control_out_remove_pass.cc"
"${GE_CODE_DIR}/ge/graph/passes/remove_same_const_pass.cc"
"${GE_CODE_DIR}/ge/graph/passes/useless_control_out_remove_pass.cc"
"${GE_CODE_DIR}/ge/model/ge_model.cc"
"${GE_CODE_DIR}/ge/common/cust_aicpu_kernel_store.cc"
"${GE_CODE_DIR}/ge/graph/load/model_manager/model_utils.cc"
@ -627,7 +627,7 @@ set(DISTINCT_GRAPH_LOAD_TEST_FILES
#"graph/load/new_model_manager_davinci_model_unittest.cc"
"graph/load/model_manager_unittest.cc"
#"graph/load/new_model_manager_task_build_unittest.cc"
"graph/load/new_model_manager_model_manager_aicpu_unittest.cc"
"graph/load/new_model_manager_model_manager_aicpu_unittest.cc"
"graph/load/end_graph_task_unittest.cc"
"graph/load/new_model_manager_event_manager_unittest.cc"
#"graph/load/output_net_output_unittest.cc"
@ -638,7 +638,7 @@ set(DISTINCT_GRAPH_LOAD_TEST_FILES
"graph/load/kernel_task_info_unittest.cc"
"graph/load/memcpy_addr_async_task_info_unittest.cc"
"graph/load/memcpy_async_task_info_unittest.cc"
"graph/load/cpu_queue_schedule_unittest.cc"
"graph/load/cpu_queue_schedule_unittest.cc"
#"graph/graph_load_unittest.cc"
"graph/ge_executor_unittest.cc"
"graph/load/model_helper_unittest.cc"
@ -671,7 +671,7 @@ set(PASS_TEST_FILES
"graph/passes/trans_op_depth_fusion_pass_unittest.cc"
"graph/passes/transop_nearby_allreduce_fusion_pass_unittest.cc"
"graph/passes/constant_folding_pass_unittest.cc"
"graph/passes/fuse_data_nodes_with_common_input_pass_unittest.cc"
"graph/passes/fuse_data_nodes_with_common_input_pass_unittest.cc"
"graph/passes/stop_gradient_pass_unittest.cc"
"graph/passes/prevent_gradient_pass_unittest.cc"
"graph/passes/identity_pass_unittest.cc"
@ -755,6 +755,10 @@ set(MULTI_PARTS_TEST_FILES
"session/omg_omg_unittest.cc"
)
set(GENERATOR_TEST_FILES
"generator/ge_generator_unittest.cc"
)
set(SINGLE_OP_TEST_FILES
#"single_op/single_op_model_unittest.cc"
"single_op/single_op_manager_unittest.cc"
@ -1055,6 +1059,7 @@ target_link_libraries(ut_libge_kernel_utest
# libge_distinct_load_utest
add_executable(ut_libge_distinct_load_utest
${COMMON_TEST_FILES}
${GENERATOR_TEST_FILES}
${DISTINCT_GRAPH_LOAD_TEST_FILES}
${DISTINCT_GRAPH_LOAD_SRC_FILES}
${SINGLE_OP_TEST_FILES}

@ -0,0 +1,76 @@
/**
* 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 <gtest/gtest.h>
#define private public
#define protected public
#include "generator/ge_generator.h"
#include "graph/utils/tensor_utils.h"
using namespace std;
namespace ge {
class UtestGeGenerator : public testing::Test {
protected:
void SetUp() {}
void TearDown() {}
};
TEST_F(UtestGeGenerator, test_build_single_op_offline) {
GeTensorDesc tensor_desc(GeShape(), FORMAT_NCHW, DT_FLOAT);
TensorUtils::SetSize(tensor_desc, 512);
shared_ptr<OpDesc> op_desc = make_shared<OpDesc>("Add", "add");
EXPECT_EQ(op_desc->AddInputDesc(tensor_desc), GRAPH_SUCCESS);
EXPECT_EQ(op_desc->AddInputDesc(tensor_desc), GRAPH_SUCCESS);
EXPECT_EQ(op_desc->AddOutputDesc(tensor_desc), GRAPH_SUCCESS);
GeTensor tensor(tensor_desc);
const vector<GeTensor> inputs = { tensor, tensor };
const vector<GeTensor> outputs = { tensor };
// not Initialize, impl is null.
GeGenerator generator;
EXPECT_EQ(generator.BuildSingleOpModel(op_desc, inputs, outputs, "offline_"), PARAM_INVALID);
// const map<string, string> &options
generator.Initialize({});
EXPECT_EQ(generator.BuildSingleOpModel(op_desc, inputs, outputs, "offline_"), GE_GENERATOR_GRAPH_MANAGER_BUILD_GRAPH_FAILED);
}
TEST_F(UtestGeGenerator, test_build_single_op_online) {
GeTensorDesc tensor_desc(GeShape(), FORMAT_NCHW, DT_FLOAT);
TensorUtils::SetSize(tensor_desc, 512);
shared_ptr<OpDesc> op_desc = make_shared<OpDesc>("Add", "add");
EXPECT_EQ(op_desc->AddInputDesc(tensor_desc), GRAPH_SUCCESS);
EXPECT_EQ(op_desc->AddInputDesc(tensor_desc), GRAPH_SUCCESS);
EXPECT_EQ(op_desc->AddOutputDesc(tensor_desc), GRAPH_SUCCESS);
GeTensor tensor(tensor_desc);
const vector<GeTensor> inputs = { tensor, tensor };
const vector<GeTensor> outputs = { tensor };
// not Initialize, impl is null.
GeGenerator generator;
generator.Initialize({});
ModelBufferData model_buffer;
EXPECT_EQ(generator.BuildSingleOpModel(op_desc, inputs, outputs, ENGINE_SYS, model_buffer), GE_GENERATOR_GRAPH_MANAGER_BUILD_GRAPH_FAILED);
}
} // namespace ge
Loading…
Cancel
Save