@@ -53,6 +53,7 @@ string PluginManager::GetPath() { | |||||
GELOGW("Failed to read the shared library file path!"); | GELOGW("Failed to read the shared library file path!"); | ||||
return string(); | return string(); | ||||
} else { | } else { | ||||
GE_IF_BOOL_EXEC(dl_info.dli_fname == nullptr, return string()); | |||||
std::string so_path = dl_info.dli_fname; | std::string so_path = dl_info.dli_fname; | ||||
char path[MMPA_MAX_PATH] = {0}; | char path[MMPA_MAX_PATH] = {0}; | ||||
if (so_path.length() >= MMPA_MAX_PATH) { | if (so_path.length() >= MMPA_MAX_PATH) { | ||||
@@ -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, | 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, | const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, | ||||
bool is_offline) { | bool is_offline) { | ||||
GE_CHECK_NOTNULL_EXEC(impl_, return PARAM_INVALID); | |||||
impl_->is_offline_ = is_offline; | |||||
if (!is_offline) { | if (!is_offline) { | ||||
(void)AttrUtils::SetBool(op_desc, ATTR_SINGLE_OP_SCENE, true); | (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."); | GELOGI("ATC parser success in single op build."); | ||||
GeRootModelPtr ge_root_model = nullptr; | 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)); | GE_CHK_STATUS_RET_NOLOG(impl_->BuildModel(graph, inputs, ge_root_model)); | ||||
map<string, GeAttrValue> op_attrs = op_desc_tmp->GetAllAttrs(); | map<string, GeAttrValue> op_attrs = op_desc_tmp->GetAllAttrs(); | ||||
GE_CHECK_NOTNULL(ge_root_model); | GE_CHECK_NOTNULL(ge_root_model); | ||||
@@ -758,7 +758,7 @@ Status GeGenerator::BuildSingleOpModel(OpDescPtr &op_desc, const vector<GeTensor | |||||
ModelBufferData model_buff; | ModelBufferData model_buff; | ||||
OpEngineType engine_type = ENGINE_SYS; | OpEngineType engine_type = ENGINE_SYS; | ||||
Status status = 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"); | |||||
GELOGI("Finish build single offline model, status: %u", status); | |||||
return status; | return status; | ||||
} | } | ||||
@@ -777,7 +777,7 @@ Status GeGenerator::BuildSingleOpModel(OpDescPtr &op_desc, const vector<GeTensor | |||||
ModelBufferData &model_buff) { | ModelBufferData &model_buff) { | ||||
GELOGI("Start to build single op online, input size: %zu, output size: %zu", inputs.size(), outputs.size()); | 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); | Status status = BuildSingleOp(op_desc, inputs, outputs, kFileNameSuffix, engine_type, model_buff, false); | ||||
GELOGI("Finish build single online model"); | |||||
GELOGI("Finish build single online model, status: %u", status); | |||||
return status; | return status; | ||||
} | } | ||||
@@ -18,23 +18,23 @@ project(ut_ge) | |||||
set(CMAKE_CXX_STANDARD 11) | set(CMAKE_CXX_STANDARD 11) | ||||
set(PROTO_LIST | 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}) | 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/hccl_group_pass.cc" | ||||
"${GE_CODE_DIR}/ge/graph/passes/memcpy_addr_async_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/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/model/ge_model.cc" | ||||
"${GE_CODE_DIR}/ge/common/cust_aicpu_kernel_store.cc" | "${GE_CODE_DIR}/ge/common/cust_aicpu_kernel_store.cc" | ||||
"${GE_CODE_DIR}/ge/graph/load/model_manager/model_utils.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/new_model_manager_davinci_model_unittest.cc" | ||||
"graph/load/model_manager_unittest.cc" | "graph/load/model_manager_unittest.cc" | ||||
#"graph/load/new_model_manager_task_build_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/end_graph_task_unittest.cc" | ||||
"graph/load/new_model_manager_event_manager_unittest.cc" | "graph/load/new_model_manager_event_manager_unittest.cc" | ||||
#"graph/load/output_net_output_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/kernel_task_info_unittest.cc" | ||||
"graph/load/memcpy_addr_async_task_info_unittest.cc" | "graph/load/memcpy_addr_async_task_info_unittest.cc" | ||||
"graph/load/memcpy_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/graph_load_unittest.cc" | ||||
"graph/ge_executor_unittest.cc" | "graph/ge_executor_unittest.cc" | ||||
"graph/load/model_helper_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/trans_op_depth_fusion_pass_unittest.cc" | ||||
"graph/passes/transop_nearby_allreduce_fusion_pass_unittest.cc" | "graph/passes/transop_nearby_allreduce_fusion_pass_unittest.cc" | ||||
"graph/passes/constant_folding_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/stop_gradient_pass_unittest.cc" | ||||
"graph/passes/prevent_gradient_pass_unittest.cc" | "graph/passes/prevent_gradient_pass_unittest.cc" | ||||
"graph/passes/identity_pass_unittest.cc" | "graph/passes/identity_pass_unittest.cc" | ||||
@@ -755,6 +755,10 @@ set(MULTI_PARTS_TEST_FILES | |||||
"session/omg_omg_unittest.cc" | "session/omg_omg_unittest.cc" | ||||
) | ) | ||||
set(GENERATOR_TEST_FILES | |||||
"generator/ge_generator_unittest.cc" | |||||
) | |||||
set(SINGLE_OP_TEST_FILES | set(SINGLE_OP_TEST_FILES | ||||
#"single_op/single_op_model_unittest.cc" | #"single_op/single_op_model_unittest.cc" | ||||
"single_op/single_op_manager_unittest.cc" | "single_op/single_op_manager_unittest.cc" | ||||
@@ -1055,6 +1059,7 @@ target_link_libraries(ut_libge_kernel_utest | |||||
# libge_distinct_load_utest | # libge_distinct_load_utest | ||||
add_executable(ut_libge_distinct_load_utest | add_executable(ut_libge_distinct_load_utest | ||||
${COMMON_TEST_FILES} | ${COMMON_TEST_FILES} | ||||
${GENERATOR_TEST_FILES} | |||||
${DISTINCT_GRAPH_LOAD_TEST_FILES} | ${DISTINCT_GRAPH_LOAD_TEST_FILES} | ||||
${DISTINCT_GRAPH_LOAD_SRC_FILES} | ${DISTINCT_GRAPH_LOAD_SRC_FILES} | ||||
${SINGLE_OP_TEST_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 |