Merge pull request !719 from zhangfan/ge_devpull/572/head
@@ -1,6 +1,21 @@ | |||
cmake_minimum_required(VERSION 3.14) | |||
project (Parser[CXX]) | |||
include(CMakePrintHelpers) | |||
message(STATUS "Variables in parser project :") | |||
cmake_print_variables(ASCEND_OPENSDK_DIR) | |||
cmake_print_variables(CMAKE_BUILD_TYPE) | |||
cmake_print_variables(CMAKE_INSTALL_PREFIX) | |||
cmake_print_variables(CMAKE_PREFIX_PATH) | |||
cmake_print_variables(CMAKE_MODULE_PATH) | |||
cmake_print_variables(protoc_ROOT) | |||
cmake_print_variables(protobuf_grpc_ROOT) | |||
cmake_print_variables(protobuf_static_ROOT) | |||
cmake_print_variables(ascend_protobuf_shared_ROOT) | |||
cmake_print_variables(ascend_protobuf_static_ROOT) | |||
cmake_print_variables(ENABLE_OPEN_SRC ENABLE_GITEE ENABLE_PARSER_UT ENABLE_PARSER_ST ENABLE_PARSER_COV) | |||
cmake_print_variables(BUILD_WITHOUT_AIR BUILD_METADEF METADEF_DIR) | |||
set(INSTALL_BASE_DIR "") | |||
set(INSTALL_LIBRARY_DIR lib) | |||
set(INSTALL_RUNTIME_DIR bin) | |||
@@ -9,68 +24,51 @@ set(INSTALL_CONFIG_DIR cmake) | |||
include(CMakePackageConfigHelpers) | |||
set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}) | |||
if (DEFINED ENV{D_PKG_SERVER}) | |||
set(PARSER_PB_PKG $ENV{D_PKG_SERVER}) | |||
elseif (DEFINED ENV{MSLIBS_SERVER}) | |||
set(PARSER_PB_PKG "http://$ENV{MSLIBS_SERVER}:8081") | |||
message("Download packages from MSPKG server") | |||
endif () | |||
option(ENABLE_OPEN_SRC "Enable graphengine compile in opensource." FALSE) | |||
if (ENABLE_OPEN_SRC) | |||
set(HI_PYTHON python3) | |||
include(cmake/external_libs/protobuf_shared.cmake) | |||
include(cmake/external_libs/protoc.cmake) | |||
include(cmake/external_libs/securec.cmake) | |||
include(cmake/external_libs/json.cmake) | |||
include(cmake/FindModule.cmake) | |||
include(cmake/intf_pub_linux.cmake) | |||
# 开源软件包 | |||
find_package(json MODULE) | |||
find_package(protoc MODULE) | |||
find_package(ascend_protobuf_shared MODULE) | |||
find_package(ascend_protobuf_static MODULE) | |||
find_package(GTest CONFIG REQUIRED) | |||
# 自研软件包 | |||
find_package(securec MODULE REQUIRED) | |||
find_package(slog CONFIG REQUIRED) | |||
find_package(mmpa CONFIG REQUIRED) | |||
find_package(runtime CONFIG REQUIRED) | |||
find_package(msprof CONFIG REQUIRED) | |||
find_package(cce CONFIG REQUIRED) | |||
if (BUILD_WITHOUT_AIR) | |||
find_package(air CONFIG REQUIRED) | |||
endif() | |||
if (NOT BUILD_METADEF) | |||
find_package(metadef CONFIG REQUIRED) | |||
endif() | |||
if(DEFINED ENV{D_LINK_PATH}) | |||
# D_LINK_PATH is set | |||
set(GE_LIB_PATH $ENV{D_LINK_PATH}) | |||
set(GE_SYS_ARCH "") | |||
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64") | |||
# x86 ubuntu | |||
set(GE_SYS_ARCH "x86_64") | |||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64") | |||
# arm euleros | |||
set(GE_SYS_ARCH "aarch64") | |||
else() | |||
message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated") | |||
if (BUILD_METADEF) | |||
# 使用medadef源码编译 | |||
if (BUILD_WITHOUT_AIR) | |||
# parser集成metadef源码 | |||
set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) | |||
else () | |||
# air已经集成metadef源码,parser直接使用 | |||
message(STATUS "METADEF_DIR = ${METADEF_DIR}") | |||
endif() | |||
set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) | |||
find_module(slog libascendalog.so ${GE_LIB_PATH}) | |||
find_module(static_mmpa libmmpa.a ${GE_LIB_PATH}) | |||
elseif(ENABLE_GE_COV OR ENABLE_GE_UT) | |||
message(STATUS "Runing on llt mode, no need to depend other component") | |||
elseif(ENABLE_PARSER_UT OR ENABLE_PARSER_COV OR ENABLE_PARSER_ST) | |||
include(cmake/external_libs/gtest.cmake) | |||
add_subdirectory(tests) | |||
else() | |||
if(DEFINED ENV{ASCEND_CUSTOM_PATH}) | |||
set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) | |||
else() | |||
set(ASCEND_DIR /usr/local/Ascend) | |||
endif() | |||
set(ASCEND_COMPILER_DIR ${ASCEND_DIR}/compiler/lib64) | |||
find_module(slog libascendalog.so ${ASCEND_COMPILER_DIR}) | |||
find_module(static_mmpa libmmpa.a ${ASCEND_COMPILER_DIR}) | |||
else () | |||
# 使用medadef发布包编译 | |||
set(METADEF_DIR ${ASCEND_OPENSDK_DIR}) | |||
endif() | |||
if (NOT DEFINED METADEF_DIR) | |||
set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) | |||
add_subdirectory(metadef) | |||
endif() | |||
include(cmake/intf_pub_linux.cmake) | |||
include(cmake/function.cmake) | |||
else() | |||
####工程tigong | |||
set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/../metadef) | |||
# 使用全量源码构建框架集成的metadef源码 | |||
set(METADEF_DIR ${TOP_DIR}/metadef) | |||
endif() | |||
set(PARSER_PROTO_LIST | |||
@@ -131,16 +129,10 @@ set(PARSER_CAFFE_PROTO_SRC | |||
add_library(parser_graph_library_proto_obj OBJECT ${PARSER_GRAPH_LIBRARY_PROTO_SRC}) | |||
add_dependencies(parser_graph_library_proto_obj parser_protos) | |||
target_include_directories(parser_graph_library_proto_obj PRIVATE | |||
#### blue zone #### | |||
${PROTOBUF_SHARED_PKG_DIR}/include | |||
#### yellow zone #### | |||
${ASCEND_PROTOBUF_SHARED_PKG_DIR}/include | |||
) | |||
target_compile_definitions(parser_graph_library_proto_obj PRIVATE | |||
google=ascend_private | |||
) | |||
target_link_libraries(parser_graph_library_proto_obj PRIVATE ascend_protobuf $<BUILD_INTERFACE:intf_pub>) | |||
target_link_libraries(parser_graph_library_proto_obj PRIVATE ascend_protobuf intf_pub) | |||
target_compile_options(parser_graph_library_proto_obj PRIVATE | |||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC -Wextra -Wfloat-equal> | |||
$<$<OR:$<STREQUAL:${PRODUCT_SIDE},host>,$<STREQUAL:${ENABLE_OPEN_SRC},True>>:-fexceptions> | |||
@@ -152,16 +144,10 @@ target_compile_options(parser_graph_library_proto_obj PRIVATE | |||
add_library(parser_tensorflow_protos_obj OBJECT ${PARSER_TENSORFLOW_PROTO_SRCS}) | |||
add_dependencies(parser_tensorflow_protos_obj parser_protos) | |||
target_include_directories(parser_tensorflow_protos_obj PRIVATE | |||
#### blue zone #### | |||
${PROTOBUF_SHARED_PKG_DIR}/include | |||
#### yellow zone #### | |||
${ASCEND_PROTOBUF_SHARED_PKG_DIR}/include | |||
) | |||
target_compile_definitions(parser_tensorflow_protos_obj PRIVATE | |||
google=ascend_private | |||
) | |||
target_link_libraries(parser_tensorflow_protos_obj PRIVATE ascend_protobuf $<BUILD_INTERFACE:intf_pub>) | |||
target_link_libraries(parser_tensorflow_protos_obj PRIVATE ascend_protobuf intf_pub) | |||
target_compile_options(parser_tensorflow_protos_obj PRIVATE | |||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC -Wextra -Wfloat-equal> | |||
$<$<OR:$<STREQUAL:${PRODUCT_SIDE},host>,$<STREQUAL:${ENABLE_OPEN_SRC},True>>:-fexceptions> | |||
@@ -173,16 +159,10 @@ target_compile_options(parser_tensorflow_protos_obj PRIVATE | |||
add_library(parser_onnx_protos_obj OBJECT ${PARSER_ONNX_PROTO_SRCS}) | |||
add_dependencies(parser_onnx_protos_obj parser_protos) | |||
target_include_directories(parser_onnx_protos_obj PRIVATE | |||
#### blue zone #### | |||
${PROTOBUF_SHARED_PKG_DIR}/include | |||
#### yellow zone #### | |||
${ASCEND_PROTOBUF_SHARED_PKG_DIR}/include | |||
) | |||
target_compile_definitions(parser_onnx_protos_obj PRIVATE | |||
google=ascend_private | |||
) | |||
target_link_libraries(parser_onnx_protos_obj PRIVATE ascend_protobuf $<BUILD_INTERFACE:intf_pub>) | |||
target_link_libraries(parser_onnx_protos_obj PRIVATE ascend_protobuf intf_pub) | |||
target_compile_options(parser_onnx_protos_obj PRIVATE | |||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC -Wextra -Wfloat-equal> | |||
$<$<OR:$<STREQUAL:${PRODUCT_SIDE},host>,$<STREQUAL:${ENABLE_OPEN_SRC},True>>:-fexceptions> | |||
@@ -194,16 +174,10 @@ target_compile_options(parser_onnx_protos_obj PRIVATE | |||
add_library(parser_caffe_proto_obj OBJECT ${PARSER_CAFFE_PROTO_SRC}) | |||
add_dependencies(parser_caffe_proto_obj parser_protos) | |||
target_include_directories(parser_caffe_proto_obj PRIVATE | |||
#### blue zone #### | |||
${PROTOBUF_SHARED_PKG_DIR}/include | |||
#### yellow zone #### | |||
${ASCEND_PROTOBUF_SHARED_PKG_DIR}/include | |||
) | |||
target_compile_definitions(parser_caffe_proto_obj PRIVATE | |||
google=ascend_private | |||
) | |||
target_link_libraries(parser_caffe_proto_obj PRIVATE ascend_protobuf $<BUILD_INTERFACE:intf_pub>) | |||
target_link_libraries(parser_caffe_proto_obj PRIVATE ascend_protobuf intf_pub) | |||
target_compile_options(parser_caffe_proto_obj PRIVATE | |||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC -Wextra -Wfloat-equal> | |||
$<$<OR:$<STREQUAL:${PRODUCT_SIDE},host>,$<STREQUAL:${ENABLE_OPEN_SRC},True>>:-fexceptions> | |||
@@ -243,6 +217,12 @@ add_subdirectory(parser) | |||
add_subdirectory(parser/common) | |||
add_subdirectory(parser/func_to_graph) | |||
add_subdirectory(parser/onnx) | |||
if (BUILD_METADEF AND BUILD_WITHOUT_AIR) | |||
add_subdirectory(metadef) | |||
endif() | |||
if(ENABLE_PARSER_UT OR ENABLE_PARSER_COV OR ENABLE_PARSER_ST) | |||
add_subdirectory(tests) | |||
endif() | |||
install(TARGETS _caffe_parser parser_common fmk_onnx_parser fmk_parser parser_headers | |||
EXPORT parser-targets | |||
@@ -255,7 +235,16 @@ install(FILES ${PARSER_DIR}/inc/external/parser/onnx_parser.h | |||
${PARSER_DIR}/inc/external/parser/tensorflow_parser.h | |||
DESTINATION ${INSTALL_INCLUDE_DIR}/parser/external/parser COMPONENT opensdk EXCLUDE_FROM_ALL | |||
) | |||
# 下列头文件发布是非法的,需要在后续整改中删掉 | |||
# --------------------start------------------------ | |||
install(FILES ${PARSER_DIR}/parser/common/pre_checker.h | |||
${PARSER_DIR}/parser/common/register_tbe.h | |||
DESTINATION ${INSTALL_INCLUDE_DIR}/parser/parser/common COMPONENT opensdk EXCLUDE_FROM_ALL | |||
) | |||
install(FILES ${PARSER_DIR}/parser/common/convert/pb2json.h | |||
DESTINATION ${INSTALL_INCLUDE_DIR}/parser/parser/common/convert COMPONENT opensdk EXCLUDE_FROM_ALL | |||
) | |||
# ---------------------end------------------------- | |||
if (PACKAGE STREQUAL "opensdk") | |||
install(EXPORT parser-targets DESTINATION ${INSTALL_CONFIG_DIR} | |||
FILE parser-targets.cmake COMPONENT opensdk EXCLUDE_FROM_ALL | |||
@@ -15,9 +15,33 @@ | |||
# ============================================================================ | |||
set -e | |||
echo "ASCEND_CUSTOM_PATH=${ASCEND_CUSTOM_PATH}" | |||
echo "BUILD_METADEF=${BUILD_METADEF}" | |||
if [ ! ${BUILD_METADEF} ] ; then | |||
BUILD_METADEF=ON | |||
fi | |||
if [ "X$BUILD_METADEF" = "XON" ]; then | |||
git submodule update --init metadef | |||
fi | |||
BASEPATH=$(cd "$(dirname $0)"; pwd) | |||
OUTPUT_PATH="${BASEPATH}/output" | |||
export BUILD_PATH="${BASEPATH}/build/" | |||
BUILD_PATH="${BASEPATH}/build/" | |||
ASCEND_OPENSDK_DIR=${ASCEND_CUSTOM_PATH}/opensdk/opensdk | |||
PREFIX_PATH="${ASCEND_OPENSDK_DIR}/cmake;\ | |||
${ASCEND_OPENSDK_DIR}/c_sec;\ | |||
${ASCEND_OPENSDK_DIR}/json;\ | |||
${ASCEND_OPENSDK_DIR}/openssl;\ | |||
${ASCEND_OPENSDK_DIR}/zlib;\ | |||
${ASCEND_OPENSDK_DIR}/protoc;\ | |||
${ASCEND_OPENSDK_DIR}/protoc_grpc;\ | |||
${ASCEND_OPENSDK_DIR}/grpc;\ | |||
${ASCEND_OPENSDK_DIR}/protobuf_static;\ | |||
${ASCEND_OPENSDK_DIR}/ascend_protobuf;\ | |||
${ASCEND_OPENSDK_DIR}/ascend_protobuf_static;\ | |||
${ASCEND_OPENSDK_DIR}/gtest_shared/lib/cmake/GTest;\ | |||
${ASCEND_OPENSDK_DIR}/gtest_shared/lib64/cmake/GTest" | |||
# print usage message | |||
usage() | |||
@@ -53,11 +77,9 @@ checkopts() | |||
{ | |||
VERBOSE="" | |||
THREAD_NUM=8 | |||
# ENABLE_PARSER_UT_ONLY_COMPILE="off" | |||
ENABLE_PARSER_UT="off" | |||
ENABLE_PARSER_ST="off" | |||
ENABLE_PARSER_COV="off" | |||
GE_ONLY="on" | |||
ENABLE_GITEE="off" | |||
# Process the options | |||
while getopts 'ustchj:vS:' opt | |||
@@ -66,18 +88,15 @@ checkopts() | |||
case "${opt}" in | |||
u) | |||
ENABLE_PARSER_UT="on" | |||
GE_ONLY="off" | |||
;; | |||
s) | |||
ENABLE_PARSER_ST="on" | |||
;; | |||
t) | |||
ENABLE_PARSER_UT="on" | |||
GE_ONLY="off" | |||
;; | |||
c) | |||
ENABLE_PARSER_COV="on" | |||
GE_ONLY="off" | |||
;; | |||
h) | |||
usage | |||
@@ -103,8 +122,6 @@ checkopts() | |||
} | |||
checkopts "$@" | |||
git submodule update --init metadef | |||
mk_dir() { | |||
local create_dir="$1" # the target to make | |||
@@ -121,31 +138,27 @@ build_parser() | |||
echo "create build directory and build Parser"; | |||
mk_dir "${BUILD_PATH}" | |||
cd "${BUILD_PATH}" | |||
CMAKE_ARGS="-DBUILD_PATH=$BUILD_PATH -DGE_ONLY=$GE_ONLY" | |||
if [[ "X$ENABLE_PARSER_COV" = "Xon" ]]; then | |||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PARSER_COV=ON" | |||
fi | |||
if [[ "X$ENABLE_PARSER_UT" = "Xon" ]]; then | |||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PARSER_UT=ON" | |||
fi | |||
if [[ "X$ENABLE_PARSER_ST" = "Xon" ]]; then | |||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PARSER_ST=ON" | |||
fi | |||
if [[ "X$ENABLE_GITEE" = "Xon" ]]; then | |||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GITEE=ON" | |||
fi | |||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPEN_SRC=True -DCMAKE_INSTALL_PREFIX=${OUTPUT_PATH}" | |||
echo "${CMAKE_ARGS}" | |||
cmake ${CMAKE_ARGS} .. | |||
cmake -D ENABLE_OPEN_SRC=True \ | |||
-D ENABLE_PARSER_COV=${ENABLE_PARSER_COV} \ | |||
-D ENABLE_PARSER_UT=${ENABLE_PARSER_UT} \ | |||
-D ENABLE_PARSER_ST=${ENABLE_PARSER_ST} \ | |||
-D ENABLE_GITEE=${ENABLE_GITEE} \ | |||
-D BUILD_METADEF=${BUILD_METADEF} \ | |||
-D BUILD_WITHOUT_AIR=True \ | |||
-D ASCEND_OPENSDK_DIR=${ASCEND_OPENSDK_DIR} \ | |||
-D CMAKE_BUILD_TYPE=Release \ | |||
-D CMAKE_INSTALL_PREFIX=${OUTPUT_PATH} \ | |||
-D CMAKE_MODULE_PATH=${ASCEND_OPENSDK_DIR}/cmake/modules \ | |||
-D CMAKE_PREFIX_PATH=${PREFIX_PATH} \ | |||
-D protoc_ROOT=${ASCEND_OPENSDK_DIR}/protoc \ | |||
-D protobuf_grpc_ROOT=${ASCEND_OPENSDK_DIR}/grpc \ | |||
-D protobuf_static_ROOT=${ASCEND_OPENSDK_DIR}/protobuf_static \ | |||
-D ascend_protobuf_shared_ROOT=${ASCEND_OPENSDK_DIR}/ascend_protobuf \ | |||
-D ascend_protobuf_static_ROOT=${ASCEND_OPENSDK_DIR}/ascend_protobuf_static \ | |||
.. | |||
if [ 0 -ne $? ] | |||
then | |||
echo "execute command: cmake ${CMAKE_ARGS} .. failed." | |||
echo "execute command: cmake .. failed." | |||
return 1 | |||
fi | |||
@@ -168,14 +181,6 @@ g++ -v | |||
mk_dir ${OUTPUT_PATH} | |||
build_parser || { echo "Parser build failed."; return; } | |||
echo "---------------- Parser build finished ----------------" | |||
rm -f ${OUTPUT_PATH}/libgmock*.so | |||
rm -f ${OUTPUT_PATH}/libgtest*.so | |||
rm -f ${OUTPUT_PATH}/lib*_stub.so | |||
chmod -R 750 ${OUTPUT_PATH} | |||
find ${OUTPUT_PATH} -name "*.so*" -print0 | xargs -0 chmod 500 | |||
echo "---------------- Parser output generated ----------------" | |||
if [[ "X$ENABLE_PARSER_UT" = "Xon" || "X$ENABLE_PARSER_COV" = "Xon" ]]; then | |||
cp ${BUILD_PATH}/tests/ut/parser/ut_parser ${OUTPUT_PATH} | |||
@@ -0,0 +1,108 @@ | |||
function(protobuf_generate comp c_var h_var) | |||
if(NOT ARGN) | |||
message(SEND_ERROR "Error: protobuf_generate() called without any proto files") | |||
return() | |||
endif() | |||
set(${c_var}) | |||
set(${h_var}) | |||
set(_add_target FALSE) | |||
set(extra_option "") | |||
foreach(arg ${ARGN}) | |||
if("${arg}" MATCHES "--proto_path") | |||
set(extra_option ${arg}) | |||
endif() | |||
endforeach() | |||
foreach(file ${ARGN}) | |||
if("${file}" MATCHES "--proto_path") | |||
continue() | |||
endif() | |||
if("${file}" STREQUAL "TARGET") | |||
set(_add_target TRUE) | |||
continue() | |||
endif() | |||
get_filename_component(abs_file ${file} ABSOLUTE) | |||
get_filename_component(file_name ${file} NAME_WE) | |||
get_filename_component(file_dir ${abs_file} PATH) | |||
get_filename_component(parent_subdir ${file_dir} NAME) | |||
if("${parent_subdir}" STREQUAL "proto") | |||
set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto) | |||
else() | |||
set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto/${parent_subdir}) | |||
endif() | |||
list(APPEND ${c_var} "${proto_output_path}/${file_name}.pb.cc") | |||
list(APPEND ${h_var} "${proto_output_path}/${file_name}.pb.h") | |||
add_custom_command( | |||
OUTPUT "${proto_output_path}/${file_name}.pb.cc" "${proto_output_path}/${file_name}.pb.h" | |||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |||
COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" | |||
COMMAND ${CMAKE_COMMAND} -E echo "generate proto cpp_out ${comp} by ${abs_file}" | |||
COMMAND ${PROTOC_PROGRAM} -I${file_dir} ${extra_option} --cpp_out=${proto_output_path} ${abs_file} | |||
DEPENDS ${abs_file} | |||
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM ) | |||
endforeach() | |||
if(_add_target) | |||
add_custom_target( | |||
${comp} DEPENDS ${${c_var}} ${${h_var}} | |||
) | |||
endif() | |||
set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE) | |||
set(${c_var} ${${c_var}} PARENT_SCOPE) | |||
set(${h_var} ${${h_var}} PARENT_SCOPE) | |||
endfunction() | |||
function(protobuf_generate_py comp py_var) | |||
if(NOT ARGN) | |||
message(SEND_ERROR "Error: protobuf_generate_py() called without any proto files") | |||
return() | |||
endif() | |||
set(${py_var}) | |||
set(_add_target FALSE) | |||
foreach(file ${ARGN}) | |||
if("${file}" STREQUAL "TARGET") | |||
set(_add_target TRUE) | |||
continue() | |||
endif() | |||
get_filename_component(abs_file ${file} ABSOLUTE) | |||
get_filename_component(file_name ${file} NAME_WE) | |||
get_filename_component(file_dir ${abs_file} PATH) | |||
get_filename_component(parent_subdir ${file_dir} NAME) | |||
if("${parent_subdir}" STREQUAL "proto") | |||
set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto) | |||
else() | |||
set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto/${parent_subdir}) | |||
endif() | |||
list(APPEND ${py_var} "${proto_output_path}/${file_name}_pb2.py") | |||
add_custom_command( | |||
OUTPUT "${proto_output_path}/${file_name}_pb2.py" | |||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |||
COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" | |||
COMMAND ${CMAKE_COMMAND} -E echo "generate proto python_out ${comp} by ${abs_file}" | |||
COMMAND ${PROTOC_PROGRAM} -I${file_dir} --python_out=${proto_output_path} ${abs_file} | |||
DEPENDS ${abs_file} | |||
COMMENT "Running PYTHON protocol buffer compiler on ${file}" VERBATIM ) | |||
endforeach() | |||
if(_add_target) | |||
add_custom_target( | |||
${comp} DEPENDS ${${py_var}} | |||
) | |||
endif() | |||
set_source_files_properties(${${py_var}} PROPERTIES GENERATED TRUE) | |||
set(${py_var} ${${py_var}} PARENT_SCOPE) | |||
endfunction() |
@@ -1,4 +1,5 @@ | |||
if (HAVE_PUB) | |||
include_guard(GLOBAL) | |||
if (TARGET intf_pub) | |||
return() | |||
endif() | |||
@@ -30,5 +31,3 @@ target_link_libraries(intf_pub INTERFACE | |||
-lpthread | |||
) | |||
#set(HAVE_PUB TRUE CACHE BOOL "pub add") | |||
set(HAVE_PUB TRUE) |
@@ -1 +1 @@ | |||
Subproject commit e6da96dd3928123d3f1d0389f0229055cf171890 | |||
Subproject commit c6841a71ca8b01e34f9ae990de1a7fcf8a4ecb65 |
@@ -58,37 +58,11 @@ target_compile_definitions(fmk_parser PRIVATE | |||
) | |||
target_include_directories(fmk_parser PRIVATE | |||
${CMAKE_CURRENT_LIST_DIR} | |||
${PARSER_DIR} | |||
${PARSER_DIR}/inc | |||
${PARSER_DIR}/parser | |||
${METADEF_DIR}/inc | |||
${METADEF_DIR}/inc/graph | |||
${METADEF_DIR}/inc/register | |||
${METADEF_DIR}/inc/external | |||
${METADEF_DIR}/inc/external/graph | |||
${METADEF_DIR}/inc/external/register | |||
#### temp #### | |||
${PARSER_DIR}/../graphengine/inc/common/util | |||
${PARSER_DIR}/../graphengine/inc/external | |||
${PARSER_DIR}/../graphengine/inc/framework | |||
${PARSER_DIR}/../graphengine/inc | |||
${PARSER_DIR}/../graphengine/ge | |||
${CMAKE_BINARY_DIR} | |||
${CMAKE_BINARY_DIR}/proto/parser_protos | |||
#### blue zone compile ##### | |||
${PARSER_DIR}/../ge | |||
${PARSER_DIR}/../inc | |||
${PARSER_DIR}/../inc/framework | |||
${PARSER_DIR}/../inc/common/util | |||
${PARSER_DIR}/../inc/external | |||
${PARSER_DIR}/../third_party/fwkacllib/inc | |||
#### blue independent compile ##### | |||
${METADEF_DIR}/third_party/graphengine/ge | |||
${METADEF_DIR}/third_party/graphengine/inc | |||
${METADEF_DIR}/third_party/graphengine/inc/framework | |||
${METADEF_DIR}/third_party/graphengine/inc/external | |||
${METADEF_DIR}/third_party/fwkacllib/inc | |||
) | |||
target_link_options(fmk_parser PRIVATE | |||
@@ -98,6 +72,7 @@ target_link_options(fmk_parser PRIVATE | |||
target_link_libraries(fmk_parser | |||
PRIVATE | |||
intf_pub | |||
air_headers | |||
json | |||
PUBLIC | |||
static_mmpa | |||
@@ -125,8 +100,6 @@ add_custom_command( | |||
&& mv tensorflow_parser.cc stub_tensorflow_parser.cc | |||
&& mv caffe_parser.cc stub_caffe_parser.cc | |||
&& echo "Generating stub files end." | |||
#WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | |||
#DEPENDS ../stub/gen_stubapi.py ${TOP_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR} | |||
) | |||
################################################################## | |||
@@ -153,29 +126,15 @@ target_compile_definitions(fmk_parser_stub PRIVATE | |||
) | |||
target_include_directories(fmk_parser_stub PRIVATE | |||
${CMAKE_CURRENT_LIST_DIR} | |||
${PARSER_DIR} | |||
${PARSER_DIR}/inc | |||
${PARSER_DIR}/inc/external | |||
${PARSER_DIR}/parser | |||
${PARSER_DIR}/../inc | |||
${PARSER_DIR}/../inc/common/util | |||
${METADEF_DIR}/inc | |||
${METADEF_DIR}/inc/graph | |||
${METADEF_DIR}/inc/register | |||
${METADEF_DIR}/inc/external | |||
${METADEF_DIR}/inc/external/graph | |||
${METADEF_DIR}/inc/external/register | |||
#### temp #### | |||
${PARSER_DIR}/../graphengine/inc/common/util | |||
${PARSER_DIR}/../graphengine/inc/external | |||
${PARSER_DIR}/../graphengine/inc/framework | |||
${PARSER_DIR}/../graphengine/inc | |||
${PARSER_DIR}/../graphengine/ge | |||
) | |||
target_link_libraries(fmk_parser_stub PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
intf_pub | |||
metadef_headers | |||
) | |||
set_target_properties(fmk_parser_stub PROPERTIES | |||
@@ -48,37 +48,10 @@ target_compile_definitions(parser_common PRIVATE | |||
) | |||
target_include_directories(parser_common PRIVATE | |||
${CMAKE_CURRENT_LIST_DIR} | |||
${PARSER_DIR} | |||
${PARSER_DIR}/parser | |||
${METADEF_DIR} | |||
${METADEF_DIR}/inc | |||
${METADEF_DIR}/inc/graph | |||
${METADEF_DIR}/inc/register | |||
${METADEF_DIR}/inc/external | |||
${METADEF_DIR}/inc/external/graph | |||
${METADEF_DIR}/inc/external/register | |||
#### temp #### | |||
${PARSER_DIR}/../graphengine/inc/common/util | |||
${PARSER_DIR}/../graphengine/inc/external | |||
${PARSER_DIR}/../graphengine/inc/framework | |||
${PARSER_DIR}/../graphengine/inc | |||
${PARSER_DIR}/../graphengine/ge | |||
${CMAKE_BINARY_DIR} | |||
${CMAKE_BINARY_DIR}/proto/parser_protos | |||
#### blue zone compile ##### | |||
${PARSER_DIR}/../ge | |||
${PARSER_DIR}/../inc | |||
${PARSER_DIR}/../inc/framework | |||
${PARSER_DIR}/../inc/common/util | |||
${PARSER_DIR}/../inc/external | |||
${PARSER_DIR}/../third_party/fwkacllib/inc | |||
#### independent compile ##### | |||
${METADEF_DIR}/third_party/graphengine/ge | |||
${METADEF_DIR}/third_party/graphengine/inc | |||
${METADEF_DIR}/third_party/graphengine/inc/framework | |||
${METADEF_DIR}/third_party/graphengine/inc/external | |||
${METADEF_DIR}/third_party/fwkacllib/inc | |||
) | |||
target_link_options(parser_common PRIVATE | |||
@@ -88,6 +61,7 @@ target_link_options(parser_common PRIVATE | |||
target_link_libraries(parser_common | |||
PRIVATE | |||
intf_pub | |||
air_headers | |||
static_mmpa | |||
-Wl,--no-as-needed | |||
graph | |||
@@ -23,9 +23,6 @@ add_custom_target(util ALL | |||
&& cp -r ${PROTO_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/util | |||
) | |||
set(INSTALL_BASE_DIR "") | |||
set(INSTALL_LIBRARY_DIR lib) | |||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/util OPTIONAL | |||
DESTINATION ${INSTALL_LIBRARY_DIR}/func2graph | |||
) | |||
@@ -31,39 +31,13 @@ target_compile_definitions(fmk_onnx_parser PRIVATE | |||
) | |||
target_include_directories(fmk_onnx_parser PRIVATE | |||
${CMAKE_CURRENT_LIST_DIR} | |||
${CMAKE_CURRENT_LIST_DIR}/subgraph_adapter | |||
${PARSER_DIR} | |||
${PARSER_DIR}/inc | |||
${PARSER_DIR}/parser | |||
${PARSER_DIR}/parser/inc | |||
${METADEF_DIR}/inc | |||
${METADEF_DIR}/inc/graph | |||
${METADEF_DIR}/inc/register | |||
${METADEF_DIR}/inc/external | |||
${METADEF_DIR}/inc/external/graph | |||
${METADEF_DIR}/inc/external/register | |||
#### temp #### | |||
${PARSER_DIR}/../graphengine/inc/common/util | |||
${PARSER_DIR}/../graphengine/inc/external | |||
${PARSER_DIR}/../graphengine/inc/framework | |||
${PARSER_DIR}/../graphengine/inc | |||
${PARSER_DIR}/../graphengine/ge | |||
${CMAKE_BINARY_DIR} | |||
${CMAKE_BINARY_DIR}/proto/parser_protos | |||
#### blue zone compile ##### | |||
${PARSER_DIR}/../ge | |||
${PARSER_DIR}/../inc | |||
${PARSER_DIR}/../inc/common/util | |||
${PARSER_DIR}/../inc/framework | |||
${PARSER_DIR}/../inc/external | |||
${PARSER_DIR}/../third_party/fwkacllib/inc | |||
#### independent compile ##### | |||
${METADEF_DIR}/third_party/graphengine/ge | |||
${METADEF_DIR}/third_party/graphengine/inc | |||
${METADEF_DIR}/third_party/graphengine/inc/framework | |||
${METADEF_DIR}/third_party/graphengine/inc/external | |||
${METADEF_DIR}/third_party/fwkacllib/inc | |||
) | |||
target_link_options(fmk_onnx_parser PRIVATE | |||
@@ -73,6 +47,7 @@ target_link_options(fmk_onnx_parser PRIVATE | |||
target_link_libraries(fmk_onnx_parser | |||
PRIVATE | |||
intf_pub | |||
air_headers | |||
static_mmpa | |||
-Wl,--no-as-needed | |||
ascend_protobuf | |||
@@ -97,8 +72,6 @@ add_custom_command( | |||
&& ${HI_PYTHON} ${CMAKE_CURRENT_LIST_DIR}/../stub/gen_stubapi.py ${PARSER_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR} | |||
&& mv onnx_parser.cc stub_onnx_parser.cc | |||
&& echo "Generating stub files end." | |||
#WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | |||
#DEPENDS ../stub/gen_stubapi.py ${TOP_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR} | |||
) | |||
################################################################## | |||
@@ -127,14 +100,11 @@ target_include_directories(fmk_onnx_parser_stub PRIVATE | |||
${PARSER_DIR}/inc/external | |||
${PARSER_DIR}/parser | |||
${PARSER_DIR}/../inc | |||
${METADEF_DIR}/inc | |||
${METADEF_DIR}/inc/graph | |||
${METADEF_DIR}/inc/external | |||
${METADEF_DIR}/inc/external/graph | |||
) | |||
target_link_libraries(fmk_onnx_parser_stub PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
intf_pub | |||
metadef_headers | |||
) | |||
set_target_properties(fmk_onnx_parser_stub PROPERTIES | |||
@@ -117,6 +117,7 @@ Status OnnxFileConstantParser::ParsePath(const ge::onnx::TensorProto &tensor_pro | |||
return FAILED; | |||
} | |||
op_def.SetAttr(kFileConstantPath, attrs); | |||
GELOGD("The weight file of Op[%s] is: [%s].", tensor_proto.name().c_str(), attrs.GetName().c_str()); | |||
return SUCCESS; | |||
} | |||
@@ -366,6 +366,7 @@ Status OnnxModelParser::ParseInitializer(ge::onnx::GraphProto &onnx_graph, | |||
*attribute_t = it.second; | |||
if (it.second.data_location() == ge::onnx::TensorProto_DataLocation_EXTERNAL) { | |||
const_node->set_op_type(kFileConstant); | |||
GELOGD("Initializer const node [%s], the weight was stored in the file.", const_node->name().c_str()); | |||
} else { | |||
const_node->set_op_type(ge::kOpTypeConstant); | |||
} | |||
@@ -374,7 +375,21 @@ Status OnnxModelParser::ParseInitializer(ge::onnx::GraphProto &onnx_graph, | |||
return SUCCESS; | |||
} | |||
void OnnxModelParser::UpdateAllNodeName(ge::onnx::GraphProto &onnx_graph) const { | |||
void OnnxModelParser::UpdateConstantOpType(ge::onnx::NodeProto *node) const { | |||
// If weight in file, Marker Constant(not Initializer) as file constant | |||
for (auto it : node->attribute()) { | |||
if (it.name() == ge::kAttrNameValue) { | |||
const ::ge::onnx::TensorProto tensor_proto = it.t(); | |||
if (tensor_proto.data_location() == ge::onnx::TensorProto_DataLocation_EXTERNAL) { | |||
node->set_op_type(kFileConstant); | |||
GELOGD("Const node [%s], the weight was stored in the file.", node->name().c_str()); | |||
} | |||
break; | |||
} | |||
} | |||
} | |||
void OnnxModelParser::UpdateNodeNameAndOpType(ge::onnx::GraphProto &onnx_graph) const { | |||
int index = 0; | |||
for (int i = 0; i < onnx_graph.node_size(); i++) { | |||
ge::onnx::NodeProto *node = onnx_graph.mutable_node(i); | |||
@@ -382,6 +397,9 @@ void OnnxModelParser::UpdateAllNodeName(ge::onnx::GraphProto &onnx_graph) const | |||
std::string node_name = node->op_type() + "_" + to_string(index++); | |||
node->set_name(node_name); | |||
} | |||
if (node->op_type() == kOpTypeConstant) { | |||
UpdateConstantOpType(node); | |||
} | |||
} | |||
} | |||
@@ -966,7 +984,7 @@ Status OnnxModelParser::ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphP | |||
} | |||
GELOGI("The size of initializer_name_tensor is %zu after ParseInput", initializer_name_tensor.size()); | |||
// 3. Parse Constant from graph. | |||
// 3. Parse Constant(initializer) from graph. | |||
ret = ParseInitializer(onnx_graph, initializer_name_tensor); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "[Parse][Initializer] for onnx failed."); | |||
@@ -980,8 +998,8 @@ Status OnnxModelParser::ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphP | |||
return ret; | |||
} | |||
// 5. Update node name for node do not has name. | |||
UpdateAllNodeName(onnx_graph); | |||
// 5. Update node name for node do not has name, update const op type | |||
UpdateNodeNameAndOpType(onnx_graph); | |||
// 6 Precheck. | |||
ret = Prechecker(onnx_graph); | |||
@@ -105,7 +105,9 @@ class PARSER_FUNC_VISIBILITY OnnxModelParser : public domi::ModelParser { | |||
Status ParseInitializer(ge::onnx::GraphProto &onnx_graph, | |||
std::map<std::string, ge::onnx::TensorProto> &initializer_name_tensor) const; | |||
void UpdateAllNodeName(ge::onnx::GraphProto &onnx_graph) const; | |||
void UpdateConstantOpType(ge::onnx::NodeProto *node) const; | |||
void UpdateNodeNameAndOpType(ge::onnx::GraphProto &onnx_graph) const; | |||
Status ConstructOriType(const ge::onnx::NodeProto *node_proto, std::string &ori_type); | |||
@@ -13,7 +13,6 @@ | |||
# limitations under the License. | |||
# ============================================================================ | |||
project(tests CXX C) | |||
add_subdirectory(depends/slog) | |||
add_subdirectory(depends/mmpa) | |||
add_subdirectory(depends/profiler) | |||
@@ -12,23 +12,14 @@ | |||
# 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(${PARSER_DIR}/metadef/inc) | |||
include_directories(${PARSER_DIR}/metadef/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/metadef/inc) | |||
include_directories(${PARSER_DIR}/metadef/inc/framework) | |||
include_directories(${PARSER_DIR}/metadef/metadef/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/third_party/fwkacllib/inc) | |||
add_library(error_manager_stub SHARED ${SRCS}) | |||
target_link_libraries(error_manager_stub PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
target_link_libraries(error_manager_stub | |||
PRIVATE | |||
intf_pub | |||
PUBLIC | |||
metadef_headers | |||
) |
@@ -12,12 +12,6 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
# ============================================================================ | |||
#cmake_minimum_required(VERSION 2.8) | |||
project(STUB_ATTR_UTIL) | |||
################################################################################ | |||
set(PARSER_PROTO_LIST | |||
"${PARSER_DIR}/metadef/proto/om.proto" | |||
"${PARSER_DIR}/metadef/proto/ge_ir.proto" | |||
@@ -46,18 +40,6 @@ file(GLOB_RECURSE SRCS RELATIVE ${CMAKE_CURRENT_LIST_DIR} | |||
) | |||
include_directories(${CMAKE_CURRENT_LIST_DIR}) | |||
include_directories(${PARSER_DIR}/metadef/inc) | |||
include_directories(${PARSER_DIR}/metadef/inc/graph) | |||
include_directories(${PARSER_DIR}/metadef/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/inc/external/graph) | |||
include_directories(${PARSER_DIR}/metadef/graph) | |||
include_directories(${PARSER_DIR}/metadef/third_party) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/external/ge) | |||
include_directories(${PARSER_DIR}/metadef/third_party/fwkacllib/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/transformer/inc) | |||
include_directories(${PARSER_DIR}/metadef) | |||
include_directories(${CMAKE_BINARY_DIR}/proto/ge) | |||
include_directories(${CMAKE_BINARY_DIR}/proto/ge/proto) | |||
@@ -75,7 +57,10 @@ target_compile_options(attr_util_stub PRIVATE | |||
) | |||
target_link_libraries(attr_util_stub PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
intf_pub | |||
metadef_headers | |||
air_headers | |||
slog_headers | |||
ascend_protobuf | |||
c_sec | |||
) |
@@ -12,28 +12,19 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
# ============================================================================ | |||
#cmake_minimum_required(VERSION 2.8) | |||
project(STUB_MMPA) | |||
file(GLOB_RECURSE SRCS RELATIVE ${CMAKE_CURRENT_LIST_DIR} | |||
"src/mmpa_stub.cc" | |||
) | |||
include_directories(${PARSER_DIR}/metadef/third_party/fwkacllib/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/framework) | |||
include_directories(${PARSER_DIR}/metadef/inc) | |||
include_directories(${PARSER_DIR}/metadef/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/metadef/inc) | |||
include_directories(${PARSER_DIR}/metadef/inc/framework) | |||
include_directories(${PARSER_DIR}/metadef/metadef/inc/external) | |||
add_library(parser_mmpa_stub SHARED ${SRCS}) | |||
target_link_libraries(parser_mmpa_stub PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
-Wl,--no-as-needed | |||
ascend_protobuf | |||
-Wl,--as-needed | |||
c_sec | |||
target_link_libraries(parser_mmpa_stub | |||
PRIVATE | |||
intf_pub | |||
metadef_headers | |||
-Wl,--no-as-needed | |||
ascend_protobuf | |||
-Wl,--as-needed | |||
c_sec | |||
PUBLIC | |||
mmpa_headers | |||
) |
@@ -12,17 +12,15 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
# ============================================================================ | |||
#cmake_minimum_required(VERSION 2.8) | |||
project(parser_profiler_stub) | |||
file(GLOB_RECURSE SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} | |||
"src/profiler_stub.cc" | |||
) | |||
include_directories(${PARSER_DIR}/metadef/third_party/fwkacllib/inc) | |||
add_library(parser_profiler_stub SHARED ${SRC_FILES}) | |||
target_link_libraries(parser_profiler_stub PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
target_link_libraries(parser_profiler_stub | |||
PRIVATE | |||
intf_pub | |||
PUBLIC | |||
msprof_headers | |||
) |
@@ -15,17 +15,7 @@ | |||
*/ | |||
#include "toolchain/prof_engine.h" | |||
#include "toolchain/prof_mgr_core.h" | |||
void * ProfMgrStartUp(const ProfMgrCfg *cfg) | |||
{ | |||
return nullptr; | |||
} | |||
int ProfMgrStop(void *handle) | |||
{ | |||
return 0; | |||
} | |||
int Msprof::Engine::RegisterEngine(const std::string& module, const Msprof::Engine::EngineIntf* engine) | |||
{ | |||
@@ -12,15 +12,14 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
# ============================================================================ | |||
#cmake_minimum_required(VERSION 2.8) | |||
project(parser_slog_stub) | |||
file(GLOB_RECURSE SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} | |||
"src/*.cc" | |||
) | |||
include_directories(${PARSER_DIR}/metadef/third_party/fwkacllib/inc) | |||
add_library(parser_slog_stub SHARED ${SRC_FILES}) | |||
target_link_libraries(parser_slog_stub PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
target_link_libraries(parser_slog_stub | |||
PRIVATE | |||
intf_pub | |||
PUBLIC | |||
slog_headers | |||
) |
@@ -12,8 +12,6 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
# ============================================================================ | |||
project(st_parser) | |||
set(CMAKE_CXX_STANDARD 11) | |||
################################################################################ | |||
@@ -54,7 +52,7 @@ target_compile_options(st_parser_proto PRIVATE | |||
) | |||
target_link_libraries(st_parser_proto PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
intf_pub | |||
ascend_protobuf | |||
) | |||
@@ -148,12 +146,6 @@ include_directories(${PARSER_DIR}/metadef/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/inc/external/graph) | |||
include_directories(${PARSER_DIR}/metadef/register/op_tiling) | |||
include_directories(${PARSER_DIR}/metadef/graph) | |||
include_directories(${PARSER_DIR}/metadef/third_party) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/external/ge) | |||
include_directories(${PARSER_DIR}/metadef/third_party/fwkacllib/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/transformer/inc) | |||
include_directories(${PARSER_DIR}/metadef) | |||
include_directories(${CMAKE_BINARY_DIR}/proto/ge) | |||
include_directories(${CMAKE_BINARY_DIR}/proto/ge/proto) | |||
@@ -172,7 +164,10 @@ target_compile_options(st_parser_graph PRIVATE | |||
) | |||
target_link_libraries(st_parser_graph PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
intf_pub | |||
metadef_headers | |||
air_headers | |||
slog_headers | |||
c_sec ascend_protobuf | |||
) | |||
@@ -215,10 +210,6 @@ include_directories(${PARSER_DIR}/metadef/register) | |||
include_directories(${PARSER_DIR}/metadef/inc) | |||
include_directories(${PARSER_DIR}/metadef/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/inc/register) | |||
include_directories(${PARSER_DIR}/metadef/third_party/fwkacllib/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/framework) | |||
############ libst_parser_register.a ############ | |||
add_library(st_parser_register STATIC | |||
@@ -234,7 +225,12 @@ target_compile_options(st_parser_register PRIVATE | |||
) | |||
target_link_libraries(st_parser_register PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
intf_pub | |||
metadef_headers | |||
air_headers | |||
slog_headers | |||
runtime_headers | |||
msprof_headers | |||
c_sec ascend_protobuf json | |||
) | |||
@@ -324,10 +320,6 @@ include_directories(${PARSER_DIR}/tests) | |||
include_directories(${PARSER_DIR}/metadef/inc) | |||
include_directories(${PARSER_DIR}/metadef/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/inc/register) | |||
include_directories(${PARSER_DIR}/metadef/third_party/fwkacllib/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/framework) | |||
set(PARSER_ST_FILES | |||
@@ -353,7 +345,10 @@ target_compile_options(st_parser_common PRIVATE | |||
) | |||
target_link_libraries(st_parser_common PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
intf_pub | |||
air_headers | |||
metadef_headers | |||
slog_headers | |||
st_parser_proto st_parser_graph c_sec | |||
ascend_protobuf | |||
json | |||
@@ -373,11 +368,17 @@ target_compile_definitions(st_parser PRIVATE | |||
google=ascend_private | |||
) | |||
target_link_libraries(st_parser | |||
$<BUILD_INTERFACE:intf_pub> | |||
target_link_libraries(st_parser PRIVATE | |||
intf_pub | |||
metadef_headers | |||
air_headers | |||
slog_headers | |||
cce_headers | |||
runtime_headers | |||
msprof_headers | |||
st_parser_proto | |||
json | |||
-Wl,--whole-archive st_parser_common -Wl,--no-whole-archive | |||
st_parser_graph st_parser_register error_manager_stub parser_mmpa_stub attr_util_stub | |||
gtest gtest_main parser_slog_stub ascend_protobuf c_sec -lrt -ldl -lgcov | |||
GTest::gtest GTest::gtest_main parser_slog_stub ascend_protobuf c_sec -lrt -ldl -lgcov | |||
) |
@@ -25,7 +25,10 @@ | |||
#include "external/ge/ge_api_types.h" | |||
#include "tests/depends/ops_stub/ops_stub.h" | |||
#include "framework/omg/parser/parser_factory.h" | |||
#include "parser/onnx/onnx_util.h" | |||
#define private public | |||
#include "parser/onnx/onnx_parser.h" | |||
#undef private | |||
namespace ge { | |||
class STestOnnxParser : public testing::Test { | |||
@@ -103,6 +106,31 @@ void STestOnnxParser::RegisterCustomOp() { | |||
domi::OpRegistry::Instance()->registrationDatas.clear(); | |||
} | |||
ge::onnx::GraphProto CreateOnnxGraph() { | |||
ge::onnx::GraphProto onnx_graph; | |||
(void)onnx_graph.add_input(); | |||
(void)onnx_graph.add_output(); | |||
::ge::onnx::NodeProto* node_const1 = onnx_graph.add_node(); | |||
::ge::onnx::NodeProto* node_const2 = onnx_graph.add_node(); | |||
::ge::onnx::NodeProto* node_add = onnx_graph.add_node(); | |||
node_const1->set_op_type(kOpTypeConstant); | |||
node_const2->set_op_type(kOpTypeConstant); | |||
node_add->set_op_type("Add"); | |||
::ge::onnx::AttributeProto* attr = node_const1->add_attribute(); | |||
attr->set_name(ge::kAttrNameValue); | |||
::ge::onnx::TensorProto* tensor_proto = attr->mutable_t(); | |||
tensor_proto->set_data_location(ge::onnx::TensorProto_DataLocation_EXTERNAL); | |||
attr = node_const1->add_attribute(); | |||
attr = node_const2->add_attribute(); | |||
attr->set_name(ge::kAttrNameValue); | |||
tensor_proto = attr->mutable_t(); | |||
tensor_proto->set_data_location(ge::onnx::TensorProto_DataLocation_DEFAULT); | |||
return onnx_graph; | |||
} | |||
TEST_F(STestOnnxParser, onnx_parser_user_output_with_default) { | |||
std::string case_dir = __FILE__; | |||
case_dir = case_dir.substr(0, case_dir.find_last_of("/")); | |||
@@ -184,4 +212,15 @@ TEST_F(STestOnnxParser, onnx_parser_if_node_with_const_input) { | |||
EXPECT_EQ(ret, GRAPH_SUCCESS); | |||
} | |||
TEST_F(STestOnnxParser, onnx_test_ModelParseToGraph) | |||
{ | |||
OnnxModelParser modelParser; | |||
ge::onnx::ModelProto model_proto; | |||
auto onnx_graph = model_proto.mutable_graph(); | |||
*onnx_graph = CreateOnnxGraph(); | |||
ge::Graph graph; | |||
Status ret = modelParser.ModelParseToGraph(model_proto, graph); | |||
EXPECT_EQ(ret, FAILED); | |||
} | |||
} // namespace ge |
@@ -26,7 +26,7 @@ | |||
#include "st/parser_st_utils.h" | |||
#include "tests/depends/ops_stub/ops_stub.h" | |||
#include "parser/common/acl_graph_parser_util.h" | |||
#include "metadef/third_party/graphengine/inc/external/ge/ge_api_types.h" | |||
#include "external/ge/ge_api_types.h" | |||
#include "omg/parser/parser_factory.h" | |||
#include "common/pre_checker.h" | |||
#include "common/util.h" | |||
@@ -12,9 +12,6 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
# ============================================================================ | |||
project(ut CXX C) | |||
if (ENABLE_PARSER_COV) | |||
set(COVERAGE_COMPILER_FLAGS "-g --coverage -fprofile-arcs -fPIC -O0 -ftest-coverage") | |||
set(CMAKE_CXX_FLAGS "${COVERAGE_COMPILER_FLAGS}") | |||
@@ -12,9 +12,6 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
# ============================================================================ | |||
project(ut_parser) | |||
set(CMAKE_CXX_STANDARD 11) | |||
################################################################################ | |||
@@ -55,7 +52,7 @@ target_compile_options(ut_parser_proto PRIVATE | |||
) | |||
target_link_libraries(ut_parser_proto PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
intf_pub | |||
ascend_protobuf | |||
) | |||
@@ -149,12 +146,6 @@ include_directories(${PARSER_DIR}/metadef/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/inc/external/graph) | |||
include_directories(${PARSER_DIR}/metadef/graph) | |||
include_directories(${PARSER_DIR}/metadef/register) | |||
include_directories(${PARSER_DIR}/metadef/third_party) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/external/ge) | |||
include_directories(${PARSER_DIR}/metadef/third_party/fwkacllib/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/transformer/inc) | |||
include_directories(${PARSER_DIR}/metadef) | |||
include_directories(${CMAKE_BINARY_DIR}/proto/ge) | |||
include_directories(${CMAKE_BINARY_DIR}/proto/ge/proto) | |||
@@ -173,7 +164,10 @@ target_compile_options(ut_parser_graph PRIVATE | |||
) | |||
target_link_libraries(ut_parser_graph PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
intf_pub | |||
metadef_headers | |||
air_headers | |||
slog_headers | |||
c_sec ascend_protobuf | |||
) | |||
@@ -216,10 +210,6 @@ include_directories(${PARSER_DIR}/metadef/register) | |||
include_directories(${PARSER_DIR}/metadef/inc) | |||
include_directories(${PARSER_DIR}/metadef/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/inc/register) | |||
include_directories(${PARSER_DIR}/metadef/third_party/fwkacllib/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/framework) | |||
############ libut_parser_register.a ############ | |||
add_library(ut_parser_register STATIC | |||
@@ -235,7 +225,11 @@ target_compile_options(ut_parser_register PRIVATE | |||
) | |||
target_link_libraries(ut_parser_register PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
intf_pub | |||
air_headers | |||
slog_headers | |||
runtime_headers | |||
msprof_headers | |||
c_sec ascend_protobuf json | |||
) | |||
@@ -325,11 +319,6 @@ include_directories(${PARSER_DIR}/tests) | |||
include_directories(${PARSER_DIR}/metadef/inc) | |||
include_directories(${PARSER_DIR}/metadef/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/inc/register) | |||
include_directories(${PARSER_DIR}/metadef/third_party/fwkacllib/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/external) | |||
include_directories(${PARSER_DIR}/metadef/third_party/graphengine/inc/framework) | |||
set(PARSER_UT_FILES | |||
"parser_ut_utils.cc" | |||
@@ -357,7 +346,9 @@ target_compile_options(ut_parser_common PRIVATE | |||
) | |||
target_link_libraries(ut_parser_common PRIVATE | |||
$<BUILD_INTERFACE:intf_pub> | |||
intf_pub | |||
air_headers | |||
slog_headers | |||
ut_parser_proto ut_parser_graph c_sec | |||
ascend_protobuf | |||
json | |||
@@ -378,9 +369,15 @@ target_compile_definitions(ut_parser PRIVATE | |||
) | |||
target_link_libraries(ut_parser | |||
$<BUILD_INTERFACE:intf_pub> | |||
intf_pub | |||
metadef_headers | |||
air_headers | |||
slog_headers | |||
cce_headers | |||
runtime_headers | |||
msprof_headers | |||
ut_parser_proto | |||
-Wl,--whole-archive ut_parser_common -Wl,--no-whole-archive | |||
ut_parser_graph ut_parser_register error_manager_stub parser_mmpa_stub attr_util_stub | |||
gtest gtest_main parser_slog_stub ascend_protobuf c_sec json -lrt -ldl -lgcov | |||
GTest::gtest GTest::gtest_main parser_slog_stub ascend_protobuf c_sec json -lrt -ldl -lgcov | |||
) |
@@ -111,6 +111,29 @@ void UtestOnnxParser::RegisterCustomOp() { | |||
domi::OpRegistry::Instance()->registrationDatas.clear(); | |||
} | |||
ge::onnx::GraphProto CreateOnnxGraph() { | |||
ge::onnx::GraphProto onnx_graph; | |||
::ge::onnx::NodeProto* node_const1 = onnx_graph.add_node(); | |||
::ge::onnx::NodeProto* node_const2 = onnx_graph.add_node(); | |||
::ge::onnx::NodeProto* node_add = onnx_graph.add_node(); | |||
node_const1->set_op_type(kOpTypeConstant); | |||
node_const2->set_op_type(kOpTypeConstant); | |||
node_add->set_op_type("Add"); | |||
::ge::onnx::AttributeProto* attr = node_const1->add_attribute(); | |||
attr->set_name(ge::kAttrNameValue); | |||
::ge::onnx::TensorProto* tensor_proto = attr->mutable_t(); | |||
tensor_proto->set_data_location(ge::onnx::TensorProto_DataLocation_EXTERNAL); | |||
attr = node_const1->add_attribute(); | |||
attr = node_const2->add_attribute(); | |||
attr->set_name(ge::kAttrNameValue); | |||
tensor_proto = attr->mutable_t(); | |||
tensor_proto->set_data_location(ge::onnx::TensorProto_DataLocation_DEFAULT); | |||
return onnx_graph; | |||
} | |||
TEST_F(UtestOnnxParser, onnx_parser_if_node) { | |||
std::string case_dir = __FILE__; | |||
case_dir = case_dir.substr(0, case_dir.find_last_of("/")); | |||
@@ -575,6 +598,16 @@ TEST_F(UtestOnnxParser, OnnxModelParser_ParseInput_test) | |||
EXPECT_EQ(ret, domi::FAILED); | |||
} | |||
TEST_F(UtestOnnxParser, OnnxModelParser_ParseConstant_test) | |||
{ | |||
OnnxModelParser model_parser; | |||
ge::onnx::GraphProto onnx_graph = CreateOnnxGraph(); | |||
model_parser.UpdateNodeNameAndOpType(onnx_graph); | |||
std::string type = onnx_graph.mutable_node(0)->op_type(); | |||
EXPECT_EQ(type, kFileConstant); | |||
} | |||
TEST_F(UtestOnnxParser, onnx_test_ConstructOriType) | |||
{ | |||
ge::onnx::ModelProto model_proto; | |||
@@ -27,7 +27,7 @@ | |||
#include "external/register/register.h" | |||
#include "tests/depends/ops_stub/ops_stub.h" | |||
#include "parser/common/acl_graph_parser_util.h" | |||
#include "metadef/third_party/graphengine/inc/external/ge/ge_api_types.h" | |||
#include "external/ge/ge_api_types.h" | |||
#include "omg/parser/parser_factory.h" | |||
#include "common/pre_checker.h" | |||
#include "common/util.h" | |||