Browse Source

ge ut 3

tags/v1.1.0
t00456437 3 years ago
parent
commit
6339a3ba6c
15 changed files with 247 additions and 47 deletions
  1. +1
    -0
      tests/CMakeLists.txt
  2. +10
    -0
      tests/depends/cce/CMakeLists.txt
  3. +34
    -0
      tests/depends/error_manager/CMakeLists.txt
  4. +85
    -0
      tests/depends/error_manager/src/error_manager_stub.cc
  5. +30
    -0
      tests/depends/mmpa/src/mmpa_stub.cc
  6. +5
    -0
      tests/depends/omg/CMakeLists.txt
  7. +30
    -11
      tests/ut/ge/CMakeLists.txt
  8. +29
    -17
      tests/ut/ge/graph/build/logical_stream_allocator_unittest.cc
  9. +4
    -1
      tests/ut/ge/graph/build/mem_assigner_unittest.cc
  10. +1
    -1
      tests/ut/ge/graph/passes/base_pass_unittest.cc
  11. +4
    -4
      tests/ut/ge/graph/passes/pass_manager_unittest.cc
  12. +5
    -5
      tests/ut/ge/graph/passes/prune_pass_unittest.cc
  13. +0
    -2
      tests/ut/ge/graph/passes/switch_op_pass_unittest.cc
  14. +9
    -5
      tests/ut/ge/graph/passes/unused_and_isolated_op_remove_pass_unittest.cc
  15. +0
    -1
      tests/ut/ge/graph/passes/variable_op_pass_unittest.cc

+ 1
- 0
tests/CMakeLists.txt View File

@@ -22,6 +22,7 @@ add_subdirectory(depends/runtime)
add_subdirectory(depends/omg) add_subdirectory(depends/omg)
add_subdirectory(depends/hccl) add_subdirectory(depends/hccl)
add_subdirectory(depends/profiler) add_subdirectory(depends/profiler)
add_subdirectory(depends/error_manager)


if (ENABLE_GE_COV OR ENABLE_GE_UT) if (ENABLE_GE_COV OR ENABLE_GE_UT)
add_subdirectory(ut) add_subdirectory(ut)


+ 10
- 0
tests/depends/cce/CMakeLists.txt View File

@@ -68,6 +68,11 @@ set(SRCS
"${GE_CODE_DIR}/metadef/graph/opsproto/opsproto_manager.cc" "${GE_CODE_DIR}/metadef/graph/opsproto/opsproto_manager.cc"
) )
add_library(cce_ge_stub SHARED src/cce_stub.cc ${PROTO_SRCS} ${PROTO_HDRS}) add_library(cce_ge_stub SHARED src/cce_stub.cc ${PROTO_SRCS} ${PROTO_HDRS})

target_compile_definitions(cce_ge_stub PRIVATE
google=ascend_private
)

target_link_libraries(cce_ge_stub target_link_libraries(cce_ge_stub
$<BUILD_INTERFACE:intf_pub> $<BUILD_INTERFACE:intf_pub>
-Wl,--no-as-needed -Wl,--no-as-needed
@@ -77,6 +82,11 @@ target_link_libraries(cce_ge_stub
) )


add_library(cce_stub SHARED ${SRCS} ${PROTO_SRCS} ${PROTO_HDRS}) add_library(cce_stub SHARED ${SRCS} ${PROTO_SRCS} ${PROTO_HDRS})

target_compile_definitions(cce_stub PRIVATE
google=ascend_private
)

target_link_libraries(cce_stub PRIVATE target_link_libraries(cce_stub PRIVATE
$<BUILD_INTERFACE:intf_pub> $<BUILD_INTERFACE:intf_pub>
-Wl,--no-as-needed -Wl,--no-as-needed


+ 34
- 0
tests/depends/error_manager/CMakeLists.txt View File

@@ -0,0 +1,34 @@
# 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.
# ============================================================================

#cmake_minimum_required(VERSION 2.8)

project(STUB_ERROR_MANAGER)

file(GLOB_RECURSE SRCS RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"src/error_manager_stub.cc"
)

include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc)
include_directories(${GE_CODE_DIR}/inc)
include_directories(${GE_CODE_DIR}/inc/external)
include_directories(${GE_CODE_DIR}/metadef/inc)
include_directories(${GE_CODE_DIR}/inc/framework)
include_directories(${GE_CODE_DIR}/metadef/inc/external)

add_library(error_manager_stub SHARED ${SRCS})
target_link_libraries(error_manager_stub PRIVATE
$<BUILD_INTERFACE:intf_pub>
)

+ 85
- 0
tests/depends/error_manager/src/error_manager_stub.cc View File

@@ -0,0 +1,85 @@
/**
* 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 "common/util/error_manager/error_manager.h"

ErrorManager &ErrorManager::GetInstance() {
static ErrorManager instance;
return instance;
}

///
/// @brief init
/// @param [in] path: current so path
/// @return int 0(success) -1(fail)
///
int ErrorManager::Init(std::string path) { return 0; }

///
/// @brief Report error message
/// @param [in] error_code: error code
/// @param [in] args_map: parameter map
/// @return int 0(success) -1(fail)
///
int ErrorManager::ReportErrMessage(std::string error_code, const std::map<std::string, std::string> &args_map) {
return 0;
}

///
/// @brief output error message
/// @param [in] handle: print handle
/// @return int 0(success) -1(fail)
///
int ErrorManager::OutputErrMessage(int handle) { return 0; }

///
/// @brief output message
/// @param [in] handle: print handle
/// @return int 0(success) -1(fail)
///
int ErrorManager::OutputMessage(int handle) { return 0; }

///
/// @brief Report error message
/// @param [in] key: vector parameter key
/// @param [in] value: vector parameter value
///
void ErrorManager::ATCReportErrMessage(std::string error_code, const std::vector<std::string> &key,
const std::vector<std::string> &value) {
}

///
/// @brief report graph compile failed message such as error code and op_name in mstune case
/// @param [in] msg: failed message map, key is error code, value is op_name
/// @return int 0(success) -1(fail)
///
int ErrorManager::ReportMstuneCompileFailedMsg(const std::map<std::string, std::string> &msg) { return 0; }

///
/// @brief save graph compile failed message from thread local map to global map
/// @param [in] graph_name: graph name
///
void ErrorManager::SaveMstuneCompileFailedMsg(const std::string &graph_name) {}

///
/// @brief get graph compile failed message in mstune case
/// @param [in] graph_name: graph name
/// @param [out] msg_map: failed message map, key is error code, value is op_name list
/// @return int 0(success) -1(fail)
///
int ErrorManager::GetMstuneCompileFailedMsg(const std::string &graph_name, std::map<std::string, std::vector<std::string>> &msg_map) { return 0; }



+ 30
- 0
tests/depends/mmpa/src/mmpa_stub.cc View File

@@ -217,3 +217,33 @@ INT32 mmScandir(const CHAR *path, mmDirent ***entryList, mmFilter filterFunc, m
VOID mmScandirFree(mmDirent **entryList, INT32 count) VOID mmScandirFree(mmDirent **entryList, INT32 count)
{ {
} }

INT32 mmAccess2(const CHAR *pathName, INT32 mode)
{
return 0;
}

INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone)
{
return 0;
}

INT32 mmRealPath(const CHAR *path, CHAR *realPath, INT32 realPathLen)
{
return 0;
}

INT32 mmGetErrorCode()
{
return 0;
}

INT32 mmIsDir(const CHAR *fileName)
{
return 0;
}

INT32 mmGetEnv(const CHAR *name, CHAR *value, UINT32 len)
{
return 0;
}

+ 5
- 0
tests/depends/omg/CMakeLists.txt View File

@@ -44,6 +44,11 @@ set(SRCS
) )


add_library(omg_stub SHARED ${SRCS} ${PROTO_SRCS} ${PROTO_HDRS}) add_library(omg_stub SHARED ${SRCS} ${PROTO_SRCS} ${PROTO_HDRS})

target_compile_definitions(omg_stub PRIVATE
google=ascend_private
)

target_link_libraries(omg_stub PRIVATE target_link_libraries(omg_stub PRIVATE
$<BUILD_INTERFACE:intf_pub> $<BUILD_INTERFACE:intf_pub>
-Wl,--no-as-needed -Wl,--no-as-needed


+ 30
- 11
tests/ut/ge/CMakeLists.txt View File

@@ -21,6 +21,7 @@ set(PROTO_LIST
"${GE_CODE_DIR}/metadef/proto/om.proto" "${GE_CODE_DIR}/metadef/proto/om.proto"
"${GE_CODE_DIR}/metadef/proto/ge_ir.proto" "${GE_CODE_DIR}/metadef/proto/ge_ir.proto"
"${GE_CODE_DIR}/metadef/proto/ge_api.proto" "${GE_CODE_DIR}/metadef/proto/ge_api.proto"
"${GE_CODE_DIR}/metadef/proto/insert_op.proto"
"${GE_CODE_DIR}/metadef/proto/fwk_adapter.proto" "${GE_CODE_DIR}/metadef/proto/fwk_adapter.proto"
"${GE_CODE_DIR}/metadef/proto/op_mapping_info.proto" "${GE_CODE_DIR}/metadef/proto/op_mapping_info.proto"
"${GE_CODE_DIR}/metadef/proto/optimizer_priority.proto" "${GE_CODE_DIR}/metadef/proto/optimizer_priority.proto"
@@ -42,6 +43,7 @@ include_directories(${GE_CODE_DIR})
include_directories(${GE_CODE_DIR}/inc) include_directories(${GE_CODE_DIR}/inc)
include_directories(${GE_CODE_DIR}/metadef/inc) include_directories(${GE_CODE_DIR}/metadef/inc)
include_directories(${GE_CODE_DIR}/ge) include_directories(${GE_CODE_DIR}/ge)
include_directories(${GE_CODE_DIR}/ge/inc)
include_directories(${GE_CODE_DIR}/metadef) include_directories(${GE_CODE_DIR}/metadef)
include_directories(${GE_CODE_DIR}/metadef/graph) include_directories(${GE_CODE_DIR}/metadef/graph)
include_directories(${GE_CODE_DIR}/inc/external) include_directories(${GE_CODE_DIR}/inc/external)
@@ -86,18 +88,24 @@ set(COMMON_SRC_FILES
"${GE_CODE_DIR}/metadef/graph/buffer.cc" "${GE_CODE_DIR}/metadef/graph/buffer.cc"
"${GE_CODE_DIR}/metadef/graph/compute_graph.cc" "${GE_CODE_DIR}/metadef/graph/compute_graph.cc"
"${GE_CODE_DIR}/metadef/graph/graph.cc" "${GE_CODE_DIR}/metadef/graph/graph.cc"
"${GE_CODE_DIR}/metadef/graph/gnode.cc"
"${GE_CODE_DIR}/metadef/graph/ascend_string.cc"
"${GE_CODE_DIR}/metadef/graph/inference_context.cc" "${GE_CODE_DIR}/metadef/graph/inference_context.cc"
"${GE_CODE_DIR}/metadef/graph/shape_refiner.cc" "${GE_CODE_DIR}/metadef/graph/shape_refiner.cc"
"${GE_CODE_DIR}/metadef/graph/model.cc" "${GE_CODE_DIR}/metadef/graph/model.cc"
"${GE_CODE_DIR}/metadef/graph/model_serialize.cc" "${GE_CODE_DIR}/metadef/graph/model_serialize.cc"
"${GE_CODE_DIR}/metadef/graph/node.cc" "${GE_CODE_DIR}/metadef/graph/node.cc"
"${GE_CODE_DIR}/metadef/graph/runtime_inference_context.cc"
"${GE_CODE_DIR}/metadef/graph/op_desc.cc" "${GE_CODE_DIR}/metadef/graph/op_desc.cc"
"${GE_CODE_DIR}/metadef/third_party/transformer/src/transfer_shape_according_to_format.cpp"
"${GE_CODE_DIR}/metadef/third_party/transformer/src/axis_util.cpp"
"${GE_CODE_DIR}/metadef/graph/operator.cc" "${GE_CODE_DIR}/metadef/graph/operator.cc"
"${GE_CODE_DIR}/metadef/graph/operator_factory.cc" "${GE_CODE_DIR}/metadef/graph/operator_factory.cc"
"${GE_CODE_DIR}/metadef/graph/operator_factory_impl.cc" "${GE_CODE_DIR}/metadef/graph/operator_factory_impl.cc"
#"${GE_CODE_DIR}/metadef/graph/operator_reg.cc" #"${GE_CODE_DIR}/metadef/graph/operator_reg.cc"
#"${GE_CODE_DIR}/metadef/graph/range_vistor.cc" #"${GE_CODE_DIR}/metadef/graph/range_vistor.cc"
"${GE_CODE_DIR}/metadef/graph/ge_tensor.cc" "${GE_CODE_DIR}/metadef/graph/ge_tensor.cc"
"${GE_CODE_DIR}/metadef/graph/ref_relation.cc"
"${GE_CODE_DIR}/metadef/graph/tensor.cc" "${GE_CODE_DIR}/metadef/graph/tensor.cc"
"${GE_CODE_DIR}/metadef/graph/detail/attributes_holder.cc" "${GE_CODE_DIR}/metadef/graph/detail/attributes_holder.cc"
"${GE_CODE_DIR}/metadef/graph/utils/anchor_utils.cc" "${GE_CODE_DIR}/metadef/graph/utils/anchor_utils.cc"
@@ -107,6 +115,7 @@ set(COMMON_SRC_FILES
"${GE_CODE_DIR}/metadef/graph/utils/op_desc_utils.cc" "${GE_CODE_DIR}/metadef/graph/utils/op_desc_utils.cc"
"${GE_CODE_DIR}/metadef/graph/utils/tensor_utils.cc" "${GE_CODE_DIR}/metadef/graph/utils/tensor_utils.cc"
"${GE_CODE_DIR}/metadef/graph/utils/type_utils.cc" "${GE_CODE_DIR}/metadef/graph/utils/type_utils.cc"
"${GE_CODE_DIR}/metadef/graph/utils/transformer_utils.cc"
"${GE_CODE_DIR}/metadef/graph/debug/graph_debug.cc" "${GE_CODE_DIR}/metadef/graph/debug/graph_debug.cc"
"${GE_CODE_DIR}/metadef/graph/opsproto/opsproto_manager.cc" "${GE_CODE_DIR}/metadef/graph/opsproto/opsproto_manager.cc"
"${GE_CODE_DIR}/metadef/ops/op_imp.cpp" "${GE_CODE_DIR}/metadef/ops/op_imp.cpp"
@@ -115,6 +124,7 @@ set(COMMON_SRC_FILES
#"${GE_CODE_DIR}/tests/depends/cce/src/op_kernel_registry.cpp" #"${GE_CODE_DIR}/tests/depends/cce/src/op_kernel_registry.cpp"
"${GE_CODE_DIR}/metadef/register/auto_mapping_util.cpp" "${GE_CODE_DIR}/metadef/register/auto_mapping_util.cpp"
"${GE_CODE_DIR}/metadef/register/tensor_assign.cpp" "${GE_CODE_DIR}/metadef/register/tensor_assign.cpp"
"${GE_CODE_DIR}/metadef/register/register_format_transfer.cc"
"${GE_CODE_DIR}/metadef/graph/format_refiner.cc" "${GE_CODE_DIR}/metadef/graph/format_refiner.cc"
) )


@@ -245,6 +255,7 @@ set(GRAPH_BUILD_COMMON_SRC_FILES
"${GE_CODE_DIR}/ge/common/tbe_kernel_store.cc" "${GE_CODE_DIR}/ge/common/tbe_kernel_store.cc"
"${GE_CODE_DIR}/ge/common/model_parser/base.cc" "${GE_CODE_DIR}/ge/common/model_parser/base.cc"
"${GE_CODE_DIR}/ge/graph/build/run_context.cc" "${GE_CODE_DIR}/ge/graph/build/run_context.cc"
"${GE_CODE_DIR}/ge/graph/common/local_context.cc"
#"${GE_CODE_DIR}/ge/graph/build/optimize_stream_graph.cc" #"${GE_CODE_DIR}/ge/graph/build/optimize_stream_graph.cc"
) )


@@ -509,6 +520,7 @@ list(APPEND COMMON_SHARED_LIBRARIES
profiler_stub profiler_stub
mmpa_stub mmpa_stub
hccl_stub hccl_stub
error_manager_stub
) )
# build common # build common
add_library(ge_ut_common STATIC ${COMMON_SRC_FILES} ${PROTO_SRCS} ${PROTO_HDRS}) add_library(ge_ut_common STATIC ${COMMON_SRC_FILES} ${PROTO_SRCS} ${PROTO_HDRS})
@@ -518,6 +530,7 @@ target_compile_definitions(ge_ut_common PRIVATE
) )


target_link_libraries(ge_ut_common PRIVATE target_link_libraries(ge_ut_common PRIVATE
$<BUILD_INTERFACE:intf_pub>
c_sec c_sec
ascend_protobuf ascend_protobuf
json json
@@ -538,6 +551,7 @@ target_compile_definitions(ge_prepare_common PRIVATE
) )


target_link_libraries(ge_prepare_common PRIVATE target_link_libraries(ge_prepare_common PRIVATE
$<BUILD_INTERFACE:intf_pub>
c_sec c_sec
ascend_protobuf ascend_protobuf
json json
@@ -551,6 +565,7 @@ target_compile_definitions(ge_optimize_common PRIVATE
) )


target_link_libraries(ge_optimize_common PRIVATE target_link_libraries(ge_optimize_common PRIVATE
$<BUILD_INTERFACE:intf_pub>
ascend_protobuf ascend_protobuf
c_sec c_sec
json json
@@ -564,6 +579,7 @@ target_compile_definitions(ge_partition_common PRIVATE
) )


target_link_libraries(ge_partition_common PRIVATE target_link_libraries(ge_partition_common PRIVATE
$<BUILD_INTERFACE:intf_pub>
ascend_protobuf ascend_protobuf
c_sec c_sec
json json
@@ -577,6 +593,7 @@ target_compile_definitions(ge_load_common PRIVATE
) )


target_link_libraries(ge_load_common PRIVATE target_link_libraries(ge_load_common PRIVATE
$<BUILD_INTERFACE:intf_pub>
c_sec c_sec
ascend_protobuf ascend_protobuf
json json
@@ -590,6 +607,7 @@ target_compile_definitions(ge_execute_common PRIVATE
) )


target_link_libraries(ge_execute_common PRIVATE target_link_libraries(ge_execute_common PRIVATE
$<BUILD_INTERFACE:intf_pub>
c_sec c_sec
json json
ascend_protobuf ascend_protobuf
@@ -603,6 +621,7 @@ target_compile_definitions(ge_build_common PRIVATE
) )


target_link_libraries(ge_build_common PRIVATE target_link_libraries(ge_build_common PRIVATE
$<BUILD_INTERFACE:intf_pub>
c_sec c_sec
ascend_protobuf ascend_protobuf
json json
@@ -616,6 +635,7 @@ target_compile_definitions(ge_pass_common PRIVATE
) )


target_link_libraries(ge_pass_common PRIVATE target_link_libraries(ge_pass_common PRIVATE
$<BUILD_INTERFACE:intf_pub>
ascend_protobuf ascend_protobuf
c_sec c_sec
json json
@@ -629,6 +649,7 @@ target_compile_definitions(ge_single_op PRIVATE
) )


target_link_libraries(ge_single_op PRIVATE target_link_libraries(ge_single_op PRIVATE
$<BUILD_INTERFACE:intf_pub>
ascend_protobuf ascend_protobuf
json json
c_sec c_sec
@@ -648,11 +669,9 @@ target_compile_definitions(ut_libge_multiparts_utest PRIVATE
) )


target_link_libraries(ut_libge_multiparts_utest target_link_libraries(ut_libge_multiparts_utest
ge_build_common ge_load_common ge_build_common ge_execute_common ge_optimize_common ge_partition_common ge_pass_common
ge_prepare_common ge_single_op ge_ut_common
gtest gtest_main ascend_protobuf -lrt -ldl
$<BUILD_INTERFACE:intf_pub>
ge_build_common ge_load_common ge_build_common ge_execute_common ge_optimize_common ge_partition_common ge_pass_common ge_prepare_common ge_single_op ge_ut_common gtest gtest_main ascend_protobuf ${COMMON_SHARED_LIBRARIES} json -lrt -ldl
) )
target_link_libraries(ut_libge_multiparts_utest ${COMMON_SHARED_LIBRARIES} ascend_protobuf json)


# libge_others_utest # libge_others_utest
add_executable(ut_libge_others_utest add_executable(ut_libge_others_utest
@@ -663,10 +682,9 @@ add_executable(ut_libge_others_utest
${OTHERS_TEST_FILES} ${OTHERS_TEST_FILES}
) )
target_link_libraries(ut_libge_others_utest target_link_libraries(ut_libge_others_utest
ge_execute_common ge_load_common ge_pass_common ge_ut_common
gtest gtest_main ascend_protobuf -lrt -ldl
$<BUILD_INTERFACE:intf_pub>
ge_execute_common ge_load_common ge_pass_common ge_ut_common gtest gtest_main ascend_protobuf ${COMMON_SHARED_LIBRARIES} -lrt -ldl
) )
target_link_libraries(ut_libge_others_utest ${COMMON_SHARED_LIBRARIES} ascend_protobuf)


# libge_kernel_utest # libge_kernel_utest
add_executable(ut_libge_kernel_utest add_executable(ut_libge_kernel_utest
@@ -676,10 +694,9 @@ add_executable(ut_libge_kernel_utest
${KERNEL_SRC_FILES} ${KERNEL_SRC_FILES}
) )
target_link_libraries(ut_libge_kernel_utest target_link_libraries(ut_libge_kernel_utest
ge_pass_common ge_ut_common ge_load_common
gtest gtest_main ascend_protobuf -lrt -ldl
$<BUILD_INTERFACE:intf_pub>
ge_pass_common ge_ut_common ge_load_common gtest gtest_main ascend_protobuf ${COMMON_SHARED_LIBRARIES} -lrt -ldl
) )
target_link_libraries(ut_libge_kernel_utest ${COMMON_SHARED_LIBRARIES} ascend_protobuf)


# libge_distinct_load_utest # libge_distinct_load_utest
add_executable(ut_libge_distinct_load_utest add_executable(ut_libge_distinct_load_utest
@@ -689,7 +706,9 @@ add_executable(ut_libge_distinct_load_utest
${SINGLE_OP_TEST_FILES} ${SINGLE_OP_TEST_FILES}
${PROFILING_MNG_TEST_FILES} ${PROFILING_MNG_TEST_FILES}
) )
target_link_libraries(ut_libge_distinct_load_utest ${COMMON_SHARED_LIBRARIES}
target_link_libraries(ut_libge_distinct_load_utest
${COMMON_SHARED_LIBRARIES}
$<BUILD_INTERFACE:intf_pub>
ge_execute_common ge_ut_common ge_ut_common_format ge_pass_common ge_load_common ge_execute_common ge_ut_common ge_ut_common_format ge_pass_common ge_load_common
ge_single_op ge_prepare_common ge_single_op ge_prepare_common
ge_optimize_common ge_build_common ge_partition_common ge_optimize_common ge_build_common ge_partition_common


+ 29
- 17
tests/ut/ge/graph/build/logical_stream_allocator_unittest.cc View File

@@ -189,18 +189,20 @@ class UtestLogicalStreamAllocator : public testing::Test {
bool ExpectStreamEq(SubGraphInfoPtr subgraph, int64_t expect) { return GetStream(subgraph) == expect; } bool ExpectStreamEq(SubGraphInfoPtr subgraph, int64_t expect) { return GetStream(subgraph) == expect; }


bool ExpectStreamNe(SubGraphInfoPtr subgraph, int64_t expect) { return GetStream(subgraph) != expect; } bool ExpectStreamNe(SubGraphInfoPtr subgraph, int64_t expect) { return GetStream(subgraph) != expect; }
Status AssignLogicalStreams(vector<SubGraphInfoPtr> subgraphs, vector<EngineConfPtr> &confs,
Status AssignLogicalStreams(Graph2SubGraphInfoList &subgraph_map, vector<EngineConfPtr> &confs,
std::map<std::string, int> &max_parallel_num, ComputeGraphPtr &whole_graph) { std::map<std::string, int> &max_parallel_num, ComputeGraphPtr &whole_graph) {
SchedulerConf scheduler_conf; SchedulerConf scheduler_conf;
if (confs.empty()) { if (confs.empty()) {
for (const auto &subgraph : subgraphs) {
EngineConfPtr conf = make_shared<EngineConf>();
conf->id = subgraph->GetEngineName();
if (conf->id == "ge_local") {
conf->skip_assign_stream = true;
conf->attach = true;
}
scheduler_conf.cal_engines[conf->id] = conf;
for (const auto &subgraph_pair : subgraph_map) {
for (const auto &sub_graph : subgraph_pair.second) {
EngineConfPtr conf = make_shared<EngineConf>();
conf->id = sub_graph->GetEngineName();
if (conf->id == "ge_local") {
conf->skip_assign_stream = true;
conf->attach = true;
}
scheduler_conf.cal_engines[conf->id] = conf;
}
} }
} else { } else {
for (auto &conf : confs) { for (auto &conf : confs) {
@@ -217,11 +219,21 @@ class UtestLogicalStreamAllocator : public testing::Test {
scheduler_confs["scheduler"] = scheduler_conf; scheduler_confs["scheduler"] = scheduler_conf;
LogicalStreamAllocator allocator(scheduler_confs, max_parallel_num); LogicalStreamAllocator allocator(scheduler_confs, max_parallel_num);
int64_t stream_num = 0; int64_t stream_num = 0;
return allocator.Assign(whole_graph, subgraphs, stream_num);
return allocator.Assign(whole_graph, subgraph_map, stream_num);
} }


Status AssignLogicalStreams(vector<SubGraphInfoPtr> subgraphs, std::map<std::string, int> &max_parallel_num,
vector<EngineConfPtr> &confs) {
Status AssignLogicalStreams(vector<SubGraphInfoPtr> subgraphs,
vector<EngineConfPtr> &confs,
std::map<std::string, int> &max_parallel_num,
ComputeGraphPtr &whole_graph) {
Graph2SubGraphInfoList subgraph_map;
subgraph_map[whole_graph] = subgraphs;
return AssignLogicalStreams(subgraph_map, confs, max_parallel_num, whole_graph);
}

Status AssignLogicalStreams(vector<SubGraphInfoPtr> subgraphs,
vector<EngineConfPtr>& confs,
std::map<std::string, int> &max_parallel_num) {
ComputeGraphPtr whole_graph = make_shared<ComputeGraph>("whole_graph"); ComputeGraphPtr whole_graph = make_shared<ComputeGraph>("whole_graph");
return AssignLogicalStreams(subgraphs, confs, max_parallel_num, whole_graph); return AssignLogicalStreams(subgraphs, confs, max_parallel_num, whole_graph);
} }
@@ -229,12 +241,12 @@ class UtestLogicalStreamAllocator : public testing::Test {
Status AssignLogicalStreams(vector<SubGraphInfoPtr> subgraphs, Status AssignLogicalStreams(vector<SubGraphInfoPtr> subgraphs,
vector<EngineConfPtr> confs = vector<EngineConfPtr>()) { vector<EngineConfPtr> confs = vector<EngineConfPtr>()) {
std::map<std::string, int> max_parallel_num; std::map<std::string, int> max_parallel_num;
return AssignLogicalStreams(subgraphs, max_parallel_num, confs);
return AssignLogicalStreams(subgraphs, confs, max_parallel_num);
} }


Status AssignLogicalStreams(vector<SubGraphInfoPtr> subgraphs, std::map<std::string, int> &max_parallel_num) { Status AssignLogicalStreams(vector<SubGraphInfoPtr> subgraphs, std::map<std::string, int> &max_parallel_num) {
vector<EngineConfPtr> confs; vector<EngineConfPtr> confs;
return AssignLogicalStreams(subgraphs, max_parallel_num, confs);
return AssignLogicalStreams(subgraphs, confs, max_parallel_num);
} }


/// typical case /// typical case
@@ -295,7 +307,7 @@ class UtestLogicalStreamAllocator : public testing::Test {


Status status = AssignLogicalStreams({const1, const2, get_next, genmask1, genmask2, domask, subgraph4, subgraph5, Status status = AssignLogicalStreams({const1, const2, get_next, genmask1, genmask2, domask, subgraph4, subgraph5,
subgraph6, allreduce1, allreduce2, apply1, apply2}, subgraph6, allreduce1, allreduce2, apply1, apply2},
max_parallel_num, confs);
confs, max_parallel_num);
EXPECT_EQ(status, ge::SUCCESS); EXPECT_EQ(status, ge::SUCCESS);


EXPECT_EQ(GetStream(get_next), 0); EXPECT_EQ(GetStream(get_next), 0);
@@ -652,7 +664,7 @@ TEST_F(UtestLogicalStreamAllocator, test_independent) {
vector<EngineConfPtr> confs = {conf1, conf2}; vector<EngineConfPtr> confs = {conf1, conf2};


Status status = Status status =
AssignLogicalStreams({subgraph1, subgraph2, subgraph3, subgraph4, subgraph5}, max_parallel_num, confs);
AssignLogicalStreams({subgraph1, subgraph2, subgraph3, subgraph4, subgraph5}, confs, max_parallel_num);
EXPECT_EQ(status, ge::SUCCESS); EXPECT_EQ(status, ge::SUCCESS);
EXPECT_EQ(GetStream(subgraph1), 0); EXPECT_EQ(GetStream(subgraph1), 0);
EXPECT_EQ(GetStream(subgraph2), 0); EXPECT_EQ(GetStream(subgraph2), 0);
@@ -695,7 +707,7 @@ TEST_F(UtestLogicalStreamAllocator, test_independent_switch_label) {
vector<EngineConfPtr> confs = {conf1, conf2, conf3}; vector<EngineConfPtr> confs = {conf1, conf2, conf3};


Status status = Status status =
AssignLogicalStreams({subgraph1, subgraph2, subgraph3, subgraph4, subgraph5}, max_parallel_num, confs);
AssignLogicalStreams({subgraph1, subgraph2, subgraph3, subgraph4, subgraph5},confs, max_parallel_num);
EXPECT_EQ(status, ge::SUCCESS); EXPECT_EQ(status, ge::SUCCESS);
EXPECT_EQ(GetStream(subgraph1), 4); EXPECT_EQ(GetStream(subgraph1), 4);
EXPECT_EQ(GetStream(subgraph2), 0); EXPECT_EQ(GetStream(subgraph2), 0);


+ 4
- 1
tests/ut/ge/graph/build/mem_assigner_unittest.cc View File

@@ -177,7 +177,10 @@ class MockBlockMemAssigner : public BlockMemAssigner {
TEST_F(UtestMemoryAssignerTest, Mock_block_mem_assigner_failed) { TEST_F(UtestMemoryAssignerTest, Mock_block_mem_assigner_failed) {
ge::ComputeGraphPtr graph = make_shared<ge::ComputeGraph>(""); ge::ComputeGraphPtr graph = make_shared<ge::ComputeGraph>("");
make_graph(graph); make_graph(graph);
MockBlockMemAssigner mock_assigner(graph);
std::map<std::string, std::string> anchor_to_symbol;
std::map<std::string, std::list<NodeIndexIO>> symbol_to_anchors;
EXPECT_EQ(GraphUtils::GetRefMapping(graph, symbol_to_anchors, anchor_to_symbol), GRAPH_SUCCESS);


MockBlockMemAssigner mock_assigner(graph, anchor_to_symbol, symbol_to_anchors);
EXPECT_EQ(mock_assigner.Assign(), FAILED); EXPECT_EQ(mock_assigner.Assign(), FAILED);
} }

+ 1
- 1
tests/ut/ge/graph/passes/base_pass_unittest.cc View File

@@ -49,7 +49,7 @@ class UtestTestPass : public BaseNodePass {
for (const auto &node_name : iter->second) { for (const auto &node_name : iter->second) {
auto del_node = node->GetOwnerComputeGraph()->FindNode(node_name); auto del_node = node->GetOwnerComputeGraph()->FindNode(node_name);
GraphUtils::IsolateNode(del_node, {0}); GraphUtils::IsolateNode(del_node, {0});
AddNodeDeleted(del_node.get());
AddNodeDeleted(del_node);
} }
} }
iter = names_to_add_repass_.find(node->GetName()); iter = names_to_add_repass_.find(node->GetName());


+ 4
- 4
tests/ut/ge/graph/passes/pass_manager_unittest.cc View File

@@ -72,7 +72,7 @@ ComputeGraphPtr CreatePadGraph() {


TEST_F(UtestGraphPassesPassManagerPass, all_pass_success) { TEST_F(UtestGraphPassesPassManagerPass, all_pass_success) {
PassManager manager; PassManager manager;
manager.AddPass(new SuccessGraphPass);
manager.AddPass("", new SuccessGraphPass);
EXPECT_EQ(manager.GraphPasses().size(), 1); EXPECT_EQ(manager.GraphPasses().size(), 1);


ComputeGraphPtr graph = CreatePadGraph(); ComputeGraphPtr graph = CreatePadGraph();
@@ -83,7 +83,7 @@ TEST_F(UtestGraphPassesPassManagerPass, all_pass_success) {
TEST_F(UtestGraphPassesPassManagerPass, graph_pass_success) { TEST_F(UtestGraphPassesPassManagerPass, graph_pass_success) {
ComputeGraphPtr graph = CreatePadGraph(); ComputeGraphPtr graph = CreatePadGraph();
SuccessGraphPass pass; SuccessGraphPass pass;
vector<GraphPass *> passes = {&pass};
std::vector<std::pair<string, GraphPass*>> passes;
Status status = PassManager::Run(graph, passes); Status status = PassManager::Run(graph, passes);
EXPECT_EQ(SUCCESS, status); EXPECT_EQ(SUCCESS, status);
} }
@@ -91,7 +91,7 @@ TEST_F(UtestGraphPassesPassManagerPass, graph_pass_success) {
TEST_F(UtestGraphPassesPassManagerPass, graph_pass_not_changed) { TEST_F(UtestGraphPassesPassManagerPass, graph_pass_not_changed) {
ComputeGraphPtr graph = CreatePadGraph(); ComputeGraphPtr graph = CreatePadGraph();
NotChangedGraphPass pass; NotChangedGraphPass pass;
vector<GraphPass *> passes = {&pass};
std::vector<std::pair<string, GraphPass*>> passes;
Status status = PassManager::Run(graph, passes); Status status = PassManager::Run(graph, passes);
EXPECT_EQ(NOT_CHANGED, status); EXPECT_EQ(NOT_CHANGED, status);
} }
@@ -99,7 +99,7 @@ TEST_F(UtestGraphPassesPassManagerPass, graph_pass_not_changed) {
TEST_F(UtestGraphPassesPassManagerPass, graph_pass_error) { TEST_F(UtestGraphPassesPassManagerPass, graph_pass_error) {
ComputeGraphPtr graph = CreatePadGraph(); ComputeGraphPtr graph = CreatePadGraph();
ErrorGraphPass pass; ErrorGraphPass pass;
vector<GraphPass *> passes = {&pass};
std::vector<std::pair<string, GraphPass*>> passes;
Status status = PassManager::Run(graph, passes); Status status = PassManager::Run(graph, passes);
EXPECT_EQ(FAILED, status); EXPECT_EQ(FAILED, status);
} }

+ 5
- 5
tests/ut/ge/graph/passes/prune_pass_unittest.cc View File

@@ -67,7 +67,7 @@ TEST_F(UtestGraphPassesPrunePass, no_net_out_put_node) {


uint64_t size_ori = graph->GetDirectNode().size(); uint64_t size_ori = graph->GetDirectNode().size();
PrunePass prune_pass; PrunePass prune_pass;
vector<GraphPass *> passes = {&prune_pass};
std::vector<std::pair<string, GraphPass*>> passes = { {"prune_pass", &prune_pass} };
Status status = PassManager::Run(graph, passes); Status status = PassManager::Run(graph, passes);


EXPECT_EQ(ge::SUCCESS, status); EXPECT_EQ(ge::SUCCESS, status);
@@ -109,7 +109,7 @@ TEST_F(UtestGraphPassesPrunePass, has_net_out_put_node_with_only_one_path) {


uint64_t size_ori = graph->GetDirectNode().size(); uint64_t size_ori = graph->GetDirectNode().size();
PrunePass prune_pass; PrunePass prune_pass;
vector<GraphPass *> passes = {&prune_pass};
std::vector<std::pair<string, GraphPass*>> passes = { {"prune_pass", &prune_pass} };
Status status = PassManager::Run(graph, passes); Status status = PassManager::Run(graph, passes);


uint64_t size = graph->GetDirectNode().size(); uint64_t size = graph->GetDirectNode().size();
@@ -250,7 +250,7 @@ TEST_F(UtestGraphPassesPrunePass, has_net_out_put_node_with_multi_path) {
uint64_t size_ori = graph->GetDirectNode().size(); uint64_t size_ori = graph->GetDirectNode().size();


PrunePass prune_pass; PrunePass prune_pass;
vector<GraphPass *> passes = {&prune_pass};
std::vector<std::pair<string, GraphPass*>> passes = { {"prune_pass", &prune_pass} };
Status status = PassManager::Run(graph, passes); Status status = PassManager::Run(graph, passes);


uint64_t size_after_proc = graph->GetDirectNode().size(); uint64_t size_after_proc = graph->GetDirectNode().size();
@@ -323,7 +323,7 @@ TEST_F(UtestGraphPassesPrunePass, multi_net_out_put_node_with_circle_net) {
uint64_t size_ori = graph->GetDirectNode().size(); uint64_t size_ori = graph->GetDirectNode().size();


PrunePass prune_pass; PrunePass prune_pass;
vector<GraphPass *> passes = {&prune_pass};
std::vector<std::pair<string, GraphPass*>> passes = { {"prune_pass", &prune_pass} };
Status status = PassManager::Run(graph, passes); Status status = PassManager::Run(graph, passes);
EXPECT_EQ(ge::SUCCESS, status); EXPECT_EQ(ge::SUCCESS, status);
uint64_t size_after_proc = graph->GetDirectNode().size(); uint64_t size_after_proc = graph->GetDirectNode().size();
@@ -464,7 +464,7 @@ TEST_F(UtestGraphPassesPrunePass, has_net_out_put_node_with_two_isolate_data_nod


uint64_t size_ori = graph->GetDirectNode().size(); uint64_t size_ori = graph->GetDirectNode().size();
PrunePass prune_pass; PrunePass prune_pass;
vector<GraphPass *> passes = {&prune_pass};
std::vector<std::pair<string, GraphPass*>> passes = { {"prune_pass", &prune_pass} };
Status status = PassManager::Run(graph, passes); Status status = PassManager::Run(graph, passes);


uint64_t size = graph->GetDirectNode().size(); uint64_t size = graph->GetDirectNode().size();


+ 0
- 2
tests/ut/ge/graph/passes/switch_op_pass_unittest.cc View File

@@ -19,7 +19,6 @@
#include "omg/omg_inner_types.h" #include "omg/omg_inner_types.h"
#define protected public #define protected public
#define private public #define private public
#include "graph/passes/switch_op_pass.h"


#include "common/debug/log.h" #include "common/debug/log.h"
#include "common/debug/memory_dumper.h" #include "common/debug/memory_dumper.h"
@@ -27,7 +26,6 @@
#include "common/types.h" #include "common/types.h"
#include "graph/debug/ge_attr_define.h" #include "graph/debug/ge_attr_define.h"
#include "graph/graph.h" #include "graph/graph.h"
#include "graph/passes/control_op_attr_pass.h"
#include "inc/pass_manager.h" #include "inc/pass_manager.h"
#undef protected #undef protected
#undef private #undef private


+ 9
- 5
tests/ut/ge/graph/passes/unused_and_isolated_op_remove_pass_unittest.cc View File

@@ -54,9 +54,11 @@ TEST_F(UtestGraphPassesUnusedAndIsolatedOpRemovePass, transpose_and_reshape) {
GraphUtils::AddEdge(data_node->GetOutDataAnchor(0), transpose_node->GetInDataAnchor(0)); GraphUtils::AddEdge(data_node->GetOutDataAnchor(0), transpose_node->GetInDataAnchor(0));
GraphUtils::AddEdge(transpose_node->GetOutDataAnchor(0), reshape_node->GetInDataAnchor(0)); GraphUtils::AddEdge(transpose_node->GetOutDataAnchor(0), reshape_node->GetInDataAnchor(0));


ge::UnusedOpRemovePass unused_pass(FMK_TYPE_T);
ge::UnusedOpRemovePass unused_pass(TENSORFLOW);
ge::IsolatedOpRemovePass isolate_pass; ge::IsolatedOpRemovePass isolate_pass;
vector<GraphPass *> passes = {&unused_pass, &isolate_pass};
std::vector<std::pair<string, GraphPass*>> passes;
passes.emplace_back("", &isolate_pass);
passes.emplace_back("", &unused_pass);
Status status = PassManager::Run(graph, passes); Status status = PassManager::Run(graph, passes);
EXPECT_EQ(SUCCESS, status); EXPECT_EQ(SUCCESS, status);
NodePtr found_node = graph->FindNode("transpose1"); NodePtr found_node = graph->FindNode("transpose1");
@@ -73,9 +75,11 @@ TEST_F(UtestGraphPassesUnusedAndIsolatedOpRemovePass, transpose_and_squeeze) {
GraphUtils::AddEdge(data_node->GetOutDataAnchor(0), transpose_node->GetInDataAnchor(0)); GraphUtils::AddEdge(data_node->GetOutDataAnchor(0), transpose_node->GetInDataAnchor(0));
GraphUtils::AddEdge(transpose_node->GetOutDataAnchor(0), squeeze_node->GetInDataAnchor(0)); GraphUtils::AddEdge(transpose_node->GetOutDataAnchor(0), squeeze_node->GetInDataAnchor(0));


ge::UnusedOpRemovePass unused_pass(FMK_TYPE_T);
ge::UnusedOpRemovePass unused_pass(TENSORFLOW);
ge::IsolatedOpRemovePass isolate_pass; ge::IsolatedOpRemovePass isolate_pass;
vector<GraphPass *> passes = {&unused_pass, &isolate_pass};
std::vector<std::pair<string, GraphPass*>> passes;
passes.emplace_back("", &isolate_pass);
passes.emplace_back("", &unused_pass);
Status status = PassManager::Run(graph, passes); Status status = PassManager::Run(graph, passes);
EXPECT_EQ(SUCCESS, status); EXPECT_EQ(SUCCESS, status);
NodePtr found_node = graph->FindNode("transpose1"); NodePtr found_node = graph->FindNode("transpose1");
@@ -100,7 +104,7 @@ TEST_F(UtestGraphPassesUnusedAndIsolatedOpRemovePass, transpose_and_conv) {
NodePtr conv2_node = AddNode(graph, "conv2", CONVOLUTION); NodePtr conv2_node = AddNode(graph, "conv2", CONVOLUTION);
GraphUtils::AddEdge(conv_node->GetOutDataAnchor(0), conv2_node->GetInDataAnchor(0)); GraphUtils::AddEdge(conv_node->GetOutDataAnchor(0), conv2_node->GetInDataAnchor(0));


ge::UnusedOpRemovePass unused_pass(FMK_TYPE_T);
ge::UnusedOpRemovePass unused_pass(TENSORFLOW);
ge::IsolatedOpRemovePass isolate_pass; ge::IsolatedOpRemovePass isolate_pass;
vector<GraphPass *> passes = {&unused_pass, &isolate_pass}; vector<GraphPass *> passes = {&unused_pass, &isolate_pass};
Status status = PassManager::Run(graph, passes); Status status = PassManager::Run(graph, passes);


+ 0
- 1
tests/ut/ge/graph/passes/variable_op_pass_unittest.cc View File

@@ -39,7 +39,6 @@
#include "graph/manager/graph_var_manager.h" #include "graph/manager/graph_var_manager.h"
#include "graph_builder_utils.h" #include "graph_builder_utils.h"
#include "cce/dnn_struct_base.hpp" #include "cce/dnn_struct_base.hpp"
#include "common/formats/format_transfers/format_transfer.h"
#include "common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h" #include "common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h"
#include "common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h" #include "common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h"
#include "common/formats/format_transfers/datatype_transfer.h" #include "common/formats/format_transfers/datatype_transfer.h"


Loading…
Cancel
Save