@@ -0,0 +1,30 @@ | |||||
# Parser | |||||
build/ | |||||
output/ | |||||
prebuilts/ | |||||
cov/ | |||||
*.ir | |||||
*.out | |||||
# Dynamic libraries | |||||
# *.so | |||||
*.dylib | |||||
# Static libraries | |||||
*.la | |||||
*.lai | |||||
*.a | |||||
*.lib | |||||
# Protocol buffers | |||||
*_pb2.py | |||||
*.pb.h | |||||
*.pb.cc | |||||
# Object files | |||||
*.o | |||||
# Editor | |||||
.vscode | |||||
.idea/ | |||||
cmake-build-* |
@@ -16,6 +16,7 @@ if (ENABLE_OPEN_SRC) | |||||
include(cmake/external_libs/protoc.cmake) | include(cmake/external_libs/protoc.cmake) | ||||
include(cmake/external_libs/securec.cmake) | include(cmake/external_libs/securec.cmake) | ||||
include(cmake/external_libs/json.cmake) | include(cmake/external_libs/json.cmake) | ||||
include(cmake/external_libs/gtest.cmake) | |||||
include(cmake/FindModule.cmake) | include(cmake/FindModule.cmake) | ||||
include(cmake/intf_pub_linux.cmake) | include(cmake/intf_pub_linux.cmake) | ||||
@@ -37,6 +38,8 @@ if (ENABLE_OPEN_SRC) | |||||
find_module(static_mmpa libmmpa.a ${GE_LIB_PATH}) | find_module(static_mmpa libmmpa.a ${GE_LIB_PATH}) | ||||
elseif(ENABLE_GE_COV OR ENABLE_GE_UT) | elseif(ENABLE_GE_COV OR ENABLE_GE_UT) | ||||
message(STATUS "Runing on llt mode, no need to depend other component") | message(STATUS "Runing on llt mode, no need to depend other component") | ||||
elseif(ENABLE_PARSER_UT OR ENABLE_PARSER_COV) | |||||
add_subdirectory(tests) | |||||
else() | else() | ||||
if(DEFINED ENV{ASCEND_CUSTOM_PATH}) | if(DEFINED ENV{ASCEND_CUSTOM_PATH}) | ||||
set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) | set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) | ||||
@@ -53,10 +53,10 @@ checkopts() | |||||
{ | { | ||||
VERBOSE="" | VERBOSE="" | ||||
THREAD_NUM=8 | THREAD_NUM=8 | ||||
# ENABLE_GE_UT_ONLY_COMPILE="off" | |||||
ENABLE_GE_UT="off" | |||||
ENABLE_GE_ST="off" | |||||
ENABLE_GE_COV="off" | |||||
# ENABLE_PARSER_UT_ONLY_COMPILE="off" | |||||
ENABLE_PARSER_UT="off" | |||||
ENABLE_PARSER_ST="off" | |||||
ENABLE_PARSER_COV="off" | |||||
GE_ONLY="on" | GE_ONLY="on" | ||||
ENABLE_GITEE="off" | ENABLE_GITEE="off" | ||||
# Process the options | # Process the options | ||||
@@ -65,19 +65,18 @@ checkopts() | |||||
OPTARG=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]') | OPTARG=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]') | ||||
case "${opt}" in | case "${opt}" in | ||||
u) | u) | ||||
# ENABLE_GE_UT_ONLY_COMPILE="on" | |||||
ENABLE_GE_UT="on" | |||||
ENABLE_PARSER_UT="on" | |||||
GE_ONLY="off" | GE_ONLY="off" | ||||
;; | ;; | ||||
s) | s) | ||||
ENABLE_GE_ST="on" | |||||
ENABLE_PARSER_ST="on" | |||||
;; | ;; | ||||
t) | t) | ||||
ENABLE_GE_UT="on" | |||||
GE_ONLY="off" | |||||
;; | |||||
ENABLE_PARSER_UT="on" | |||||
GE_ONLY="off" | |||||
;; | |||||
c) | c) | ||||
ENABLE_GE_COV="on" | |||||
ENABLE_PARSER_COV="on" | |||||
GE_ONLY="off" | GE_ONLY="off" | ||||
;; | ;; | ||||
h) | h) | ||||
@@ -124,17 +123,17 @@ build_parser() | |||||
cd "${BUILD_PATH}" | cd "${BUILD_PATH}" | ||||
CMAKE_ARGS="-DBUILD_PATH=$BUILD_PATH -DGE_ONLY=$GE_ONLY" | CMAKE_ARGS="-DBUILD_PATH=$BUILD_PATH -DGE_ONLY=$GE_ONLY" | ||||
if [[ "X$ENABLE_GE_COV" = "Xon" ]]; then | |||||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GE_COV=ON" | |||||
if [[ "X$ENABLE_PARSER_COV" = "Xon" ]]; then | |||||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PARSER_COV=ON" | |||||
fi | fi | ||||
if [[ "X$ENABLE_GE_UT" = "Xon" ]]; then | |||||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GE_UT=ON" | |||||
if [[ "X$ENABLE_PARSER_UT" = "Xon" ]]; then | |||||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PARSER_UT=ON" | |||||
fi | fi | ||||
if [[ "X$ENABLE_GE_ST" = "Xon" ]]; then | |||||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GE_ST=ON" | |||||
if [[ "X$ENABLE_PARSER_ST" = "Xon" ]]; then | |||||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PARSER_ST=ON" | |||||
fi | fi | ||||
if [[ "X$ENABLE_GITEE" = "Xon" ]]; then | if [[ "X$ENABLE_GITEE" = "Xon" ]]; then | ||||
@@ -149,7 +148,13 @@ build_parser() | |||||
echo "execute command: cmake ${CMAKE_ARGS} .. failed." | echo "execute command: cmake ${CMAKE_ARGS} .. failed." | ||||
return 1 | return 1 | ||||
fi | fi | ||||
make ${VERBOSE} -j${THREAD_NUM} && make install | |||||
if [ "X$ENABLE_PARSER_UT" = "Xon" ]; then | |||||
make ut_parser -j8 | |||||
else | |||||
make ${VERBOSE} -j${THREAD_NUM} && make install | |||||
fi | |||||
if [ 0 -ne $? ] | if [ 0 -ne $? ] | ||||
then | then | ||||
echo "execute command: make ${VERBOSE} -j${THREAD_NUM} && make install failed." | echo "execute command: make ${VERBOSE} -j${THREAD_NUM} && make install failed." | ||||
@@ -170,6 +175,25 @@ find ${OUTPUT_PATH} -name "*.so*" -print0 | xargs -0 chmod 500 | |||||
echo "---------------- Parser output generated ----------------" | 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} | |||||
RUN_TEST_CASE=${OUTPUT_PATH}/ut_parser && ${RUN_TEST_CASE} | |||||
if [[ "$?" -ne 0 ]]; then | |||||
echo "!!! UT FAILED, PLEASE CHECK YOUR CHANGES !!!" | |||||
echo -e "\033[31m${RUN_TEST_CASE}\033[0m" | |||||
exit 1; | |||||
fi | |||||
echo "Generating coverage statistics, please wait..." | |||||
cd ${BASEPATH} | |||||
rm -rf ${BASEPATH}/cov | |||||
mkdir ${BASEPATH}/cov | |||||
lcov -c -d build/tests/ut/parser -o cov/tmp.info | |||||
lcov -r cov/tmp.info '*/output/*' '*/build/opensrc/*' '*/build/proto/*' '*/third_party/*' '*/tests/*' '/usr/local/*' '*/metadef/inc/*' -o cov/coverage.info | |||||
cd ${BASEPATH}/cov | |||||
genhtml coverage.info | |||||
fi | |||||
# generate output package in tar form, including ut/st libraries/executables | # generate output package in tar form, including ut/st libraries/executables | ||||
generate_package() | generate_package() | ||||
{ | { | ||||
@@ -212,7 +236,7 @@ generate_package() | |||||
tar -cf parser_lib.tar fwkacllib acllib atc | tar -cf parser_lib.tar fwkacllib acllib atc | ||||
} | } | ||||
if [[ "X$ENABLE_GE_UT" = "Xoff" ]]; then | |||||
if [[ "X$ENABLE_PARSER_UT" = "Xoff" ]]; then | |||||
generate_package | generate_package | ||||
fi | fi | ||||
echo "---------------- Parser package archive generated ----------------" | echo "---------------- Parser package archive generated ----------------" |
@@ -0,0 +1,64 @@ | |||||
if (HAVE_GTEST) | |||||
return() | |||||
endif() | |||||
include(ExternalProject) | |||||
if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||||
(${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) | |||||
set(CMAKE_INSTALL_PREFIX ${PARSER_DIR}/output CACHE STRING "path for install()" FORCE) | |||||
message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | |||||
endif() | |||||
if (PARSER_PB_PKG) | |||||
set(REQ_URL "${PARSER_PB_PKG}/libs/ge_gtest/release-1.8.1.tar.gz") | |||||
set(MD5 "") | |||||
elseif (ENABLE_GITEE) | |||||
set(REQ_URL "https://gitee.com/mirrors/googletest/repository/archive/release-1.8.1.tar.gz") | |||||
set(MD5 "") | |||||
else() | |||||
set(REQ_URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz") | |||||
set(MD5 "") | |||||
endif () | |||||
set (gtest_CXXFLAGS "-D_GLIBCXX_USE_CXX11_ABI=0 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack") | |||||
set (gtest_CFLAGS "-D_GLIBCXX_USE_CXX11_ABI=0 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack") | |||||
ExternalProject_Add(gtest_build | |||||
URL ${REQ_URL} | |||||
TLS_VERIFY OFF | |||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_CXX_FLAGS=${gtest_CXXFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/gtest <SOURCE_DIR> | |||||
-DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_MACOSX_RPATH=TRUE -Dgtest_disable_pthreads=ON | |||||
BUILD_COMMAND $(MAKE) | |||||
INSTALL_COMMAND $(MAKE) install | |||||
EXCLUDE_FROM_ALL TRUE | |||||
) | |||||
set(GTEST_PKG_DIR ${CMAKE_INSTALL_PREFIX}/gtest) | |||||
file(MAKE_DIRECTORY ${GTEST_PKG_DIR}/include) | |||||
add_library(gtest SHARED IMPORTED) | |||||
set_target_properties(gtest PROPERTIES | |||||
IMPORTED_LOCATION ${GTEST_PKG_DIR}/lib/libgtest.so | |||||
) | |||||
add_library(gtest_main SHARED IMPORTED) | |||||
set_target_properties(gtest_main PROPERTIES | |||||
IMPORTED_LOCATION ${GTEST_PKG_DIR}/lib/libgtest_main.so | |||||
) | |||||
target_include_directories(gtest INTERFACE ${GTEST_PKG_DIR}/include) | |||||
target_include_directories(gtest_main INTERFACE ${GTEST_PKG_DIR}/include) | |||||
set(INSTALL_BASE_DIR "") | |||||
set(INSTALL_LIBRARY_DIR lib) | |||||
install(FILES ${GTEST_PKG_DIR}/lib/libgtest.so ${GTEST_PKG_DIR}/lib/libgtest_main.so OPTIONAL | |||||
DESTINATION ${INSTALL_LIBRARY_DIR}) | |||||
add_dependencies(gtest gtest_build) | |||||
#set(HAVE_GFLAGS TRUE CACHE BOOL "gflags build add") | |||||
set(HAVE_GTEST TRUE) |
@@ -5,15 +5,20 @@ endif() | |||||
include(ExternalProject) | include(ExternalProject) | ||||
set(JSON_SRC_DIR ${CMAKE_BINARY_DIR}/opensrc/json/include) | set(JSON_SRC_DIR ${CMAKE_BINARY_DIR}/opensrc/json/include) | ||||
#if (ENABLE_GITEE) | |||||
if (PARSER_PB_PKG) | |||||
set(REQ_URL "${PARSER_PB_PKG}/libs/ge_nlohmann_json/include.zip") | |||||
set(MD5 "") | |||||
set(JSON_INCLUDE_DIR ${JSON_SRC_DIR}) | |||||
#else if (ENABLE_GITEE) | |||||
# set(REQ_URL "https://gitee.com/mirrors/JSON-for-Modern-CPP/repository/archive/v3.6.1.zip") | # set(REQ_URL "https://gitee.com/mirrors/JSON-for-Modern-CPP/repository/archive/v3.6.1.zip") | ||||
# set(MD5 "5bda78ce308e6cfcf614dcf1d5ff27a7") | # set(MD5 "5bda78ce308e6cfcf614dcf1d5ff27a7") | ||||
# set(JSON_INCLUDE_DIR "${JSON_SRC_DIR}/include") | # set(JSON_INCLUDE_DIR "${JSON_SRC_DIR}/include") | ||||
#else() | |||||
else() | |||||
set(REQ_URL "https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip") | set(REQ_URL "https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip") | ||||
set(MD5 "0dc903888211db3a0f170304cd9f3a89") | set(MD5 "0dc903888211db3a0f170304cd9f3a89") | ||||
set(JSON_INCLUDE_DIR ${JSON_SRC_DIR}) | set(JSON_INCLUDE_DIR ${JSON_SRC_DIR}) | ||||
#endif () | |||||
endif () | |||||
ExternalProject_Add(json_build | ExternalProject_Add(json_build | ||||
URL ${REQ_URL} | URL ${REQ_URL} | ||||
#URL /home/txd/workspace/cloud_code/pkg/include.zip | #URL /home/txd/workspace/cloud_code/pkg/include.zip | ||||
@@ -10,11 +10,20 @@ if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||||
message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | ||||
endif() | endif() | ||||
if (PARSER_PB_PKG) | |||||
set(REQ_URL "${PARSER_PB_PKG}/libs/securec/v1.1.10.tar.gz") | |||||
set(MD5 "") | |||||
else() | |||||
set(REQ_URL "https://gitee.com/openeuler/libboundscheck/repository/archive/v1.1.10.tar.gz") | |||||
set(MD5 "") | |||||
endif() | |||||
ExternalProject_Add(c_sec_build | ExternalProject_Add(c_sec_build | ||||
URL https://gitee.com/openeuler/libboundscheck/repository/archive/v1.1.10.tar.gz | |||||
#URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz | |||||
URL ${REQ_URL} | |||||
#URL https://gitee.com/openeuler/libboundscheck/repository/archive/v1.1.10.tar.gz | |||||
#SOURCE_DIR ${PARSER_DIR}/../libc_sec | #SOURCE_DIR ${PARSER_DIR}/../libc_sec | ||||
PATCH_COMMAND patch -p1 < ${PARSER_DIR}/metadef/third_party/patch/securec/0001-add-securec-cmake-script.patch | |||||
PATCH_COMMAND patch -p1 < ${PARSER_DIR}/metadef/third_party/patch/securec/0001-add-securec-cmake-script.patch | |||||
TLS_VERIFY OFF | |||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} | CONFIGURE_COMMAND ${CMAKE_COMMAND} | ||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} | -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} | ||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} | -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} | ||||
@@ -0,0 +1,28 @@ | |||||
# 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. | |||||
# ============================================================================ | |||||
project(tests CXX C) | |||||
add_subdirectory(depends/slog) | |||||
add_subdirectory(depends/mmpa) | |||||
add_subdirectory(depends/profiler) | |||||
add_subdirectory(depends/error_manager) | |||||
if (ENABLE_PARSER_COV OR ENABLE_PARSER_UT) | |||||
add_subdirectory(ut) | |||||
endif() | |||||
if (ENABLE_PARSER_ST) | |||||
add_subdirectory(st) | |||||
endif() |
@@ -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(${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> | |||||
) |
@@ -0,0 +1,95 @@ | |||||
/** | |||||
* 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; | |||||
} | |||||
int ErrorManager::ReportInterErrMessage(std::string error_code, const std::string &error_msg) { | |||||
return 0; | |||||
} | |||||
const std::string &ErrorManager::GetLogHeader() { | |||||
static const std::string kLogHeader("GeUtStub"); | |||||
return kLogHeader; | |||||
} | |||||
/// | |||||
/// @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::string &root_graph_name, | |||||
const std::map<std::string, std::string> &msg) { return 0; } | |||||
/// | |||||
/// @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; } | |||||
void ErrorManager::SetStage(const std::string &first_stage, const std::string &second_stage) { | |||||
} | |||||
void ErrorManager::GenWorkStreamIdDefault() { | |||||
} |
@@ -0,0 +1,39 @@ | |||||
# 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_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(mmpa_stub SHARED ${SRCS}) | |||||
target_link_libraries(mmpa_stub PRIVATE | |||||
$<BUILD_INTERFACE:intf_pub> | |||||
-Wl,--no-as-needed | |||||
ascend_protobuf | |||||
-Wl,--as-needed | |||||
c_sec | |||||
) |
@@ -0,0 +1,284 @@ | |||||
/** | |||||
* 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 "mmpa/mmpa_api.h" | |||||
INT32 mmOpen(const CHAR *path_name, INT32 flags) { | |||||
INT32 fd = HANDLE_INVALID_VALUE; | |||||
if (NULL == path_name) { | |||||
syslog(LOG_ERR, "The path name pointer is null.\r\n"); | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
if (0 == (flags & (O_RDONLY | O_WRONLY | O_RDWR | O_CREAT))) { | |||||
syslog(LOG_ERR, "The file open mode is error.\r\n"); | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
fd = open(path_name, flags); | |||||
if (fd < MMPA_ZERO) { | |||||
syslog(LOG_ERR, "Open file failed, errno is %s.\r\n", strerror(errno)); | |||||
return EN_ERROR; | |||||
} | |||||
return fd; | |||||
} | |||||
INT32 mmOpen2(const CHAR *path_name, INT32 flags, MODE mode) { | |||||
INT32 fd = HANDLE_INVALID_VALUE; | |||||
if (NULL == path_name) { | |||||
syslog(LOG_ERR, "The path name pointer is null.\r\n"); | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
if (MMPA_ZERO == (flags & (O_RDONLY | O_WRONLY | O_RDWR | O_CREAT))) { | |||||
syslog(LOG_ERR, "The file open mode is error.\r\n"); | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
if ((MMPA_ZERO == (mode & (S_IRUSR | S_IREAD))) && (MMPA_ZERO == (mode & (S_IWUSR | S_IWRITE)))) { | |||||
syslog(LOG_ERR, "The permission mode of the file is error.\r\n"); | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
fd = open(path_name, flags, mode); | |||||
if (fd < MMPA_ZERO) { | |||||
syslog(LOG_ERR, "Open file failed, errno is %s.\r\n", strerror(errno)); | |||||
return EN_ERROR; | |||||
} | |||||
return fd; | |||||
} | |||||
INT32 mmClose(INT32 fd) { | |||||
INT32 result = EN_OK; | |||||
if (fd < MMPA_ZERO) { | |||||
syslog(LOG_ERR, "The file fd is invalid.\r\n"); | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
result = close(fd); | |||||
if (EN_OK != result) { | |||||
syslog(LOG_ERR, "Close the file failed, errno is %s.\r\n", strerror(errno)); | |||||
return EN_ERROR; | |||||
} | |||||
return EN_OK; | |||||
} | |||||
mmSsize_t mmWrite(INT32 fd, VOID *mm_buf, UINT32 mm_count) { | |||||
mmSsize_t result = MMPA_ZERO; | |||||
if ((fd < MMPA_ZERO) || (NULL == mm_buf)) { | |||||
syslog(LOG_ERR, "Input parameter invalid.\r\n"); | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
result = write(fd, mm_buf, (size_t)mm_count); | |||||
if (result < MMPA_ZERO) { | |||||
syslog(LOG_ERR, "Write buf to file failed, errno is %s.\r\n", strerror(errno)); | |||||
return EN_ERROR; | |||||
} | |||||
return result; | |||||
} | |||||
mmSsize_t mmRead(INT32 fd, VOID *mm_buf, UINT32 mm_count) { | |||||
mmSsize_t result = MMPA_ZERO; | |||||
if ((fd < MMPA_ZERO) || (NULL == mm_buf)) { | |||||
syslog(LOG_ERR, "Input parameter invalid.\r\n"); | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
result = read(fd, mm_buf, (size_t)mm_count); | |||||
if (result < MMPA_ZERO) { | |||||
syslog(LOG_ERR, "Read file to buf failed, errno is %s.\r\n", strerror(errno)); | |||||
return EN_ERROR; | |||||
} | |||||
return result; | |||||
} | |||||
INT32 mmMkdir(const CHAR *lp_path_name, mmMode_t mode) { | |||||
INT32 t_mode = mode; | |||||
INT32 ret = EN_OK; | |||||
if (NULL == lp_path_name) { | |||||
syslog(LOG_ERR, "The input path is null.\r\n"); | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
if (t_mode < MMPA_ZERO) { | |||||
syslog(LOG_ERR, "The input mode is wrong.\r\n"); | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
ret = mkdir(lp_path_name, mode); | |||||
if (EN_OK != ret) { | |||||
syslog(LOG_ERR, "Failed to create the directory, the ret is %s.\r\n", strerror(errno)); | |||||
return EN_ERROR; | |||||
} | |||||
return EN_OK; | |||||
} | |||||
void *memCpyS(void *dest, const void *src, UINT32 count) { | |||||
char *tmp = (char *)dest; | |||||
char *s = (char *)src; | |||||
if (MMPA_ZERO == count) { | |||||
return dest; | |||||
} | |||||
while (count--) { | |||||
*tmp++ = *s++; | |||||
} | |||||
return dest; | |||||
} | |||||
INT32 mmRmdir(const CHAR *lp_path_name) { return rmdir(lp_path_name); } | |||||
mmTimespec mmGetTickCount() { | |||||
mmTimespec rts; | |||||
struct timespec ts = {0}; | |||||
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts); | |||||
rts.tv_sec = ts.tv_sec; | |||||
rts.tv_nsec = ts.tv_nsec; | |||||
return rts; | |||||
} | |||||
INT32 mmGetTid() { | |||||
INT32 ret = (INT32)syscall(SYS_gettid); | |||||
if (ret < MMPA_ZERO) { | |||||
return EN_ERROR; | |||||
} | |||||
return ret; | |||||
} | |||||
INT32 mmAccess(const CHAR *path_name) { | |||||
if (path_name == NULL) { | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
INT32 ret = access(path_name, F_OK); | |||||
if (ret != EN_OK) { | |||||
return EN_ERROR; | |||||
} | |||||
return EN_OK; | |||||
} | |||||
INT32 mmStatGet(const CHAR *path, mmStat_t *buffer) { | |||||
if ((path == NULL) || (buffer == NULL)) { | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
INT32 ret = stat(path, buffer); | |||||
if (ret != EN_OK) { | |||||
return EN_ERROR; | |||||
} | |||||
return EN_OK; | |||||
} | |||||
INT32 mmGetFileSize(const CHAR *file_name, ULONGLONG *length) { | |||||
if ((file_name == NULL) || (length == NULL)) { | |||||
return EN_INVALID_PARAM; | |||||
} | |||||
struct stat file_stat; | |||||
(void)memset_s(&file_stat, sizeof(file_stat), 0, sizeof(file_stat)); // unsafe_function_ignore: memset | |||||
INT32 ret = lstat(file_name, &file_stat); | |||||
if (ret < MMPA_ZERO) { | |||||
return EN_ERROR; | |||||
} | |||||
*length = (ULONGLONG)file_stat.st_size; | |||||
return EN_OK; | |||||
} | |||||
INT32 mmScandir(const CHAR *path, mmDirent ***entryList, mmFilter filterFunc, mmSort sort) | |||||
{ | |||||
return 0; | |||||
} | |||||
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; | |||||
} | |||||
INT32 mmDlclose(VOID *handle) | |||||
{ | |||||
return 0; | |||||
} | |||||
CHAR *mmDlerror() | |||||
{ | |||||
return ""; | |||||
} | |||||
INT32 mmDladdr(VOID *addr, mmDlInfo *info) | |||||
{ | |||||
return 0; | |||||
} | |||||
VOID *mmDlopen(const CHAR *fileName, INT32 mode) | |||||
{ | |||||
return NULL; | |||||
} | |||||
VOID *mmDlsym(VOID *handle, const CHAR *funcName) | |||||
{ | |||||
return NULL; | |||||
} | |||||
INT32 mmGetPid() | |||||
{ | |||||
return (INT32)getpid(); | |||||
} | |||||
INT32 mmDup2(INT32 oldFd, INT32 newFd) { | |||||
return -1; | |||||
} | |||||
INT32 mmDup(INT32 fd) { | |||||
return -1; | |||||
} | |||||
@@ -0,0 +1,28 @@ | |||||
# 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(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(profiler_stub SHARED ${SRC_FILES}) | |||||
target_link_libraries(profiler_stub PRIVATE | |||||
$<BUILD_INTERFACE:intf_pub> | |||||
) |
@@ -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. | |||||
*/ | |||||
#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) | |||||
{ | |||||
return 0; | |||||
} | |||||
@@ -0,0 +1,26 @@ | |||||
# 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(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(slog_stub SHARED ${SRC_FILES}) | |||||
target_link_libraries(slog_stub PRIVATE | |||||
$<BUILD_INTERFACE:intf_pub> | |||||
) |
@@ -0,0 +1,48 @@ | |||||
/** | |||||
* 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 "toolchain/slog.h" | |||||
#include <stdarg.h> | |||||
#include <stdio.h> | |||||
#include <string.h> | |||||
void dav_log(int module_id, const char *fmt, ...) {} | |||||
void DlogErrorInner(int module_id, const char *fmt, ...) { dav_log(module_id, fmt); } | |||||
void DlogWarnInner(int module_id, const char *fmt, ...) { dav_log(module_id, fmt); } | |||||
void DlogInfoInner(int module_id, const char *fmt, ...) { dav_log(module_id, fmt); } | |||||
void DlogDebugInner(int module_id, const char *fmt, ...) { dav_log(module_id, fmt); } | |||||
void DlogEventInner(int module_id, const char *fmt, ...) { dav_log(module_id, fmt); } | |||||
void DlogInner(int module_id, int level, const char *fmt, ...) { dav_log(module_id, fmt); } | |||||
void DlogWithKVInner(int module_id, int level, KeyValue *pst_kv_array, int kv_num, const char *fmt, ...) { | |||||
dav_log(module_id, fmt); | |||||
} | |||||
int dlog_setlevel(int module_id, int level, int enable_event) { return DLOG_DEBUG; } | |||||
int dlog_getlevel(int module_id, int *enable_event) { return DLOG_DEBUG; } | |||||
int CheckLogLevel(int moduleId, int logLevel) | |||||
{ | |||||
return 1; | |||||
} |
@@ -0,0 +1,24 @@ | |||||
# 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. | |||||
# ============================================================================ | |||||
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}") | |||||
endif() | |||||
add_subdirectory(parser) | |||||
@@ -0,0 +1,345 @@ | |||||
# 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. | |||||
# ============================================================================ | |||||
project(ut_parser) | |||||
set(CMAKE_CXX_STANDARD 11) | |||||
################################################################################ | |||||
set(PARSER_PROTO_LIST | |||||
"${PARSER_DIR}/metadef/proto/om.proto" | |||||
"${PARSER_DIR}/metadef/proto/ge_ir.proto" | |||||
"${PARSER_DIR}/metadef/proto/task.proto" | |||||
"${PARSER_DIR}/metadef/proto/tensorflow/attr_value.proto" | |||||
"${PARSER_DIR}/metadef/proto/tensorflow/function.proto" | |||||
"${PARSER_DIR}/metadef/proto/tensorflow/graph.proto" | |||||
"${PARSER_DIR}/metadef/proto/tensorflow/graph_library.proto" | |||||
"${PARSER_DIR}/metadef/proto/tensorflow/node_def.proto" | |||||
"${PARSER_DIR}/metadef/proto/tensorflow/op_def.proto" | |||||
"${PARSER_DIR}/metadef/proto/tensorflow/resource_handle.proto" | |||||
"${PARSER_DIR}/metadef/proto/tensorflow/tensor.proto" | |||||
"${PARSER_DIR}/metadef/proto/tensorflow/tensor_shape.proto" | |||||
"${PARSER_DIR}/metadef/proto/tensorflow/types.proto" | |||||
"${PARSER_DIR}/metadef/proto/tensorflow/versions.proto" | |||||
"${PARSER_DIR}/metadef/proto/caffe/caffe.proto" | |||||
"${PARSER_DIR}/metadef/proto/onnx/ge_onnx.proto" | |||||
#"${PARSER_DIR}/metadef/proto/proto_inner/ge_onnx.proto" | |||||
) | |||||
protobuf_generate(ge PARSER_PROTO_SRCS PARSER_PROTO_HDRS ${PARSER_PROTO_LIST}) | |||||
############ libut_parser_proto.a ############ | |||||
add_library(ut_parser_proto STATIC | |||||
${PARSER_PROTO_HDRS} ${PARSER_PROTO_SRCS} | |||||
) | |||||
target_compile_definitions(ut_parser_proto PRIVATE | |||||
PROTOBUF_INLINE_NOT_IN_HEADERS=0 | |||||
google=ascend_private | |||||
) | |||||
target_compile_options(ut_parser_proto PRIVATE | |||||
-O2 -g -fno-common | |||||
) | |||||
target_link_libraries(ut_parser_proto PRIVATE | |||||
$<BUILD_INTERFACE:intf_pub> | |||||
ascend_protobuf | |||||
) | |||||
################################################################################ | |||||
set(DUPLICATE_PROTO_LIST | |||||
"${PARSER_DIR}/metadef/proto/proto_inner/ge_onnx.proto" | |||||
) | |||||
protobuf_generate(ge DUP_PROTO_SRCS DUP_PROTO_HDRS ${DUPLICATE_PROTO_LIST}) | |||||
################################################################################ | |||||
set(MATEDEF_SRC_FILES | |||||
"${PARSER_DIR}/metadef/graph/aligned_ptr.cc" | |||||
"${PARSER_DIR}/metadef/graph/anchor.cc" | |||||
"${PARSER_DIR}/metadef/graph/ascend_string.cc" | |||||
"${PARSER_DIR}/metadef/graph/attr_value.cc" | |||||
"${PARSER_DIR}/metadef/graph/buffer.cc" | |||||
"${PARSER_DIR}/metadef/graph/compute_graph.cc" | |||||
"${PARSER_DIR}/metadef/graph/debug/graph_debug.cc" | |||||
"${PARSER_DIR}/metadef/graph/detail/attributes_holder.cc" | |||||
"${PARSER_DIR}/metadef/graph/format_refiner.cc" | |||||
"${PARSER_DIR}/metadef/graph/ge_attr_define.cc" | |||||
"${PARSER_DIR}/metadef/graph/ge_attr_value.cc" | |||||
"${PARSER_DIR}/metadef/graph/ge_tensor.cc" | |||||
"${PARSER_DIR}/metadef/graph/gnode.cc" | |||||
"${PARSER_DIR}/metadef/graph/graph.cc" | |||||
"${PARSER_DIR}/metadef/graph/inference_context.cc" | |||||
"${PARSER_DIR}/metadef/graph/model.cc" | |||||
"${PARSER_DIR}/metadef/graph/model_serialize.cc" | |||||
"${PARSER_DIR}/metadef/graph/node.cc" | |||||
"${PARSER_DIR}/metadef/graph/op_desc.cc" | |||||
"${PARSER_DIR}/metadef/graph/operator.cc" | |||||
"${PARSER_DIR}/metadef/graph/operator_factory.cc" | |||||
"${PARSER_DIR}/metadef/graph/operator_factory_impl.cc" | |||||
"${PARSER_DIR}/metadef/graph/opsproto/opsproto_manager.cc" | |||||
"${PARSER_DIR}/metadef/graph/option/ge_context.cc" | |||||
"${PARSER_DIR}/metadef/graph/option/ge_local_context.cc" | |||||
"${PARSER_DIR}/metadef/graph/ref_relation.cc" | |||||
"${PARSER_DIR}/metadef/graph/runtime_inference_context.cc" | |||||
"${PARSER_DIR}/metadef/graph/shape_refiner.cc" | |||||
"${PARSER_DIR}/metadef/graph/tensor.cc" | |||||
"${PARSER_DIR}/metadef/graph/types.cc" | |||||
"${PARSER_DIR}/metadef/graph/utils/anchor_utils.cc" | |||||
"${PARSER_DIR}/metadef/graph/utils/ge_ir_utils.cc" | |||||
"${PARSER_DIR}/metadef/graph/utils/graph_utils.cc" | |||||
"${PARSER_DIR}/metadef/graph/utils/node_utils.cc" | |||||
"${PARSER_DIR}/metadef/graph/utils/op_desc_utils.cc" | |||||
"${PARSER_DIR}/metadef/graph/utils/tensor_utils.cc" | |||||
"${PARSER_DIR}/metadef/graph/utils/transformer_utils.cc" | |||||
"${PARSER_DIR}/metadef/graph/utils/tuning_utils.cc" | |||||
"${PARSER_DIR}/metadef/graph/utils/type_utils.cc" | |||||
"${PARSER_DIR}/metadef/ops/op_imp.cpp" | |||||
"${PARSER_DIR}/metadef/third_party/transformer/src/axis_util.cc" | |||||
"${PARSER_DIR}/metadef/third_party/transformer/src/expand_dimension.cc" | |||||
"${PARSER_DIR}/metadef/third_party/transformer/src/transfer_shape_according_to_format.cc" | |||||
) | |||||
# include directories | |||||
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) | |||||
############ libut_parser_graph.a ############ | |||||
add_library(ut_parser_graph STATIC | |||||
${MATEDEF_SRC_FILES} ${PARSER_PROTO_HDRS} ${DUP_PROTO_HDRS} | |||||
) | |||||
target_compile_definitions(ut_parser_graph PRIVATE | |||||
google=ascend_private | |||||
) | |||||
target_compile_options(ut_parser_graph PRIVATE | |||||
-O2 -g -fno-common | |||||
) | |||||
target_link_libraries(ut_parser_graph PRIVATE | |||||
$<BUILD_INTERFACE:intf_pub> | |||||
c_sec ascend_protobuf | |||||
) | |||||
################################################################################ | |||||
set(REGISTER_SRC_FILES | |||||
"${PARSER_DIR}/metadef/register/auto_mapping_util.cpp" | |||||
"${PARSER_DIR}/metadef/register/graph_optimizer/buffer_fusion/buffer_fusion_pass_base.cc" | |||||
"${PARSER_DIR}/metadef/register/graph_optimizer/buffer_fusion/buffer_fusion_pass_registry.cc" | |||||
"${PARSER_DIR}/metadef/register/graph_optimizer/buffer_fusion/buffer_fusion_pattern.cc" | |||||
"${PARSER_DIR}/metadef/register/graph_optimizer/fusion_statistic/fusion_statistic_recorder.cc" | |||||
"${PARSER_DIR}/metadef/register/graph_optimizer/graph_fusion/fusion_pass_registry.cc" | |||||
"${PARSER_DIR}/metadef/register/graph_optimizer/graph_fusion/fusion_pattern.cc" | |||||
"${PARSER_DIR}/metadef/register/graph_optimizer/graph_fusion/graph_fusion_pass_base.cc" | |||||
"${PARSER_DIR}/metadef/register/graph_optimizer/graph_fusion/pattern_fusion_base_pass.cc" | |||||
"${PARSER_DIR}/metadef/register/graph_optimizer/graph_fusion/pattern_fusion_base_pass_impl.cc" | |||||
"${PARSER_DIR}/metadef/register/host_cpu_context.cc" | |||||
"${PARSER_DIR}/metadef/register/infer_data_slice_registry.cc" | |||||
"${PARSER_DIR}/metadef/register/ops_kernel_builder_registry.cc" | |||||
"${PARSER_DIR}/metadef/register/op_kernel_registry.cpp" | |||||
"${PARSER_DIR}/metadef/register/op_tiling.cpp" | |||||
"${PARSER_DIR}/metadef/register/op_tiling_registry.cpp" | |||||
"${PARSER_DIR}/metadef/register/register.cpp" | |||||
"${PARSER_DIR}/metadef/register/register_format_transfer.cc" | |||||
"${PARSER_DIR}/metadef/register/register_pass.cpp" | |||||
"${PARSER_DIR}/metadef/register/scope/scope_graph.cc" | |||||
"${PARSER_DIR}/metadef/register/scope/scope_pass.cc" | |||||
"${PARSER_DIR}/metadef/register/scope/scope_pass_registry.cc" | |||||
"${PARSER_DIR}/metadef/register/scope/scope_pattern.cc" | |||||
"${PARSER_DIR}/metadef/register/scope/scope_util.cc" | |||||
"${PARSER_DIR}/metadef/register/tensor_assign.cpp" | |||||
) | |||||
# include directories | |||||
include_directories(${CMAKE_CURRENT_LIST_DIR}) | |||||
include_directories(${CMAKE_BINARY_DIR}/proto/ge) | |||||
include_directories(${PARSER_DIR}/metadef) | |||||
include_directories(${PARSER_DIR}/metadef/graph) | |||||
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 | |||||
${REGISTER_SRC_FILES} ${PARSER_PROTO_HDRS} | |||||
) | |||||
target_compile_definitions(ut_parser_register PRIVATE | |||||
google=ascend_private | |||||
) | |||||
target_compile_options(ut_parser_register PRIVATE | |||||
-O2 -g -fno-common | |||||
) | |||||
target_link_libraries(ut_parser_register PRIVATE | |||||
$<BUILD_INTERFACE:intf_pub> | |||||
c_sec ascend_protobuf json | |||||
) | |||||
################################################################################ | |||||
set(PARSER_SRC_FILES | |||||
"${PARSER_DIR}/parser/caffe/caffe_custom_parser_adapter.cc" | |||||
"${PARSER_DIR}/parser/caffe/caffe_data_parser.cc" | |||||
"${PARSER_DIR}/parser/caffe/caffe_op_parser.cc" | |||||
"${PARSER_DIR}/parser/caffe/caffe_parser.cc" | |||||
"${PARSER_DIR}/parser/caffe/caffe_reshape_parser.cc" | |||||
"${PARSER_DIR}/parser/common/acl_graph_parser_util.cc" | |||||
"${PARSER_DIR}/parser/common/convert/pb2json.cc" | |||||
"${PARSER_DIR}/parser/common/data_op_parser.cc" | |||||
"${PARSER_DIR}/parser/common/model_saver.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/arg_op.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/constant_op.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/defs.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/fill_op.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/frameworkop_op.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/ir_pb_converter.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/no_op_op.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/operator.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/op_schema.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/ref_switch_op.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/shape_n_op.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/variable_op.cc" | |||||
"${PARSER_DIR}/parser/common/op_def/var_is_initialized_op_op.cc" | |||||
"${PARSER_DIR}/parser/common/op_map.cc" | |||||
"${PARSER_DIR}/parser/common/op_parser_factory.cc" | |||||
"${PARSER_DIR}/parser/common/parser_api.cc" | |||||
"${PARSER_DIR}/parser/common/parser_factory.cc" | |||||
"${PARSER_DIR}/parser/common/parser_fp16_t.cc" | |||||
"${PARSER_DIR}/parser/common/parser_inner_ctx.cc" | |||||
"${PARSER_DIR}/parser/common/parser_types.cc" | |||||
"${PARSER_DIR}/parser/common/parser_utils.cc" | |||||
"${PARSER_DIR}/parser/common/pass_manager.cc" | |||||
"${PARSER_DIR}/parser/common/pre_checker.cc" | |||||
"${PARSER_DIR}/parser/common/proto_file_parser.cc" | |||||
"${PARSER_DIR}/parser/common/register_tbe.cc" | |||||
"${PARSER_DIR}/parser/common/tbe_plugin_loader.cc" | |||||
"${PARSER_DIR}/parser/common/thread_pool.cc" | |||||
"${PARSER_DIR}/parser/onnx/onnx_constant_parser.cc" | |||||
"${PARSER_DIR}/parser/onnx/onnx_custom_parser_adapter.cc" | |||||
"${PARSER_DIR}/parser/onnx/onnx_data_parser.cc" | |||||
"${PARSER_DIR}/parser/onnx/onnx_parser.cc" | |||||
"${PARSER_DIR}/parser/onnx/onnx_util.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/graph_functiondef.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/graph_optimizer.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/iterator_fusion_pass.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/scope/scope_pass_manager.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_arg_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_auto_mapping_parser_adapter.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_constant_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_custom_parser_adapter.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_data_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_enter_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_fill_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_frameworkop_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_fusionop_util.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_fusion_custom_parser_adapter.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_fusion_op_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_identity_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_merge_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_no_op_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_ref_switch_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_reshape_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_shape_n_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_squeeze_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_util.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_variable_v2_parser.cc" | |||||
"${PARSER_DIR}/parser/tensorflow/tensorflow_var_is_initialized_op_parser.cc" | |||||
) | |||||
# include directories | |||||
include_directories(${CMAKE_CURRENT_LIST_DIR}) | |||||
include_directories(${CMAKE_BINARY_DIR}/proto/ge) | |||||
include_directories(${PARSER_DIR}) | |||||
include_directories(${PARSER_DIR}/inc) | |||||
include_directories(${PARSER_DIR}/parser) | |||||
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 | |||||
"testcase/parser_unittest.cc" | |||||
) | |||||
############ libut_parser_common.a ############ | |||||
add_library(ut_parser_common STATIC | |||||
${PARSER_SRC_FILES} ${PARSER_PROTO_HDRS} | |||||
) | |||||
target_compile_definitions(ut_parser_common PRIVATE | |||||
google=ascend_private | |||||
) | |||||
target_compile_options(ut_parser_common PRIVATE | |||||
-g --coverage -fprofile-arcs -ftest-coverage | |||||
-Werror=format | |||||
) | |||||
target_link_libraries(ut_parser_common PRIVATE | |||||
$<BUILD_INTERFACE:intf_pub> | |||||
ut_parser_proto ut_parser_graph c_sec | |||||
ascend_protobuf | |||||
json | |||||
) | |||||
################################################################################ | |||||
add_executable(ut_parser | |||||
${PARSER_UT_FILES} ${PARSER_PROTO_SRCS} | |||||
) | |||||
target_compile_options(ut_parser PRIVATE | |||||
-g | |||||
) | |||||
target_compile_definitions(ut_parser PRIVATE | |||||
google=ascend_private | |||||
) | |||||
target_link_libraries(ut_parser | |||||
$<BUILD_INTERFACE:intf_pub> | |||||
ut_parser_proto | |||||
-Wl,--whole-archive ut_parser_common -Wl,--no-whole-archive | |||||
ut_parser_graph ut_parser_register error_manager_stub mmpa_stub | |||||
gtest gtest_main slog_stub ascend_protobuf c_sec -lrt -ldl -lgcov | |||||
) |
@@ -0,0 +1,37 @@ | |||||
/** | |||||
* 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> | |||||
#include <iostream> | |||||
#include "parser/common/op_parser_factory.h" | |||||
namespace ge { | |||||
class UtestParser : public testing::Test { | |||||
protected: | |||||
void SetUp() {} | |||||
void TearDown() {} | |||||
}; | |||||
TEST_F(UtestParser, base) { | |||||
std::shared_ptr<OpParserFactory> factory = OpParserFactory::Instance(domi::TENSORFLOW); | |||||
EXPECT_NE(factory, nullptr); | |||||
} | |||||
} // namespace ge |