| @@ -66,13 +66,14 @@ elseif(DEFINED ENV{D_LINK_PATH}) | |||
| endif() | |||
| set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) | |||
| find_library(slog libslog.so ${GE_LIB_PATH}) | |||
| find_library(mmpa libmmpa.so ${GE_LIB_PATH}) | |||
| find_library(mmpa libmmpa.a ${GE_LIB_PATH}) | |||
| find_library(runtime libruntime.so ${GE_LIB_PATH}) | |||
| find_library(msprof libmsprof.so ${GE_LIB_PATH}) | |||
| find_library(msprof libmsprofiler.a ${GE_LIB_PATH}) | |||
| find_library(register libregister.so ${GE_LIB_PATH}) | |||
| find_library(hccl libhccl.so ${GE_LIB_PATH}) | |||
| find_library(resource libresource.so ${GE_LIB_PATH}) | |||
| find_library(error_manager liberror_manager.so ${GE_LIB_PATH}) | |||
| find_library(adump_server libadump_server.a ${GE_LIB_PATH}) | |||
| else() | |||
| # Ascend mode | |||
| if(DEFINED ENV{ASCEND_CUSTOM_PATH}) | |||
| @@ -80,17 +81,18 @@ else() | |||
| else() | |||
| set(ASCEND_DIR /usr/local/Ascend) | |||
| endif() | |||
| set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64/common) | |||
| set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64) | |||
| set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64/common ${ASCEND_DIR}/driver/lib64) | |||
| set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64 ${ASCEND_DIR}/acllib/lib64 ${ASCEND_DIR}/atc/lib64) | |||
| find_library(slog libslog.so ${ASCEND_DRIVER_DIR}) | |||
| find_library(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) | |||
| find_library(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) | |||
| find_library(mmpa libmmpa.a ${ASCEND_RUNTIME_DIR}) | |||
| find_library(msprof libmsprofiler.a ${ASCEND_RUNTIME_DIR}) | |||
| find_library(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) | |||
| find_library(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) | |||
| find_library(register libregister.so ${ASCEND_RUNTIME_DIR}) | |||
| find_library(resource libresource.so ${ASCEND_RUNTIME_DIR}) | |||
| find_library(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) | |||
| find_library(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) | |||
| endif() | |||
| # add compile flags | |||
| @@ -1,10 +1,19 @@ | |||
| set(Eigen3_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") | |||
| set(Eigen3_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") | |||
| set(Eigen3_NS "ge_") | |||
| if (ENABLE_GITEE) | |||
| set(REQ_URL "https://gitee.com/mirrors/eigen-git-mirrorsource/repository/archive/3.3.7.tar.gz") | |||
| set(MD5 "cf6552a5d90c1aca4b5e0b011f65ea93") | |||
| else() | |||
| set(REQ_URL "https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz") | |||
| set(MD5 "9e30f67e8531477de4117506fe44669b") | |||
| endif () | |||
| graphengine_add_pkg(Eigen3 | |||
| VER 3.3.7 | |||
| URL https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz | |||
| MD5 9e30f67e8531477de4117506fe44669b | |||
| URL ${REQ_URL} | |||
| MD5 ${MD5} | |||
| CMAKE_OPTION -DBUILD_TESTING=OFF) | |||
| find_package(Eigen3 3.3.7 REQUIRED ${GE_FIND_NO_DEFAULT_PATH}) | |||
| @@ -1,11 +1,19 @@ | |||
| set(ge_gtest_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack") | |||
| set(ge_gtest_CFLAGS "-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack") | |||
| if (ENABLE_GITEE) | |||
| set(REQ_URL "https://gitee.com/mirrors/googletest/repository/archive/release-1.8.0.tar.gz") | |||
| set(MD5 "89e13ca1aa48d370719d58010b83f62c") | |||
| else() | |||
| set(REQ_URL "https://github.com/google/googletest/archive/release-1.8.0.tar.gz") | |||
| set(MD5 "16877098823401d1bf2ed7891d7dce36") | |||
| endif () | |||
| graphengine_add_pkg(ge_gtest | |||
| VER 1.8.0 | |||
| LIBS gtest gtest_main | |||
| URL https://github.com/google/googletest/archive/release-1.8.0.tar.gz | |||
| MD5 16877098823401d1bf2ed7891d7dce36 | |||
| URL ${REQ_URL} | |||
| MD5 ${MD5} | |||
| CMAKE_OPTION -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON | |||
| -DCMAKE_MACOSX_RPATH=TRUE -Dgtest_disable_pthreads=ON) | |||
| @@ -1,9 +1,20 @@ | |||
| set(nlohmann_json_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") | |||
| set(nlohmann_json_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") | |||
| if (ENABLE_GITEE) | |||
| set(REQ_URL "https://gitee.com/mirrors/JSON-for-Modern-CPP/repository/archive/v3.6.1.zip") | |||
| set(MD5 "5bda78ce308e6cfcf614dcf1d5ff27a7") | |||
| set(INCLUDE "./include") | |||
| else() | |||
| set(REQ_URL "https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip") | |||
| set(MD5 "0dc903888211db3a0f170304cd9f3a89") | |||
| set(INCLUDE "./") | |||
| endif () | |||
| graphengine_add_pkg(ge_nlohmann_json | |||
| VER 3.6.1 | |||
| HEAD_ONLY ./ | |||
| URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip | |||
| MD5 0dc903888211db3a0f170304cd9f3a89) | |||
| HEAD_ONLY ${INCLUDE} | |||
| URL ${REQ_URL} | |||
| MD5 ${MD5}) | |||
| include_directories(${ge_nlohmann_json_INC}) | |||
| add_library(graphengine::json ALIAS ge_nlohmann_json) | |||
| @@ -1,5 +1,13 @@ | |||
| if (ENABLE_GITEE) | |||
| set(REQ_URL "https://gitee.com/mirrors/ONNX/repository/archive/v1.6.0.tar.gz") | |||
| set(MD5 "1bdbcecdd68ea8392630467646776e02") | |||
| else() | |||
| set(REQ_URL "https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz") | |||
| set(MD5 "512f2779d6215d4a36f366b6b9acdf1e") | |||
| endif () | |||
| graphengine_add_pkg(onnx | |||
| VER 1.6.0 | |||
| HEAD_ONLY ./ | |||
| URL https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz | |||
| MD5 512f2779d6215d4a36f366b6b9acdf1e) | |||
| URL ${REQ_URL} | |||
| MD5 ${MD5}) | |||
| @@ -1,24 +1,40 @@ | |||
| if (NOT TARGET protobuf::protobuf) | |||
| set(protobuf_USE_STATIC_LIBS ON) | |||
| set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2") | |||
| set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") | |||
| if (NOT TARGET ge_protobuf::ascend_protobuf) | |||
| if (AS_MS_COMP) | |||
| set(protobuf_USE_STATIC_LIBS OFF) | |||
| set(protobuf_CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=ON -DLIB_PREFIX=ascend_ | |||
| -DCMAKE_C_FLAGS=\"-Dgoogle=ascend_private\" -DCMAKE_CXX_FLAGS=\"-Dgoogle=ascend_private\") | |||
| else () | |||
| set(protobuf_USE_STATIC_LIBS ON) | |||
| set(protobuf_CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -DLIB_PREFIX=ascend_) | |||
| endif () | |||
| set(ge_protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2 -D_GLIBCXX_USE_CXX11_ABI=0") | |||
| set(ge_protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") | |||
| set(_ge_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) | |||
| string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | |||
| string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | |||
| graphengine_add_pkg(protobuf | |||
| if (ENABLE_GITEE) | |||
| set(REQ_URL "https://gitee.com/mirrors/protobuf_source/repository/archive/v3.8.0.tar.gz") | |||
| set(MD5 "eba86ae9f07ba5cfbaf8af3bc4e84236") | |||
| else() | |||
| set(REQ_URL "https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz") | |||
| set(MD5 "3d9e32700639618a4d2d342c99d4507a") | |||
| endif () | |||
| graphengine_add_pkg(ge_protobuf | |||
| VER 3.8.0 | |||
| LIBS protobuf | |||
| LIBS ascend_protobuf | |||
| EXE protoc | |||
| URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz | |||
| MD5 3d9e32700639618a4d2d342c99d4507a | |||
| URL ${REQ_URL} | |||
| MD5 ${MD5} | |||
| CMAKE_PATH ../cmake/ | |||
| CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF) | |||
| CMAKE_OPTION ${protobuf_CMAKE_OPTION}) | |||
| set(CMAKE_CXX_FLAGS ${_ge_tmp_CMAKE_CXX_FLAGS}) | |||
| endif() | |||
| add_library(graphengine::protobuf ALIAS protobuf::protobuf) | |||
| set(PROTOBUF_LIBRARY protobuf::protobuf) | |||
| include_directories(${protobuf_INC}) | |||
| include_directories(${protobuf_DIRPATH}/src) | |||
| add_library(graphengine::protobuf ALIAS ge_protobuf::ascend_protobuf) | |||
| set(PROTOBUF_LIBRARY ge_protobuf::ascend_protobuf) | |||
| include_directories(${ge_protobuf_INC}) | |||
| include_directories(${ge_protobuf_DIRPATH}/src) | |||
| function(ge_protobuf_generate comp c_var h_var) | |||
| if(NOT ARGN) | |||
| @@ -42,8 +58,8 @@ function(ge_protobuf_generate comp c_var h_var) | |||
| "${CMAKE_BINARY_DIR}/proto/${comp}/proto/${file_name}.pb.h" | |||
| WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |||
| COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto/${comp}/proto" | |||
| COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto/${comp}/proto ${abs_file} | |||
| DEPENDS protobuf::protoc ${abs_file} | |||
| COMMAND ge_protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto/${comp}/proto ${abs_file} | |||
| DEPENDS ge_protobuf::protoc ${abs_file} | |||
| COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM ) | |||
| endforeach() | |||
| @@ -1,7 +1,7 @@ | |||
| graphengine_add_pkg(securec | |||
| VER 1.1.10 | |||
| URL https://gitee.com/openeuler/bounds_checking_function/repository/archive/v1.1.10.tar.gz | |||
| MD5 0782dd2351fde6920d31a599b23d8c91 | |||
| URL https://gitee.com/openeuler/libboundscheck/repository/archive/v1.1.10.tar.gz | |||
| MD5 193f0ca5246c1dd84920db34d2d8249f | |||
| LIBS c_sec | |||
| PATCHES ${GE_SOURCE_DIR}/third_party/patch/securec/securec.patch001 | |||
| CMAKE_OPTION "-DCMAKE_BUILD_TYPE=Release" | |||
| @@ -112,7 +112,9 @@ function(__find_pkg_then_add_target pkg_name pkg_exe) | |||
| if(NOT ${pkg_exe}_EXE) | |||
| return() | |||
| endif() | |||
| add_executable(${pkg_name}::${pkg_exe} IMPORTED GLOBAL) | |||
| if (NOT TARGET ${pkg_name}::${pkg_exe}) | |||
| add_executable(${pkg_name}::${pkg_exe} IMPORTED GLOBAL) | |||
| endif () | |||
| set_target_properties(${pkg_name}::${pkg_exe} PROPERTIES | |||
| IMPORTED_LOCATION ${${pkg_exe}_EXE} | |||
| ) | |||
| @@ -0,0 +1,51 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_COMMON_OPSKERNELUTILS_OPS_KERNEL_INFO_UTILS_H_ | |||
| #define INC_COMMON_OPSKERNELUTILS_OPS_KERNEL_INFO_UTILS_H_ | |||
| #include "external/ge/ge_api_error_codes.h" | |||
| #include "cce/aicpu_engine_struct.h" | |||
| #include "common/opskernel/ops_kernel_info_types.h" | |||
| #include "graph/node.h" | |||
| #include "proto/task.pb.h" | |||
| namespace ge { | |||
| class OpsKernelBuilder { | |||
| public: | |||
| OpsKernelBuilder() = default; | |||
| virtual ~OpsKernelBuilder() = default; | |||
| // initialize OpsKernelBuilder | |||
| virtual Status Initialize(const std::map<std::string, std::string> &options) = 0; | |||
| // finalize OpsKernelBuilder | |||
| virtual Status Finalize() = 0; | |||
| // memory allocation requirement | |||
| virtual Status CalcOpRunningParam(Node &node) = 0; | |||
| // generate task for op | |||
| virtual Status GenerateTask(const Node &node, RunContext &context, std::vector<domi::TaskDef> &tasks) = 0; | |||
| // only call aicpu interface to generate task struct | |||
| virtual Status GenSingleOpRunTask(const NodePtr &node, STR_FWK_OP_KERNEL &task, string &task_info) { return FAILED; } | |||
| // only call aicpu interface to generate task struct | |||
| virtual Status GenMemCopyTask(uint64_t count, STR_FWK_OP_KERNEL &task, string &task_info) { return FAILED; } | |||
| }; | |||
| } // namespace ge | |||
| #endif // INC_COMMON_OPSKERNELUTILS_OPS_KERNEL_INFO_UTILS_H_ | |||
| @@ -43,10 +43,10 @@ class OpsKernelInfoStore { | |||
| virtual ~OpsKernelInfoStore() {} | |||
| // initialize opsKernelInfoStore | |||
| virtual Status Initialize(const map<string, string> &options) = 0; /*lint -e148*/ | |||
| virtual Status Initialize(const map<string, string> &options) = 0; | |||
| // close opsKernelInfoStore | |||
| virtual Status Finalize() = 0; /*lint -e148*/ | |||
| virtual Status Finalize() = 0; | |||
| virtual Status CreateSession(const std::map<std::string, std::string> &session_options) { return SUCCESS; } | |||
| @@ -65,24 +65,11 @@ class OpsKernelInfoStore { | |||
| // opsFlag opsFlag[0] indicates constant folding is supported or not | |||
| virtual void opsFlagCheck(const ge::Node &node, std::string &opsFlag){}; | |||
| // memory allocation requirement | |||
| virtual Status CalcOpRunningParam(Node &node) = 0; /*lint -e148*/ | |||
| // generate task for op。 | |||
| virtual Status GenerateTask(const Node &node, RunContext &context, | |||
| std::vector<domi::TaskDef> &tasks) = 0; /*lint -e148*/ | |||
| // only call fe engine interface to compile single op | |||
| virtual Status CompileOp(vector<ge::NodePtr> &node_vec) { return SUCCESS; } | |||
| virtual Status CompileOpRun(vector<ge::NodePtr> &node_vec) { return SUCCESS; } | |||
| // load task for op | |||
| virtual Status LoadTask(GETaskInfo &task) { return SUCCESS; } | |||
| // only call aicpu interface to generate task struct | |||
| virtual Status GenSingleOpRunTask(const NodePtr &node, STR_FWK_OP_KERNEL &task, string &task_info) { return SUCCESS; } | |||
| // only call aicpu interface to generate task struct | |||
| virtual Status GenMemCopyTask(uint64_t count, STR_FWK_OP_KERNEL &task, string &task_info) { return SUCCESS; } | |||
| }; | |||
| } // namespace ge | |||
| #endif // INC_COMMON_OPSKERNEL_OPS_KERNEL_INFO_STORE_H_ | |||
| @@ -26,13 +26,14 @@ | |||
| using std::string; | |||
| namespace ge { | |||
| /*lint -e148*/ | |||
| struct RunContext { | |||
| rtModel_t model; | |||
| rtStream_t stream; | |||
| uint64_t sessionId; | |||
| uint64_t dataMemSize; | |||
| uint8_t *dataMemBase; | |||
| std::map<int64_t, uint64_t> mem_type_data_mem_size; | |||
| std::map<int64_t, uint8_t *> mem_type_data_mem_base; | |||
| uint64_t weightMemSize; | |||
| uint8_t *weightMemBase; | |||
| ge::Buffer weightsBuffer; | |||
| @@ -41,8 +42,6 @@ struct RunContext { | |||
| std::vector<rtLabel_t> graphLabelList; // all labels of graph, order by ge label id(0,1,...) | |||
| }; | |||
| /*lint +e148*/ | |||
| struct Task { | |||
| uint32_t id; | |||
| uint16_t type; | |||
| @@ -51,8 +50,7 @@ struct Task { | |||
| }; | |||
| struct OpInfo { | |||
| string engine; // which engin | |||
| /*lint -e148*/ | |||
| string engine; // which engin | |||
| string opKernelLib; // which opsKernelStore | |||
| int computeCost; // compute cost | |||
| bool flagPartial; // whether to support is related to shape | |||
| @@ -27,7 +27,6 @@ | |||
| using std::map; | |||
| using std::string; | |||
| /*lint -e148*/ | |||
| namespace ge { | |||
| class GraphOptimizer { | |||
| public: | |||
| @@ -67,5 +66,4 @@ class GraphOptimizer { | |||
| virtual Status OptimizeFusedGraphAfterGraphSlice(ComputeGraph &graph) { return SUCCESS; } | |||
| }; | |||
| } // namespace ge | |||
| /*lint +e148*/ | |||
| #endif // INC_COMMON_OPTIMIZER_GRAPH_OPTIMIZER_H_ | |||
| @@ -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. | |||
| */ | |||
| #ifndef AICORE_UTIL_MANAGER_H_ | |||
| #define AICORE_UTIL_MANAGER_H_ | |||
| #include <string> | |||
| #include "register/graph_optimizer/graph_optimize_register_error_codes.h" | |||
| namespace fe { | |||
| class AICoreUtilManager { | |||
| public: | |||
| static AICoreUtilManager &Instance(); | |||
| /* | |||
| * to initialize the aicore configuration | |||
| * param[in] the options of init | |||
| * param[in] engine Name | |||
| * param[in] socVersion soc version from ge | |||
| * return Status(SUCCESS/FAILED) | |||
| */ | |||
| Status Initialize(const std::map<std::string, std::string> &options, std::string &soc_version); | |||
| /* | |||
| * to release the source of fusion manager | |||
| * return Status(SUCCESS/FAILED) | |||
| */ | |||
| Status Finalize(); | |||
| private: | |||
| AICoreUtilManager(); | |||
| ~AICoreUtilManager(); | |||
| bool is_init_; | |||
| }; | |||
| } // namespace fe | |||
| #endif // AICORE_UTIL_MANAGER_H | |||
| @@ -36,6 +36,14 @@ static const std::string L1_OPTIMIZED = "l1_optimized"; | |||
| static const std::string L2_OPTIMIZED = "l2_optimized"; | |||
| static const std::string OP_SLICE_INFO = "_op_slice_info"; | |||
| static const std::string ATTR_NAME_UNKNOWN_SHAPE = "_unknown_shape"; | |||
| static const std::string ATTR_NAME_IS_UNKNOWN_GRAPH = "_fe_is_unknown_graph"; | |||
| static const std::string ATTR_NAME_IS_UNKNOWN_SHAPE_OP = "_fe_is_unknown_shape_op"; | |||
| static const std::string ATTR_NAME_TVM_CACHE_READ_MODE = "tvm_cache_read_mode"; | |||
| static const std::string ATTR_NAME_TBE_KERNEL_SIZE = "_tbeKernelSize"; | |||
| } // namespace fe | |||
| #endif | |||
| @@ -0,0 +1,54 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_COMMON_UTILS_AI_CORE_COMMON_CONSTANTS_H_ | |||
| #define INC_COMMON_UTILS_AI_CORE_COMMON_CONSTANTS_H_ | |||
| #include <string> | |||
| namespace fe { | |||
| static const std::string CORE_TYPE = "_coretype"; | |||
| /* engine name of AI core and vector core */ | |||
| static const std::string AI_CORE_NAME = "AIcoreEngine"; | |||
| static const std::string VECTOR_CORE_NAME = "VectorEngine"; | |||
| static const int64_t IS_UNKNOWN_SHAPE_VALUE = 1; | |||
| static const int64_t SHAPE_UNKNOWN_DIM = -1; | |||
| static const int64_t SHAPE_UNKNOWN_DIM_NUM = -2; | |||
| static const std::string SOC_VERSION_ASCEND310 = "Ascend310"; | |||
| static const std::string SOC_VERSION_ASCEND610 = "Ascend610"; | |||
| static const std::string SOC_VERSION_ASCEND615 = "Ascend615"; | |||
| static const std::string SOC_VERSION_ASCEND710 = "Ascend710"; | |||
| static const std::string SOC_VERSION_ASCEND710P = "Ascend710Pro"; | |||
| static const std::string SOC_VERSION_ASCEND910A = "Ascend910A"; | |||
| static const std::string SOC_VERSION_ASCEND910B = "Ascend910B"; | |||
| static const std::string SOC_VERSION_ASCEND910PROA = "Ascend910ProA"; | |||
| static const std::string SOC_VERSION_ASCEND910PROB = "Ascend910ProB"; | |||
| static const std::string SOC_VERSION_ASCEND910PREMIUMA = "Ascend910PremiumA"; | |||
| static const std::string SOC_VERSION_HI3796CV300ES = "Hi3796CV300ES"; | |||
| static const std::string SOC_VERSION_HI3796CV300CS = "Hi3796CV300CS"; | |||
| static const std::vector<std::string> SOC_VERSION_CLOUD_LIST = {SOC_VERSION_ASCEND910A, SOC_VERSION_ASCEND910B, | |||
| SOC_VERSION_ASCEND910PROA, SOC_VERSION_ASCEND910PROB, | |||
| SOC_VERSION_ASCEND910PREMIUMA}; | |||
| static const std::vector<std::string> SOC_VERSION_DC_LIST = {SOC_VERSION_ASCEND610, SOC_VERSION_ASCEND615, | |||
| SOC_VERSION_ASCEND710, SOC_VERSION_ASCEND710P}; | |||
| } // namespace fe | |||
| #endif | |||
| @@ -42,47 +42,61 @@ struct FusionDataFlow { | |||
| std::pair<std::string, ge::AnchorPtr> node_dataindex_pair; | |||
| }; | |||
| typedef struct tagL2FusionData { | |||
| typedef struct tag_l2_fusion_data { | |||
| uint32_t l2Index; | |||
| uint64_t l2Addr; | |||
| uint64_t l2PageNum; | |||
| } L2FusionData_t; | |||
| typedef std::map<uint64_t, L2FusionData_t> L2FusionDataMap_t; | |||
| typedef struct tagFeSmDesc { | |||
| typedef struct tag_fe_sm_desc { | |||
| rtL2Ctrl_t l2ctrl; | |||
| std::string nodeName[8]; | |||
| uint8_t outputIndex[8]; | |||
| } feSmDesc_t; | |||
| std::string node_name[8]; | |||
| uint8_t output_index[8]; | |||
| } fe_sm_desc_t; | |||
| typedef struct TagTaskL2FusionInfo { | |||
| std::string nodeName; | |||
| feSmDesc_t l2Info; | |||
| std::string node_name; | |||
| fe_sm_desc_t l2_info; | |||
| L2FusionDataMap_t input; | |||
| L2FusionDataMap_t output; | |||
| uint32_t isUsed; | |||
| uint32_t is_used; | |||
| } TaskL2FusionInfo_t; | |||
| using L2FusionInfoPtr = std::shared_ptr<TaskL2FusionInfo_t>; | |||
| typedef struct ToOpStruct { | |||
| int64_t opL1Space = 0; | |||
| std::vector<int64_t> opL1FusionType; | |||
| int64_t opL1WorkspaceFlag = 0; // for workspace flag | |||
| int64_t opL1WorkspaceSize = 0; | |||
| std::vector<std::vector<int64_t>> validInputShape; | |||
| std::vector<std::vector<int64_t>> validOutputShape; | |||
| std::vector<std::vector<int64_t>> sliceInputOffset; // conv & pooling & ReadSelect | |||
| std::vector<std::vector<int64_t>> sliceOutputOffset; // WriteSelect | |||
| std::vector<uint32_t> totalShape; | |||
| uint32_t splitIndex = 0; | |||
| int64_t op_l1_space = 0; | |||
| std::vector<int64_t> op_l1_fusion_type; | |||
| int64_t op_l1_workspace_flag = 0; // for workspace flag | |||
| int64_t op_l1_workspace_size = 0; | |||
| std::vector<std::vector<int64_t>> valid_input_shape; | |||
| std::vector<std::vector<int64_t>> valid_output_shape; | |||
| std::vector<std::vector<int64_t>> slice_input_offset; // conv & pooling & ReadSelect | |||
| std::vector<std::vector<int64_t>> slice_output_offset; // WriteSelect | |||
| std::vector<uint32_t> total_shape; | |||
| uint32_t split_index = 0; | |||
| ToOpStruct() { | |||
| // set invalid value for essential variable | |||
| opL1Space = -1; | |||
| opL1WorkspaceSize = -1; | |||
| op_l1_space = -1; | |||
| op_l1_workspace_size = -1; | |||
| } | |||
| } ToOpStruct_t; | |||
| enum SlicePattern { | |||
| ELEMENT_WISE = 0, | |||
| ELEMENT_WISE_BROADCAST, | |||
| BROADCAST, | |||
| SLIDING_WINDOW, | |||
| SLIDING_WINDOW_DECONV, | |||
| CUBE_MATMUL, | |||
| SLICE_PATTERN_REDUCE, | |||
| SLICE_PATTERN_RESIZE, | |||
| SLICE_PATTERN_SCATTER, | |||
| SLICE_PATTERN_SEGMENT, | |||
| PATTERN_RESERVED | |||
| }; | |||
| enum OpImplType { | |||
| EN_IMPL_CUSTOM_CONSTANT_CCE = 0, // custom constant op | |||
| EN_IMPL_CUSTOM_TIK, // custom tik op | |||
| @@ -99,6 +113,10 @@ enum OpImplType { | |||
| EN_RESERVED // reserved value | |||
| }; | |||
| // Dont change the order, only add new mode in the end | |||
| enum L2Mode { EN_L2_CLOSE = 0, EN_L2_BUFFER_OPTIMIZE, EN_L2_CACHE_NORMAL, EN_L2_CACHE_RC }; | |||
| enum BufferFusionMode { EN_OPTIMIZE_DISABLE = 0, EN_L2_BUFFER, EN_L2_FUSION }; | |||
| static const std::map<ge::DataType, uint32_t> DATATYPE_SIZE_MAP{{ge::DT_FLOAT, sizeof(float)}, | |||
| {ge::DT_FLOAT16, sizeof(int16_t)}, | |||
| {ge::DT_INT8, sizeof(int8_t)}, | |||
| @@ -114,5 +132,13 @@ static const std::map<ge::DataType, uint32_t> DATATYPE_SIZE_MAP{{ge::DT_FLOAT, s | |||
| {ge::DT_DUAL, sizeof(float) + sizeof(int8_t)}, | |||
| {ge::DT_DUAL_SUB_UINT8, sizeof(int8_t)}, | |||
| {ge::DT_DUAL_SUB_INT8, sizeof(int8_t)}}; | |||
| enum OpReduceType { | |||
| REDUCE_MEAN = 0, | |||
| REDUCE_ADD, | |||
| REDUCE_MAX, | |||
| REDUCE_MIN, | |||
| }; | |||
| } // namespace fe | |||
| #endif | |||
| @@ -28,33 +28,34 @@ | |||
| namespace fe { | |||
| using kScopeNodeMap_t = std::map<int64_t, std::vector<ge::NodePtr>>; | |||
| using kScopeNodePair_t = std::pair<int64_t, std::vector<ge::NodePtr>>; | |||
| using k_scope_node_map_t = std::map<int64_t, std::vector<ge::NodePtr>>; | |||
| using k_scope_node_pair_t = std::pair<int64_t, std::vector<ge::NodePtr>>; | |||
| class GraphCommImpl; | |||
| using GraphCommImplPtr = std::unique_ptr<GraphCommImpl>; | |||
| class GraphComm { | |||
| public: | |||
| GraphComm(const string &engineName); | |||
| GraphComm(const string &engine_name); | |||
| virtual ~GraphComm(); | |||
| GraphComm(const GraphComm &in) = delete; | |||
| GraphComm &operator=(const GraphComm &in) = delete; | |||
| Status GetscopeNodeMap(ge::ComputeGraph &graph, kScopeNodeMap_t &fusionMap); | |||
| Status GetscopeNodeMap(ge::ComputeGraph &graph, k_scope_node_map_t &fusion_map); | |||
| Status CopyFusionOpNodes(vector<FusionDataFlow> &fusInputEdgeList, vector<FusionDataFlow> &fusOutputEdgeList, | |||
| vector<ge::NodePtr> &fusNodelist, ge::OpDescPtr fusionOpDesc, | |||
| ge::ComputeGraphPtr fusionGraph); | |||
| Status CopyFusionOpNodes(vector<FusionDataFlow> &fus_input_edge_list, vector<FusionDataFlow> &fus_output_edge_list, | |||
| vector<ge::NodePtr> &fus_nodelist, ge::OpDescPtr fusion_op_desc, | |||
| ge::ComputeGraphPtr fusion_graph); | |||
| Status CopyFusionOpEdges(ge::OpDescPtr fusionOpDesc, ge::ComputeGraph &origGraph, ge::ComputeGraphPtr fusionGraph); | |||
| Status CopyFusionOpEdges(ge::OpDescPtr fusion_op_desc, ge::ComputeGraph &orig_graph, | |||
| ge::ComputeGraphPtr fusion_graph); | |||
| Status GetNodeDataFlowMap(const ge::NodePtr &fusNode, | |||
| std::map<ge::NodePtr, std::map<ge::AnchorPtr, ge::AnchorPtr>> &fusionOpAnchorsMap, | |||
| ge::kFusionDataFlowVec_t &fusDataflowList, const int &mapType); | |||
| Status GetNodeDataFlowMap(const ge::NodePtr &fus_node, | |||
| std::map<ge::NodePtr, std::map<ge::AnchorPtr, ge::AnchorPtr>> &fusion_op_anchors_map, | |||
| ge::kFusionDataFlowVec_t &fus_dataflow_list, const int &map_type); | |||
| Status GetFusionNodeEdgeList(std::vector<ge::NodePtr> &fusNodelist, std::vector<FusionDataFlow> &fusInputEdgeList, | |||
| std::vector<FusionDataFlow> &fusOutputEdgeList); | |||
| Status GetFusionNodeEdgeList(std::vector<ge::NodePtr> &fus_nodelist, std::vector<FusionDataFlow> &fus_input_edge_list, | |||
| std::vector<FusionDataFlow> &fus_output_edge_list); | |||
| void ClearFusionSrc(); | |||
| void ClearFusionDst(); | |||
| @@ -72,25 +73,26 @@ class GraphComm { | |||
| bool GetFusionSrc(const uint32_t &src_op_id, const ge::AnchorPtr &src_anchor, int32_t &fusion_src_index, | |||
| int32_t &fusion_dst_index); | |||
| Status GetFusionNodeCtrlEdgeList(vector<ge::NodePtr> &fusNodelist, vector<FusionDataFlow> &fusInputCtrlEdgeList, | |||
| vector<FusionDataFlow> &fusOutputCtrlEdgeList); | |||
| Status GetFusionNodeCtrlEdgeList(vector<ge::NodePtr> &fus_nodelist, vector<FusionDataFlow> &fus_input_ctrl_edge_list, | |||
| vector<FusionDataFlow> &fus_output_ctrl_edge_list); | |||
| Status MergeFusionNodeEdgeList(ge::NodePtr &fusNode, vector<ge::NodePtr> &fusNodelist, | |||
| vector<FusionDataFlow> &fusInputEdgeList, vector<FusionDataFlow> &fusOutputEdgeList); | |||
| Status MergeFusionNodeEdgeList(ge::NodePtr &fus_node, vector<ge::NodePtr> &fus_nodelist, | |||
| vector<FusionDataFlow> &fus_input_edge_list, | |||
| vector<FusionDataFlow> &fus_output_edge_list); | |||
| Status MergeFusionNodeCtrlEdgeList(ge::NodePtr &fusNode, vector<ge::NodePtr> &fusNodelist, | |||
| vector<FusionDataFlow> &fusInputEdgeList, | |||
| vector<FusionDataFlow> &fusOutputEdgeList); | |||
| Status MergeFusionNodeCtrlEdgeList(ge::NodePtr &fus_node, vector<ge::NodePtr> &fus_nodelist, | |||
| vector<FusionDataFlow> &fus_input_edge_list, | |||
| vector<FusionDataFlow> &fus_output_edge_list); | |||
| string GetEngineName(); | |||
| private: | |||
| Status MergeFusionNodeInputEdgeList(ge::NodePtr fusNode, std::vector<ge::NodePtr> &fusNodelist, | |||
| std::vector<FusionDataFlow> &fusInputEdgeList); | |||
| Status MergeFusionNodeOutputEdgeList(ge::NodePtr fusNode, std::vector<ge::NodePtr> &fusNodelist, | |||
| std::vector<FusionDataFlow> &fusOutputEdgeList); | |||
| Status MergeFusionNodeInputEdgeList(ge::NodePtr fus_node, std::vector<ge::NodePtr> &fus_nodelist, | |||
| std::vector<FusionDataFlow> &fus_input_edge_list); | |||
| Status MergeFusionNodeOutputEdgeList(ge::NodePtr fus_node, std::vector<ge::NodePtr> &fus_nodelist, | |||
| std::vector<FusionDataFlow> &fus_output_edge_list); | |||
| string engineName_; | |||
| string engine_name_; | |||
| std::vector<FusionOpSrc> exist_fusion_src_list_; | |||
| std::vector<FusionOpDst> exist_fusion_dst_list_; | |||
| @@ -101,7 +103,7 @@ class GraphComm { | |||
| // std::vector<std::multimap<std::string, ge::AnchorPtr>> | |||
| ge::kFusionDataFlowVec_t fusion_output_dataflow_list_; | |||
| GraphCommImplPtr graphCommImplPtr_; | |||
| GraphCommImplPtr graph_comm_impl_ptr_; | |||
| }; | |||
| } // namespace fe | |||
| #endif | |||
| @@ -0,0 +1,54 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef PROJECT_JSON_UTIL_H | |||
| #define PROJECT_JSON_UTIL_H | |||
| #include "graph/compute_graph.h" | |||
| #include "common/aicore_util_types.h" | |||
| #include "fusion_engine/graph_tuner/graph_tuner_errorcode.h" | |||
| const std::string L1_FUSION_EXTEND_CONTENT = "_l1_fusion_extend_content"; | |||
| const std::string L2_FUSION_EXTEND_CONTENT = "l2_fusion_extend_content"; | |||
| const std::string TASK_L2_FUSION_INFO_EXTEND_CONTENT = "task_l2_fusion_info_extend_content"; | |||
| const std::string L1_FUSION_TO_OP_STRUCT = "_l1fusion_ToOpStruct"; | |||
| const std::string L2_FUSION_TO_OP_STRUCT = "_l2fusion_ToOpStruct"; | |||
| const std::string TASK_L2_FUSION_INFO = "_task_L2FusionInfo"; | |||
| namespace tune { | |||
| using ToOpStructPtr = std::shared_ptr<fe::ToOpStruct_t>; | |||
| using L2FusionInfoPtr = std::shared_ptr<fe::TaskL2FusionInfo_t>; | |||
| Status GetL1InfoFromJson(ge::OpDescPtr opDescPtr); | |||
| Status GetL2InfoFromJson(ge::OpDescPtr opDescPtr); | |||
| Status GetTaskL2FusionInfoFromJson(ge::OpDescPtr opDescPtr); | |||
| Status ReadGraphInfoFromJson(ge::ComputeGraph &graph); | |||
| Status WriteGraphInfoToJson(ge::ComputeGraph &graph); | |||
| void GetL2ToOpStructFromJson(ge::OpDescPtr &opDescPtr, ToOpStructPtr &l2InfoPtr); | |||
| void GetL1ToOpStructFromJson(ge::OpDescPtr &opDescPtr, ToOpStructPtr &l1InfoPtr); | |||
| L2FusionInfoPtr GetL2FusionInfoFromJson(ge::OpDescPtr &opDescPtr); | |||
| void SetL2FusionInfoToNode(ge::OpDescPtr &opDescPtr, L2FusionInfoPtr &l2FusionInfoPtr); | |||
| } // namespace tune | |||
| #endif // PROJECT_JSON_UTIL_H | |||
| @@ -0,0 +1,44 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef L2_STREAM_INFO_H_ | |||
| #define L2_STREAM_INFO_H_ | |||
| #include <map> | |||
| #include <string> | |||
| #include <mutex> | |||
| #include "register/graph_optimizer/graph_optimize_register_error_codes.h" | |||
| #include "runtime/base.h" | |||
| #include "cce/l2fusion_struct.hpp" | |||
| namespace fe { | |||
| class StreamL2Info { | |||
| public: | |||
| StreamL2Info(const StreamL2Info &) = delete; | |||
| StreamL2Info &operator=(const StreamL2Info &) = delete; | |||
| static StreamL2Info &Instance(); | |||
| Status GetStreamL2Info(rtStream_t stream_id, string node_name, fusion::TaskL2Info_t *&l2_data); | |||
| Status SetStreamL2Info(const rtStream_t &stream_id, fusion::TaskL2InfoFEMap_t &l2_alloc_res); | |||
| private: | |||
| StreamL2Info(); | |||
| ~StreamL2Info(); | |||
| mutable std::mutex stream_l2_mutex_; | |||
| std::map<rtStream_t, fusion::TaskL2InfoFEMap_t> stream_l2_map_; | |||
| }; | |||
| } // namespace fe | |||
| #endif // L2_STREAM_INFO_H_ | |||
| @@ -32,12 +32,12 @@ class ScopeAllocator { | |||
| int64_t GetCurrentScopeId(); | |||
| int64_t AllocateScopeId(void); | |||
| bool HasScopeAttr(ge::ConstOpDescPtr opdef); | |||
| bool GetScopeAttr(ge::ConstOpDescPtr opdef, int64_t& scopeId); | |||
| bool SetScopeAttr(ge::OpDescPtr opdef, int64_t scopeId); | |||
| bool ResetScopeId(int64_t scopeId); | |||
| bool GetScopeAttr(ge::ConstOpDescPtr opdef, int64_t& scope_id); | |||
| bool SetScopeAttr(ge::OpDescPtr opdef, int64_t scope_id); | |||
| bool ResetScopeId(int64_t scope_id); | |||
| private: | |||
| int64_t scopeId; | |||
| int64_t scope_id; | |||
| }; | |||
| } // namespace fe | |||
| #endif | |||
| @@ -29,16 +29,16 @@ class TensorSizeCalculator { | |||
| public: | |||
| /** | |||
| * Calculate the tensor size of input and output of each opdesc | |||
| * @param opDesc opdesc object | |||
| * @param opImplType op impl type | |||
| * @param op_desc opdesc object | |||
| * @param op_impl_type op impl type | |||
| * @return status SUCCESS or FAILED | |||
| */ | |||
| static Status CalculateOpTensorSize(ge::OpDesc &opDesc); | |||
| static Status CalculateOpTensorSize(ge::OpDesc &op_desc); | |||
| private: | |||
| static Status CalcInputOpTensorSize(ge::OpDesc &opDesc, int32_t &outputRealCalcFlag); | |||
| static Status CalcInputOpTensorSize(ge::OpDesc &op_desc, int32_t &output_real_calc_flag); | |||
| static Status CalcOutputOpTensorSize(ge::OpDesc &opDesc, int32_t &outputRealCalcFlag); | |||
| static Status CalcOutputOpTensorSize(ge::OpDesc &op_desc, int32_t &output_real_calc_flag); | |||
| }; | |||
| } // namespace fe | |||
| @@ -20,6 +20,7 @@ | |||
| #include <map> | |||
| #include <string> | |||
| #include <vector> | |||
| #include <mutex> | |||
| class ErrorManager { | |||
| public: | |||
| @@ -66,6 +67,28 @@ class ErrorManager { | |||
| void 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 ReportMstuneCompileFailedMsg(const std::map<std::string, std::string> &msg); | |||
| /// | |||
| /// @brief save graph compile failed message from thread local map to global map | |||
| /// @param [in] graph_name: graph name | |||
| /// | |||
| void SaveMstuneCompileFailedMsg(const std::string &graph_name); | |||
| /// | |||
| /// @brief get graph compile failed message in mstune case | |||
| /// @param [in] graph_name: graph name | |||
| /// @param [out] msg_map: failed message map, key is error code, value is op_name list | |||
| /// @return int 0(success) -1(fail) | |||
| /// | |||
| int GetMstuneCompileFailedMsg(const std::string &graph_name, | |||
| std::map<std::string, std::vector<std::string>> &msg_map); | |||
| private: | |||
| struct ErrorInfo { | |||
| std::string error_id; | |||
| @@ -86,9 +109,11 @@ class ErrorManager { | |||
| int ReadJsonFile(const std::string &file_path, void *handle); | |||
| bool is_init_ = false; | |||
| std::mutex mutex_; | |||
| std::map<std::string, ErrorInfo> error_map_; | |||
| std::vector<std::string> error_messages_; | |||
| std::vector<std::string> warning_messages_; | |||
| std::map<std::string, std::map<std::string, std::vector<std::string>>> compile_failed_msg_map_; | |||
| }; | |||
| #endif // ERROR_MANAGER_H_ | |||
| @@ -36,66 +36,66 @@ class PlatformInfoManager { | |||
| uint32_t InitializePlatformInfo(); | |||
| uint32_t Finalize(); | |||
| uint32_t GetPlatformInfo(const string SoCVersion, PlatformInfo &platformInfo, OptionalInfo &optiCompilationInfo); | |||
| uint32_t GetPlatformInfo(const string SoCVersion, PlatformInfo &platform_info, OptionalInfo &opti_compilation_info); | |||
| uint32_t GetPlatformInfoWithOutSocVersion(PlatformInfo &platformInfo, OptionalInfo &optiCompilationInfo); | |||
| uint32_t GetPlatformInfoWithOutSocVersion(PlatformInfo &platform_info, OptionalInfo &opti_compilation_info); | |||
| void SetOptionalCompilationInfo(OptionalInfo &optiCompilationInfo); | |||
| void SetOptionalCompilationInfo(OptionalInfo &opti_compilation_info); | |||
| private: | |||
| PlatformInfoManager(); | |||
| ~PlatformInfoManager(); | |||
| uint32_t LoadIniFile(string iniFileRealPath); | |||
| uint32_t LoadIniFile(string ini_file_real_path); | |||
| void Trim(string &str); | |||
| uint32_t LoadConfigFile(string realPath); | |||
| uint32_t LoadConfigFile(string real_path); | |||
| string RealPath(const std::string &path); | |||
| string GetSoFilePath(); | |||
| void ParseVersion(map<string, string> &versionMap, string &socVersion, PlatformInfo &platformInfoTemp); | |||
| void ParseVersion(map<string, string> &version_map, string &soc_version, PlatformInfo &platform_info_temp); | |||
| void ParseSocInfo(map<string, string> &socInfoMap, PlatformInfo &platformInfoTemp); | |||
| void ParseSocInfo(map<string, string> &soc_info_map, PlatformInfo &platform_info_temp); | |||
| void ParseCubeOfAICoreSpec(map<string, string> &aiCoreSpecMap, PlatformInfo &platformInfoTemp); | |||
| void ParseCubeOfAICoreSpec(map<string, string> &ai_core_spec_map, PlatformInfo &platform_info_temp); | |||
| void ParseBufferOfAICoreSpec(map<string, string> &aiCoreSpecMap, PlatformInfo &platformInfoTemp); | |||
| void ParseBufferOfAICoreSpec(map<string, string> &ai_core_spec_map, PlatformInfo &platform_info_temp); | |||
| void ParseUBOfAICoreSpec(map<string, string> &aiCoreSpecMap, PlatformInfo &platformInfoTemp); | |||
| void ParseUBOfAICoreSpec(map<string, string> &ai_core_spec_map, PlatformInfo &platform_info_temp); | |||
| void ParseUnzipOfAICoreSpec(map<string, string> &aiCoreSpecMap, PlatformInfo &platformInfoTemp); | |||
| void ParseUnzipOfAICoreSpec(map<string, string> &ai_core_spec_map, PlatformInfo &platform_info_temp); | |||
| void ParseAICoreSpec(map<string, string> &aiCoreSpecMap, PlatformInfo &platformInfoTemp); | |||
| void ParseAICoreSpec(map<string, string> &ai_core_spec_map, PlatformInfo &platform_info_temp); | |||
| void ParseBufferOfAICoreMemoryRates(map<string, string> &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp); | |||
| void ParseBufferOfAICoreMemoryRates(map<string, string> &ai_core_memory_rates_map, PlatformInfo &platform_info_temp); | |||
| void ParseAICoreMemoryRates(map<string, string> &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp); | |||
| void ParseAICoreMemoryRates(map<string, string> &ai_core_memory_rates_map, PlatformInfo &platform_info_temp); | |||
| void ParseUBOfAICoreMemoryRates(map<string, string> &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp); | |||
| void ParseUBOfAICoreMemoryRates(map<string, string> &ai_core_memory_rates_map, PlatformInfo &platform_info_temp); | |||
| void ParseAICoreintrinsicDtypeMap(map<string, string> &aiCoreintrinsicDtypeMap, PlatformInfo &platformInfoTemp); | |||
| void ParseAICoreintrinsicDtypeMap(map<string, string> &ai_coreintrinsic_dtype_map, PlatformInfo &platform_info_temp); | |||
| void ParseVectorCoreSpec(map<string, string> &vectorCoreSpecMap, PlatformInfo &platformInfoTemp); | |||
| void ParseVectorCoreSpec(map<string, string> &vector_core_spec_map, PlatformInfo &platform_info_temp); | |||
| void ParseVectorCoreMemoryRates(map<string, string> &vectorCoreMemoryRatesMap, PlatformInfo &platformInfoTemp); | |||
| void ParseVectorCoreMemoryRates(map<string, string> &vector_core_memory_rates_map, PlatformInfo &platform_info_temp); | |||
| void ParseCPUCache(map<string, string> &CPUCacheMap, PlatformInfo &platformInfoTemp); | |||
| void ParseCPUCache(map<string, string> &CPUCacheMap, PlatformInfo &platform_info_temp); | |||
| void ParseVectorCoreintrinsicDtypeMap(map<string, string> &vectorCoreintrinsicDtypeMap, | |||
| PlatformInfo &platformInfoTemp); | |||
| void ParseVectorCoreintrinsicDtypeMap(map<string, string> &vector_coreintrinsic_dtype_map, | |||
| PlatformInfo &platform_info_temp); | |||
| uint32_t ParsePlatformInfoFromStrToStruct(map<string, map<string, string>> &contentInfoMap, string &socVersion, | |||
| PlatformInfo &platformInfoTemp); | |||
| uint32_t ParsePlatformInfoFromStrToStruct(map<string, map<string, string>> &content_info_map, string &soc_version, | |||
| PlatformInfo &platform_info_temp); | |||
| uint32_t AssemblePlatformInfoVector(map<string, map<string, string>> &contentInfoMap); | |||
| uint32_t AssemblePlatformInfoVector(map<string, map<string, string>> &content_info_map); | |||
| private: | |||
| bool initFlag_; | |||
| map<string, PlatformInfo> platformInfoMap_; | |||
| OptionalInfo optiCompilationInfo_; | |||
| bool init_flag_; | |||
| map<string, PlatformInfo> platform_info_map_; | |||
| OptionalInfo opti_compilation_info_; | |||
| }; | |||
| } // namespace fe | |||
| #endif | |||
| @@ -30,111 +30,113 @@ enum MemoryType { DDR = 0, HBM }; | |||
| enum L2Type { Cache = 0, Buff }; | |||
| typedef struct tagStrInfo { | |||
| string aicVersion; | |||
| string ccecAICVersion; | |||
| string ccecAIVVersion; | |||
| string isSupportAIcpuCompiler; | |||
| typedef struct tag_str_info { | |||
| string aic_version; | |||
| string ccec_aic_version; | |||
| string ccec_aiv_version; | |||
| string is_support_ai_cpu_compiler; | |||
| } StrInfo; | |||
| typedef struct tagSoCInfo { | |||
| uint32_t aiCoreCnt; | |||
| uint32_t vectorCoreCnt; | |||
| uint32_t aiCpuCnt; | |||
| MemoryType memoryType; | |||
| uint64_t memorySize; | |||
| L2Type l2Type; | |||
| uint64_t l2Size; | |||
| typedef struct tag_so_c_info { | |||
| uint32_t ai_core_cnt; | |||
| uint32_t vector_core_cnt; | |||
| uint32_t ai_cpu_cnt; | |||
| MemoryType memory_type; | |||
| uint64_t memory_size; | |||
| L2Type l2_type; | |||
| uint64_t l2_size; | |||
| uint32_t l2PageNum; | |||
| } SoCInfo; | |||
| typedef struct tagAiCoreSpec { | |||
| double cubeFreq; | |||
| uint64_t cubeMSize; | |||
| uint64_t cubeNSize; | |||
| uint64_t cubeKSize; | |||
| uint64_t vecCalcSize; | |||
| uint64_t l0ASize; | |||
| uint64_t l0BSize; | |||
| uint64_t l0CSize; | |||
| uint64_t l1Size; | |||
| uint64_t smaskBuffer; | |||
| uint64_t ubSize; | |||
| uint64_t ubblockSize; | |||
| uint64_t ubbankSize; | |||
| uint64_t ubbankNum; | |||
| uint64_t ubburstInOneBlock; | |||
| uint64_t ubbankGroupNum; | |||
| uint32_t unzipEngines; | |||
| uint32_t unzipMaxRatios; | |||
| uint32_t unzipChannels; | |||
| uint8_t unzipIsTight; | |||
| typedef struct tag_ai_core_spec { | |||
| double cube_freq; | |||
| uint64_t cube_m_size; | |||
| uint64_t cube_n_size; | |||
| uint64_t cube_k_size; | |||
| uint64_t vec_calc_size; | |||
| uint64_t l0_a_size; | |||
| uint64_t l0_b_size; | |||
| uint64_t l0_c_size; | |||
| uint64_t l1_size; | |||
| uint64_t smask_buffer; | |||
| uint64_t ub_size; | |||
| uint64_t ubblock_size; | |||
| uint64_t ubbank_size; | |||
| uint64_t ubbank_num; | |||
| uint64_t ubburst_in_one_block; | |||
| uint64_t ubbank_group_num; | |||
| uint32_t unzip_engines; | |||
| uint32_t unzip_max_ratios; | |||
| uint32_t unzip_channels; | |||
| uint8_t unzip_is_tight; | |||
| uint8_t cube_vector_split; | |||
| } AiCoreSpec; | |||
| typedef struct tagAiCoreMemoryRates { | |||
| double ddrRate; | |||
| double ddrReadRate; | |||
| double ddrWriteRate; | |||
| double l2Rate; | |||
| double l2ReadRate; | |||
| double l2WriteRate; | |||
| double l1ToL0ARate; | |||
| double l1ToL0BRate; | |||
| double l1ToUBRate; | |||
| double l0CToUBRate; | |||
| double ubToL2Rate; | |||
| double ubToDdrRate; | |||
| double ubToL1Rate; | |||
| typedef struct tag_ai_core_memory_rates { | |||
| double ddr_rate; | |||
| double ddr_read_rate; | |||
| double ddr_write_rate; | |||
| double l2_rate; | |||
| double l2_read_rate; | |||
| double l2_write_rate; | |||
| double l1_to_l0_a_rate; | |||
| double l1_to_l0_b_rate; | |||
| double l1_to_ub_rate; | |||
| double l0_c_to_ub_rate; | |||
| double ub_to_l2_rate; | |||
| double ub_to_ddr_rate; | |||
| double ub_to_l1_rate; | |||
| } AiCoreMemoryRates; | |||
| typedef struct tagVectorCoreSpec { | |||
| double vecFreq; | |||
| uint64_t vecCalcSize; | |||
| uint64_t smaskBuffer; | |||
| uint64_t ubSize; | |||
| uint64_t ubblockSize; | |||
| uint64_t ubbankSize; | |||
| uint64_t ubbankNum; | |||
| uint64_t ubburstInOneBlock; | |||
| uint64_t ubbankGroupNum; | |||
| uint64_t vectorRegSize; | |||
| uint64_t predicateRegSize; | |||
| uint64_t addressRegSize; | |||
| typedef struct tag_vector_core_spec { | |||
| double vec_freq; | |||
| uint64_t vec_calc_size; | |||
| uint64_t smask_buffer; | |||
| uint64_t ub_size; | |||
| uint64_t ubblock_size; | |||
| uint64_t ubbank_size; | |||
| uint64_t ubbank_num; | |||
| uint64_t ubburst_in_one_block; | |||
| uint64_t ubbank_group_num; | |||
| uint64_t vector_reg_size; | |||
| uint64_t predicate_reg_size; | |||
| uint64_t address_reg_size; | |||
| uint64_t alignment_reg_size; | |||
| } VectorCoreSpec; | |||
| typedef struct tagVectorCoreMemoryRates { | |||
| double ddrRate; | |||
| double ddrReadRate; | |||
| double ddrWriteRate; | |||
| double l2Rate; | |||
| double l2ReadRate; | |||
| double l2WriteRate; | |||
| double ubToL2Rate; | |||
| double ubToDdrRate; | |||
| typedef struct tag_vector_core_memory_rates { | |||
| double ddr_rate; | |||
| double ddr_read_rate; | |||
| double ddr_write_rate; | |||
| double l2_rate; | |||
| double l2_read_rate; | |||
| double l2_write_rate; | |||
| double ub_to_l2_rate; | |||
| double ub_to_ddr_rate; | |||
| } VectorCoreMemoryRates; | |||
| typedef struct tagCPUCache { | |||
| typedef struct tag_cpu_cache { | |||
| uint32_t AICPUSyncBySW; | |||
| uint32_t TSCPUSyncBySW; | |||
| } CPUCache; | |||
| typedef struct tagPlatformInfo { | |||
| StrInfo strInfo; | |||
| SoCInfo socInfo; | |||
| AiCoreSpec aiCoreSpec; | |||
| AiCoreMemoryRates aiCoreMemoryRates; | |||
| map<string, vector<string>> aiCoreIntrinsicDtypeMap; | |||
| VectorCoreSpec vectorCoreSpec; | |||
| VectorCoreMemoryRates vectorCoreMemoryRates; | |||
| typedef struct tag_platform_info { | |||
| StrInfo str_info; | |||
| SoCInfo soc_info; | |||
| AiCoreSpec ai_core_spec; | |||
| AiCoreMemoryRates ai_core_memory_rates; | |||
| map<string, vector<string>> ai_core_intrinsic_dtype_map; | |||
| VectorCoreSpec vector_core_spec; | |||
| VectorCoreMemoryRates vector_core_memory_rates; | |||
| CPUCache cpucache; | |||
| map<string, vector<string>> vectorCoreIntrinsicDtypeMap; | |||
| map<string, vector<string>> vector_core_intrinsic_dtype_map; | |||
| } PlatformInfo; | |||
| typedef struct tagOptionalInfo { | |||
| string socVersion; | |||
| string coreType; | |||
| uint32_t aiCoreNum; | |||
| string l1FusionFlag; | |||
| typedef struct tag_optional_info { | |||
| string soc_version; | |||
| string core_type; | |||
| uint32_t ai_core_num; | |||
| string l1_fusion_flag; | |||
| } OptionalInfo; | |||
| } // namespace fe | |||
| #endif | |||
| @@ -0,0 +1,73 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_EXTERNAL_ACL_ACL_H_ | |||
| #define INC_EXTERNAL_ACL_ACL_H_ | |||
| #include "acl_rt.h" | |||
| #include "acl_op.h" | |||
| #include "acl_mdl.h" | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| // Current version is 1.0.0 | |||
| #define ACL_MAJOR_VERSION 1 | |||
| #define ACL_MINOR_VERSION 0 | |||
| #define ACL_PATCH_VERSION 0 | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief acl initialize | |||
| * | |||
| * @par Restriction | |||
| * The aclInit interface can be called only once in a process | |||
| * @param configPath [IN] the config path,it can be NULL | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclInit(const char *configPath); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief acl finalize | |||
| * | |||
| * @par Restriction | |||
| * Need to call aclFinalize before the process exits. | |||
| * After calling aclFinalize,the services cannot continue to be used normally. | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclFinalize(); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief query ACL interface version | |||
| * | |||
| * @param majorVersion[OUT] ACL interface major version | |||
| * @param minorVersion[OUT] ACL interface minor version | |||
| * @param patchVersion[OUT] ACL interface patch version | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtGetVersion(int32_t *majorVersion, int32_t *minorVersion, int32_t *patchVersion); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif // INC_EXTERNAL_ACL_ACL_H_ | |||
| @@ -0,0 +1,569 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_EXTERNAL_ACL_ACL_BASE_H_ | |||
| #define INC_EXTERNAL_ACL_ACL_BASE_H_ | |||
| #include <stdint.h> | |||
| #include <stddef.h> | |||
| #include "error_codes/rt_error_codes.h" | |||
| #include "error_codes/ge_error_codes.h" | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(_MSC_VER) | |||
| #ifdef FUNC_VISIBILITY | |||
| #define ACL_FUNC_VISIBILITY _declspec(dllexport) | |||
| #else | |||
| #define ACL_FUNC_VISIBILITY | |||
| #endif | |||
| #else | |||
| #ifdef FUNC_VISIBILITY | |||
| #define ACL_FUNC_VISIBILITY __attribute__((visibility("default"))) | |||
| #else | |||
| #define ACL_FUNC_VISIBILITY | |||
| #endif | |||
| #endif | |||
| #ifdef __GNUC__ | |||
| #define ACL_DEPRECATED __attribute__((deprecated)) | |||
| #define ACL_DEPRECATED_MESSAGE(message) __attribute__((deprecated(message))) | |||
| #elif defined(_MSC_VER) | |||
| #define ACL_DEPRECATED __declspec(deprecated) | |||
| #define ACL_DEPRECATED_MESSAGE(message) __declspec(deprecated(message)) | |||
| #else | |||
| #define ACL_DEPRECATED | |||
| #define ACL_DEPRECATED_MESSAGE(message) | |||
| #endif | |||
| typedef void *aclrtStream; | |||
| typedef void *aclrtEvent; | |||
| typedef void *aclrtContext; | |||
| typedef int aclError; | |||
| typedef uint16_t aclFloat16; | |||
| typedef struct aclDataBuffer aclDataBuffer; | |||
| typedef struct aclTensorDesc aclTensorDesc; | |||
| static const int ACL_ERROR_NONE = 0; | |||
| static const int ACL_SUCCESS = 0; | |||
| static const int ACL_ERROR_INVALID_PARAM = 100000; | |||
| static const int ACL_ERROR_UNINITIALIZE = 100001; | |||
| static const int ACL_ERROR_REPEAT_INITIALIZE = 100002; | |||
| static const int ACL_ERROR_INVALID_FILE = 100003; | |||
| static const int ACL_ERROR_WRITE_FILE = 100004; | |||
| static const int ACL_ERROR_INVALID_FILE_SIZE = 100005; | |||
| static const int ACL_ERROR_PARSE_FILE = 100006; | |||
| static const int ACL_ERROR_FILE_MISSING_ATTR = 100007; | |||
| static const int ACL_ERROR_FILE_ATTR_INVALID = 100008; | |||
| static const int ACL_ERROR_INVALID_DUMP_CONFIG = 100009; | |||
| static const int ACL_ERROR_INVALID_PROFILING_CONFIG = 100010; | |||
| static const int ACL_ERROR_INVALID_MODEL_ID = 100011; | |||
| static const int ACL_ERROR_DESERIALIZE_MODEL = 100012; | |||
| static const int ACL_ERROR_PARSE_MODEL = 100013; | |||
| static const int ACL_ERROR_READ_MODEL_FAILURE = 100014; | |||
| static const int ACL_ERROR_MODEL_SIZE_INVALID = 100015; | |||
| static const int ACL_ERROR_MODEL_MISSING_ATTR = 100016; | |||
| static const int ACL_ERROR_MODEL_INPUT_NOT_MATCH = 100017; | |||
| static const int ACL_ERROR_MODEL_OUTPUT_NOT_MATCH = 100018; | |||
| static const int ACL_ERROR_MODEL_NOT_DYNAMIC = 100019; | |||
| static const int ACL_ERROR_OP_TYPE_NOT_MATCH = 100020; | |||
| static const int ACL_ERROR_OP_INPUT_NOT_MATCH = 100021; | |||
| static const int ACL_ERROR_OP_OUTPUT_NOT_MATCH = 100022; | |||
| static const int ACL_ERROR_OP_ATTR_NOT_MATCH = 100023; | |||
| static const int ACL_ERROR_OP_NOT_FOUND = 100024; | |||
| static const int ACL_ERROR_OP_LOAD_FAILED = 100025; | |||
| static const int ACL_ERROR_UNSUPPORTED_DATA_TYPE = 100026; | |||
| static const int ACL_ERROR_FORMAT_NOT_MATCH = 100027; | |||
| static const int ACL_ERROR_BIN_SELECTOR_NOT_REGISTERED = 100028; | |||
| static const int ACL_ERROR_KERNEL_NOT_FOUND = 100029; | |||
| static const int ACL_ERROR_BIN_SELECTOR_ALREADY_REGISTERED = 100030; | |||
| static const int ACL_ERROR_KERNEL_ALREADY_REGISTERED = 100031; | |||
| static const int ACL_ERROR_INVALID_QUEUE_ID = 100032; | |||
| static const int ACL_ERROR_REPEAT_SUBSCRIBE = 100033; | |||
| static const int ACL_ERROR_STREAM_NOT_SUBSCRIBE = 100034; | |||
| static const int ACL_ERROR_THREAD_NOT_SUBSCRIBE = 100035; | |||
| static const int ACL_ERROR_WAIT_CALLBACK_TIMEOUT = 100036; | |||
| static const int ACL_ERROR_REPEAT_FINALIZE = 100037; | |||
| static const int ACL_ERROR_NOT_STATIC_AIPP = 100038; | |||
| static const int ACL_ERROR_COMPILING_STUB_MODE = 100039; | |||
| static const int ACL_ERROR_GROUP_NOT_SET = 100040; | |||
| static const int ACL_ERROR_GROUP_NOT_CREATE = 100041; | |||
| static const int ACL_ERROR_PROF_ALREADY_RUN = 100042; | |||
| static const int ACL_ERROR_PROF_NOT_RUN = 100043; | |||
| static const int ACL_ERROR_DUMP_ALREADY_RUN = 100044; | |||
| static const int ACL_ERROR_DUMP_NOT_RUN = 100045; | |||
| static const int ACL_ERROR_PROF_REPEAT_SUBSCRIBE = 148046; | |||
| static const int ACL_ERROR_PROF_API_CONFLICT = 148047; | |||
| static const int ACL_ERROR_BAD_ALLOC = 200000; | |||
| static const int ACL_ERROR_API_NOT_SUPPORT = 200001; | |||
| static const int ACL_ERROR_INVALID_DEVICE = 200002; | |||
| static const int ACL_ERROR_MEMORY_ADDRESS_UNALIGNED = 200003; | |||
| static const int ACL_ERROR_RESOURCE_NOT_MATCH = 200004; | |||
| static const int ACL_ERROR_INVALID_RESOURCE_HANDLE = 200005; | |||
| static const int ACL_ERROR_FEATURE_UNSUPPORTED = 200006; | |||
| static const int ACL_ERROR_PROF_MODULES_UNSUPPORTED = 200007; | |||
| static const int ACL_ERROR_STORAGE_OVER_LIMIT = 300000; | |||
| static const int ACL_ERROR_INTERNAL_ERROR = 500000; | |||
| static const int ACL_ERROR_FAILURE = 500001; | |||
| static const int ACL_ERROR_GE_FAILURE = 500002; | |||
| static const int ACL_ERROR_RT_FAILURE = 500003; | |||
| static const int ACL_ERROR_DRV_FAILURE = 500004; | |||
| static const int ACL_ERROR_PROFILING_FAILURE = 500005; | |||
| #define ACL_TENSOR_SHAPE_RANGE_NUM 2 | |||
| #define ACL_UNKNOWN_RANK 0xFFFFFFFFFFFFFFFE | |||
| typedef enum { | |||
| ACL_DT_UNDEFINED = -1, | |||
| ACL_FLOAT = 0, | |||
| ACL_FLOAT16 = 1, | |||
| ACL_INT8 = 2, | |||
| ACL_INT32 = 3, | |||
| ACL_UINT8 = 4, | |||
| ACL_INT16 = 6, | |||
| ACL_UINT16 = 7, | |||
| ACL_UINT32 = 8, | |||
| ACL_INT64 = 9, | |||
| ACL_UINT64 = 10, | |||
| ACL_DOUBLE = 11, | |||
| ACL_BOOL = 12, | |||
| ACL_STRING = 13, | |||
| } aclDataType; | |||
| typedef enum { | |||
| ACL_FORMAT_UNDEFINED = -1, | |||
| ACL_FORMAT_NCHW = 0, | |||
| ACL_FORMAT_NHWC = 1, | |||
| ACL_FORMAT_ND = 2, | |||
| ACL_FORMAT_NC1HWC0 = 3, | |||
| ACL_FORMAT_FRACTAL_Z = 4, | |||
| ACL_FORMAT_NC1HWC0_C04 = 12, | |||
| ACL_FORMAT_FRACTAL_NZ = 29, | |||
| } aclFormat; | |||
| typedef enum { | |||
| ACL_DEBUG = 0, | |||
| ACL_INFO = 1, | |||
| ACL_WARNING = 2, | |||
| ACL_ERROR = 3, | |||
| } aclLogLevel; | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Converts data of type aclFloat16 to data of type float | |||
| * | |||
| * @param value [IN] Data to be converted | |||
| * | |||
| * @retval Transformed data | |||
| */ | |||
| ACL_FUNC_VISIBILITY float aclFloat16ToFloat(aclFloat16 value); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Converts data of type float to data of type aclFloat16 | |||
| * | |||
| * @param value [IN] Data to be converted | |||
| * | |||
| * @retval Transformed data | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclFloat16 aclFloatToFloat16(float value); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create data of aclDataBuffer | |||
| * | |||
| * @param data [IN] pointer to data | |||
| * @li Need to be managed by the user, | |||
| * call aclrtMalloc interface to apply for memory, | |||
| * call aclrtFree interface to release memory | |||
| * | |||
| * @param size [IN] size of data in bytes | |||
| * | |||
| * @retval pointer to created instance. nullptr if run out of memory | |||
| * | |||
| * @see aclrtMalloc | aclrtFree | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclDataBuffer *aclCreateDataBuffer(void *data, size_t size); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief destroy data of aclDataBuffer | |||
| * | |||
| * @par Function | |||
| * Only the aclDataBuffer type data is destroyed here. | |||
| * The memory of the data passed in when the aclDataDataBuffer interface | |||
| * is called to create aclDataBuffer type data must be released by the user | |||
| * | |||
| * @param dataBuffer [IN] pointer to the aclDataBuffer | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclCreateDataBuffer | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclDestroyDataBuffer(const aclDataBuffer *dataBuffer); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get data address from aclDataBuffer | |||
| * | |||
| * @param dataBuffer [IN] pointer to the data of aclDataBuffer | |||
| * | |||
| * @retval data address | |||
| */ | |||
| ACL_FUNC_VISIBILITY void *aclGetDataBufferAddr(const aclDataBuffer *dataBuffer); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get data size of aclDataBuffer | |||
| * | |||
| * @param dataBuffer [IN] pointer to the data of aclDataBuffer | |||
| * | |||
| * @retval data size | |||
| */ | |||
| ACL_DEPRECATED_MESSAGE("aclGetDataBufferSize is deprecated, use aclGetDataBufferSizeV2 instead") | |||
| ACL_FUNC_VISIBILITY uint32_t aclGetDataBufferSize(const aclDataBuffer *dataBuffer); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get data size of aclDataBuffer to replace aclGetDataBufferSize | |||
| * | |||
| * @param dataBuffer [IN] pointer to the data of aclDataBuffer | |||
| * | |||
| * @retval data size | |||
| */ | |||
| ACL_FUNC_VISIBILITY size_t aclGetDataBufferSizeV2(const aclDataBuffer *dataBuffer); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get size of aclDataType | |||
| * | |||
| * @param dataType [IN] aclDataType data the size to get | |||
| * | |||
| * @retval size of the aclDataType | |||
| */ | |||
| ACL_FUNC_VISIBILITY size_t aclDataTypeSize(aclDataType dataType); | |||
| // interfaces of tensor desc | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create data aclTensorDesc | |||
| * | |||
| * @param dataType [IN] Data types described by tensor | |||
| * @param numDims [IN] the number of dimensions of the shape | |||
| * @param dims [IN] the size of the specified dimension | |||
| * @param format [IN] tensor format | |||
| * | |||
| * @retval aclTensorDesc pointer. | |||
| * @retval nullptr if param is invalid or run out of memory | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclTensorDesc *aclCreateTensorDesc(aclDataType dataType, int numDims, const int64_t *dims, | |||
| aclFormat format); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief destroy data aclTensorDesc | |||
| * | |||
| * @param desc [IN] pointer to the data of aclTensorDesc to destroy | |||
| */ | |||
| ACL_FUNC_VISIBILITY void aclDestroyTensorDesc(const aclTensorDesc *desc); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set tensor shape range for aclTensorDesc | |||
| * | |||
| * @param desc [OUT] pointer to the data of aclTensorDesc | |||
| * @param dimsCount [IN] the number of dimensions of the shape | |||
| * @param dimsRange [IN] the range of dimensions of the shape | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclSetTensorShapeRange(aclTensorDesc *desc, size_t dimsCount, | |||
| int64_t dimsRange[][ACL_TENSOR_SHAPE_RANGE_NUM]); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get data type specified by the tensor description | |||
| * | |||
| * @param desc [IN] pointer to the instance of aclTensorDesc | |||
| * | |||
| * @retval data type specified by the tensor description. | |||
| * @retval ACL_DT_UNDEFINED if description is null | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclDataType aclGetTensorDescType(const aclTensorDesc *desc); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get data format specified by the tensor description | |||
| * | |||
| * @param desc [IN] pointer to the instance of aclTensorDesc | |||
| * | |||
| * @retval data format specified by the tensor description. | |||
| * @retval ACL_FORMAT_UNDEFINED if description is null | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclFormat aclGetTensorDescFormat(const aclTensorDesc *desc); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get tensor size specified by the tensor description | |||
| * | |||
| * @param desc [IN] pointer to the instance of aclTensorDesc | |||
| * | |||
| * @retval data size specified by the tensor description. | |||
| * @retval 0 if description is null | |||
| */ | |||
| ACL_FUNC_VISIBILITY size_t aclGetTensorDescSize(const aclTensorDesc *desc); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get element count specified by the tensor description | |||
| * | |||
| * @param desc [IN] pointer to the instance of aclTensorDesc | |||
| * | |||
| * @retval element count specified by the tensor description. | |||
| * @retval 0 if description is null | |||
| */ | |||
| ACL_FUNC_VISIBILITY size_t aclGetTensorDescElementCount(const aclTensorDesc *desc); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get number of dims specified by the tensor description | |||
| * | |||
| * @param desc [IN] pointer to the instance of aclTensorDesc | |||
| * | |||
| * @retval number of dims specified by the tensor description. | |||
| * @retval 0 if description is null | |||
| * @retval ACL_UNKNOWN_RANK if the tensor dim is -2 | |||
| */ | |||
| ACL_FUNC_VISIBILITY size_t aclGetTensorDescNumDims(const aclTensorDesc *desc); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get the size of the specified dim in the tensor description | |||
| * | |||
| * @param desc [IN] pointer to the instance of aclTensorDesc | |||
| * @param index [IN] index of dims, start from 0. | |||
| * | |||
| * @retval dim specified by the tensor description and index. | |||
| * @retval -1 if description or index is invalid | |||
| */ | |||
| ACL_DEPRECATED_MESSAGE("aclGetTensorDescDim is deprecated, use aclGetTensorDescDimV2 instead") | |||
| ACL_FUNC_VISIBILITY int64_t aclGetTensorDescDim(const aclTensorDesc *desc, size_t index); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get the size of the specified dim in the tensor description | |||
| * | |||
| * @param desc [IN] pointer to the instance of aclTensorDesc | |||
| * @param index [IN] index of dims, start from 0. | |||
| * @param dimSize [OUT] size of the specified dim. | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclGetTensorDescDimV2(const aclTensorDesc *desc, size_t index, int64_t *dimSize); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get the range of the specified dim in the tensor description | |||
| * | |||
| * @param desc [IN] pointer to the instance of aclTensorDesc | |||
| * @param index [IN] index of dims, start from 0. | |||
| * @param dimRangeNum [IN] number of dimRange. | |||
| * @param dimRange [OUT] range of the specified dim. | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclGetTensorDescDimRange(const aclTensorDesc *desc, size_t index, size_t dimRangeNum, | |||
| int64_t *dimRange); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set tensor description name | |||
| * | |||
| * @param desc [OUT] pointer to the instance of aclTensorDesc | |||
| * @param name [IN] tensor description name | |||
| */ | |||
| ACL_FUNC_VISIBILITY void aclSetTensorDescName(aclTensorDesc *desc, const char *name); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get tensor description name | |||
| * | |||
| * @param desc [IN] pointer to the instance of aclTensorDesc | |||
| * | |||
| * @retval tensor description name. | |||
| * @retval empty string if description is null | |||
| */ | |||
| ACL_FUNC_VISIBILITY const char *aclGetTensorDescName(aclTensorDesc *desc); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Convert the format in the source aclTensorDesc according to | |||
| * the specified dstFormat to generate a new target aclTensorDesc. | |||
| * The format in the source aclTensorDesc remains unchanged. | |||
| * | |||
| * @param srcDesc [IN] pointer to the source tensor desc | |||
| * @param dstFormat [IN] destination format | |||
| * @param dstDesc [OUT] pointer to the pointer to the destination tensor desc | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclTransTensorDescFormat(const aclTensorDesc *srcDesc, aclFormat dstFormat, | |||
| aclTensorDesc **dstDesc); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Set the storage format specified by the tensor description | |||
| * | |||
| * @param desc [OUT] pointer to the instance of aclTensorDesc | |||
| * @param format [IN] the storage format | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_DEPRECATED_MESSAGE("aclSetTensorStorageFormat is deprecated, use aclSetTensorFormat instead") | |||
| ACL_FUNC_VISIBILITY aclError aclSetTensorStorageFormat(aclTensorDesc *desc, aclFormat format); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Set the storage shape specified by the tensor description | |||
| * | |||
| * @param desc [OUT] pointer to the instance of aclTensorDesc | |||
| * @param numDims [IN] the number of dimensions of the shape | |||
| * @param dims [IN] the size of the specified dimension | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_DEPRECATED_MESSAGE("aclSetTensorStorageShape is deprecated, use aclSetTensorShape instead") | |||
| ACL_FUNC_VISIBILITY aclError aclSetTensorStorageShape(aclTensorDesc *desc, int numDims, const int64_t *dims); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Set the format specified by the tensor description | |||
| * | |||
| * @param desc [OUT] pointer to the instance of aclTensorDesc | |||
| * @param format [IN] the storage format | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclSetTensorFormat(aclTensorDesc *desc, aclFormat format); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Set the shape specified by the tensor description | |||
| * | |||
| * @param desc [OUT] pointer to the instance of aclTensorDesc | |||
| * @param numDims [IN] the number of dimensions of the shape | |||
| * @param dims [IN] the size of the specified dimension | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclSetTensorShape(aclTensorDesc *desc, int numDims, const int64_t *dims); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Set the original format specified by the tensor description | |||
| * | |||
| * @param desc [OUT] pointer to the instance of aclTensorDesc | |||
| * @param format [IN] the storage format | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclSetTensorOriginFormat(aclTensorDesc *desc, aclFormat format); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Set the original shape specified by the tensor description | |||
| * | |||
| * @param desc [OUT] pointer to the instance of aclTensorDesc | |||
| * @param numDims [IN] the number of dimensions of the shape | |||
| * @param dims [IN] the size of the specified dimension | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclSetTensorOriginShape(aclTensorDesc *desc, int numDims, const int64_t *dims); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get op description info | |||
| * | |||
| * @param desc [IN] pointer to tensor description | |||
| * @param index [IN] index of tensor | |||
| * | |||
| * @retval null for failed. | |||
| * @retval OtherValues success. | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclTensorDesc *aclGetTensorDescByIndex(aclTensorDesc *desc, size_t index); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get address of tensor | |||
| * | |||
| * @param desc [IN] pointer to tensor description | |||
| * | |||
| * @retval null for failed | |||
| * @retval OtherValues success | |||
| */ | |||
| ACL_FUNC_VISIBILITY void *aclGetTensorDescAddress(const aclTensorDesc *desc); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Set the dynamic input name specified by the tensor description | |||
| * | |||
| * @param desc [OUT] pointer to the instance of aclTensorDesc | |||
| * @param dynamicInputName [IN] pointer to the dynamic input name | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclSetTensorDynamicInput(aclTensorDesc *desc, const char *dynamicInputName); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief an interface for users to output APP logs | |||
| * | |||
| * @param logLevel [IN] the level of current log | |||
| * @param func [IN] the function where the log is located | |||
| * @param file [IN] the file where the log is located | |||
| * @param line [IN] Number of source lines where the log is located | |||
| * @param fmt [IN] the format of current log | |||
| * @param ... [IN] the value of current log | |||
| */ | |||
| ACL_FUNC_VISIBILITY void aclAppLog(aclLogLevel logLevel, const char *func, const char *file, uint32_t line, | |||
| const char *fmt, ...); | |||
| #define ACL_APP_LOG(level, fmt, ...) aclAppLog(level, __FUNCTION__, __FILE__, __LINE__, fmt, ##__VA_ARGS__) | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif // INC_EXTERNAL_ACL_ACL_BASE_H_ | |||
| @@ -0,0 +1,503 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_EXTERNAL_ACL_ACL_OP_H_ | |||
| #define INC_EXTERNAL_ACL_ACL_OP_H_ | |||
| #include "acl_base.h" | |||
| #include "acl_rt.h" | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| typedef struct aclopHandle aclopHandle; | |||
| typedef struct aclopAttr aclopAttr; | |||
| typedef struct aclopKernelDesc aclopKernelDesc; | |||
| typedef void (*aclDataDeallocator)(void *data, size_t length); | |||
| static const int ACL_COMPILE_FLAG_BIN_SELECTOR = 1; | |||
| typedef enum aclEngineType { | |||
| ACL_ENGINE_SYS, | |||
| ACL_ENGINE_AICORE, | |||
| ACL_ENGINE_VECTOR, | |||
| } aclopEngineType; | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Set base directory that contains single op models | |||
| * | |||
| * @par Restriction | |||
| * The aclopSetModelDir interface can be called only once in a process. | |||
| * @param modelDir [IN] path of the directory | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopSetModelDir(const char *modelDir); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief load single op models from memory | |||
| * | |||
| * @par Restriction | |||
| * The aclopLoad interface can be called more than one times in a process. | |||
| * @param model [IN] address of single op models | |||
| * @param modelSize [IN] size of single op models | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopLoad(const void *model, size_t modelSize); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create data of type aclopAttr | |||
| * | |||
| * @retval pointer to created instance. | |||
| * @retval nullptr if run out of memory | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclopAttr *aclopCreateAttr(); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief destroy data of typ aclopAttr | |||
| * | |||
| * @param attr [IN] pointer to the instance of aclopAttr | |||
| */ | |||
| ACL_FUNC_VISIBILITY void aclopDestroyAttr(const aclopAttr *attr); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set an attribute. the type of the attribute is bool | |||
| * | |||
| * @param attr [OUT] pointer to the instance of aclopAttr | |||
| * @param attrName [IN] attribute name | |||
| * @param attrValue [IN] attribute value | |||
| * false if attrValue is 0, true otherwise. | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopSetAttrBool(aclopAttr *attr, const char *attrName, uint8_t attrValue); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set an attribute. the type of the attribute is int64_t | |||
| * | |||
| * @param attr [OUT] pointer to the instance of aclopAttr | |||
| * @param attrName [IN] attribute name | |||
| * @param attrValue [IN] attribute value | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopSetAttrInt(aclopAttr *attr, const char *attrName, int64_t attrValue); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set an attribute. the type of the attribute is float | |||
| * | |||
| * @param attr [OUT] pointer to the instance of aclopAttr | |||
| * @param attrName [IN] attribute name | |||
| * @param attrValue [IN] attribute value | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopSetAttrFloat(aclopAttr *attr, const char *attrName, float attrValue); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set an attribute. the type of the attribute is string | |||
| * | |||
| * @param attr [OUT] pointer to the instance of aclopAttr | |||
| * @param attrName [IN] attribute name | |||
| * @param attrValue [IN] attribute value | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopSetAttrString(aclopAttr *attr, const char *attrName, const char *attrValue); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set an attribute. the type of the attribute is list of bools | |||
| * | |||
| * @param attr [OUT] pointer to the instance of aclopAttr | |||
| * @param attrName [IN] attribute name | |||
| * @param numValues [IN] number of values. false if attrValue is 0, true otherwise. | |||
| * @param values [IN] pointer to values | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopSetAttrListBool(aclopAttr *attr, const char *attrName, int numValues, | |||
| const uint8_t *values); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set an attribute. the type of the attribute is list of ints | |||
| * | |||
| * @param attr [OUT] pointer to the instance of aclopAttr | |||
| * @param attrName [IN] attribute name | |||
| * @param numValues [IN] number of values | |||
| * @param values [IN] pointer to values | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopSetAttrListInt(aclopAttr *attr, const char *attrName, int numValues, | |||
| const int64_t *values); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set an attribute. the type of the attribute is list of floats | |||
| * | |||
| * @param attr [OUT] pointer to the instance of aclopAttr | |||
| * @param attrName [IN] attribute name | |||
| * @param numValues [IN] number of values | |||
| * @param values [IN] pointer to values | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopSetAttrListFloat(aclopAttr *attr, const char *attrName, int numValues, | |||
| const float *values); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set an attribute. the type of the attribute is list of strings | |||
| * | |||
| * @param attr [OUT] pointer to the instance of aclopAttr | |||
| * @param attrName [IN] attribute name | |||
| * @param numValues [IN] number of values | |||
| * @param values [IN] pointer to values | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopSetAttrListString(aclopAttr *attr, const char *attrName, int numValues, | |||
| const char **values); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set an attribute. the type of the attribute is list of list of ints | |||
| * | |||
| * @param attr [OUT] pointer to the instance of aclopAttr | |||
| * @param attrName [IN] attribute name | |||
| * @param numLists [IN] number of lists | |||
| * @param numValues [IN] pointer to number of values of each list | |||
| * @param values [IN] pointer to values | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopSetAttrListListInt(aclopAttr *attr, const char *attrName, int numLists, | |||
| const int *numValues, const int64_t *const values[]); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Load and execute the specified operator asynchronously | |||
| * | |||
| * @par Restriction | |||
| * @li The input and output organization of each operator is different, | |||
| * and the application needs to organize the operator strictly | |||
| * according to the operator input and output parameters when calling. | |||
| * @li When the user calls aclopExecute, | |||
| * the ACL finds the corresponding task according to the optype, | |||
| * the description of the input tesnsor, | |||
| * the description of the output tesnsor, and attr, and issues the execution. | |||
| * | |||
| * @param opType [IN] type of op | |||
| * @param numInputs [IN] number of inputs | |||
| * @param inputDesc [IN] pointer to array of input tensor descriptions | |||
| * @param inputs [IN] pointer to array of input buffers | |||
| * @param numOutputs [IN] number of outputs | |||
| * @param outputDesc [IN] pointer to array of output tensor descriptions | |||
| * @param outputs [OUT] pointer to array of output buffers | |||
| * @param attr [IN] pointer to instance of aclopAttr. | |||
| * may pass nullptr if the op has no attribute | |||
| * @param stream [IN] stream | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_DEPRECATED_MESSAGE("aclopExecute is deprecated, use aclopExecuteV2 instead") | |||
| ACL_FUNC_VISIBILITY aclError aclopExecute(const char *opType, int numInputs, const aclTensorDesc *const inputDesc[], | |||
| const aclDataBuffer *const inputs[], int numOutputs, | |||
| const aclTensorDesc *const outputDesc[], aclDataBuffer *const outputs[], | |||
| const aclopAttr *attr, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Load and execute the specified operator | |||
| * The difference with aclopExecute is that aclopExecuteV2 will refresh outputDesc | |||
| * | |||
| * @par Restriction | |||
| * @li The input and output organization of each operator is different, | |||
| * and the application needs to organize the operator strictly | |||
| * according to the operator input and output parameters when calling. | |||
| * @li When the user calls aclopExecuteV2, | |||
| * the ACL finds the corresponding task according to the optype, | |||
| * the description of the input tesnsor, | |||
| * the description of the output tesnsor, and attr, and issues the execution. | |||
| * | |||
| * @param opType [IN] type of op | |||
| * @param numInputs [IN] number of inputs | |||
| * @param inputDesc [IN] pointer to array of input tensor descriptions | |||
| * @param inputs [IN] pointer to array of input buffers | |||
| * @param numOutputs [IN] number of outputs | |||
| * @param outputDesc [IN|OUT] pointer to array of output tensor descriptions | |||
| * @param outputs [OUT] pointer to array of output buffers | |||
| * @param attr [IN] pointer to instance of aclopAttr. | |||
| * may pass nullptr if the op has no attribute | |||
| * @param stream [IN] stream | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopExecuteV2(const char *opType, int numInputs, aclTensorDesc *inputDesc[], | |||
| aclDataBuffer *inputs[], int numOutputs, aclTensorDesc *outputDesc[], | |||
| aclDataBuffer *outputs[], aclopAttr *attr, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create a instance of aclopHandle. | |||
| * | |||
| * @param opType [IN] type of op | |||
| * @param numInputs [IN] number of inputs | |||
| * @param inputDesc [IN] pointer to array of input tensor descriptions | |||
| * @param numOutputs [IN] number of outputs | |||
| * @param outputDesc [IN] pointer to array of output tensor descriptions | |||
| * @param opAttr [IN] pointer to instance of aclopAttr. | |||
| * may pass nullptr if the op has no attribute | |||
| * @param handle [OUT] pointer to the pointer to the handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopCreateHandle(const char *opType, int numInputs, | |||
| const aclTensorDesc *const inputDesc[], int numOutputs, | |||
| const aclTensorDesc *const outputDesc[], const aclopAttr *opAttr, | |||
| aclopHandle **handle); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief destroy aclopHandle instance | |||
| * | |||
| * @param handle [IN] pointer to the instance of aclopHandle | |||
| */ | |||
| ACL_FUNC_VISIBILITY void aclopDestroyHandle(aclopHandle *handle); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief execute an op with the handle. | |||
| * can save op model matching cost compared with aclopExecute | |||
| * | |||
| * @param handle [IN] pointer to the instance of aclopHandle. | |||
| * The aclopCreateHandle interface has been called | |||
| * in advance to create aclopHandle type data. | |||
| * @param numInputs [IN] number of inputs | |||
| * @param inputs [IN] pointer to array of input buffers. | |||
| * The aclCreateDataBuffer interface has been called | |||
| * in advance to create aclDataBuffer type data. | |||
| * @param numOutputs [IN] number of outputs | |||
| * @param outputs [OUT] pointer to array of output buffers | |||
| * @param stream [IN] stream | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclopCreateHandle | aclCreateDataBuffer | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopExecWithHandle(aclopHandle *handle, int numInputs, | |||
| const aclDataBuffer *const inputs[], int numOutputs, | |||
| aclDataBuffer *const outputs[], aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief cast data type | |||
| * | |||
| * @param srcDesc [IN] source tensor desc | |||
| * @param srcBuffer [IN] source tensor buffer | |||
| * @param dstDesc [IN] destination tensor desc | |||
| * @param dstBuffer [OUT] destination tensor buffer | |||
| * @param truncate [IN] do not truncate if value is 0, truncate otherwise | |||
| * @param stream [IN] stream | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopCast(const aclTensorDesc *srcDesc, const aclDataBuffer *srcBuffer, | |||
| const aclTensorDesc *dstDesc, aclDataBuffer *dstBuffer, uint8_t truncate, | |||
| aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create a handle for casting datatype | |||
| * | |||
| * @param srcDesc [IN] source tensor desc | |||
| * @param dstDesc [IN] destination tensor desc | |||
| * @param truncate [IN] do not truncate if value is 0, truncate otherwise | |||
| * @param handle [OUT] pointer to the pointer to the handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopCreateHandleForCast(aclTensorDesc *srcDesc, aclTensorDesc *dstDesc, uint8_t truncate, | |||
| aclopHandle **handle); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create kernel | |||
| * | |||
| * @param opType [IN] op type | |||
| * @param kernelId [IN] kernel id | |||
| * @param kernelName [IN] kernel name | |||
| * @param binData [IN] kernel bin data | |||
| * @param binSize [IN] kernel bin size | |||
| * @param enginetype [IN] enigne type | |||
| * @param deallocator [IN] callback function for deallocating bin data, | |||
| * null if bin data to be deallocated by caller | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclopCompile | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopCreateKernel(const char *opType, const char *kernelId, const char *kernelName, | |||
| void *binData, int binSize, aclopEngineType enginetype, | |||
| aclDataDeallocator deallocator); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create kernel | |||
| * | |||
| * @param numInputs [IN] number of inputs | |||
| * @param inputDesc [IN] pointer to array of input tensor descriptions | |||
| * @param numOutputs [IN] number of outputs | |||
| * @param outputDesc [IN] pointer to array of output tensor descriptions | |||
| * @param opAttr [IN] pointer to instance of aclopAttr | |||
| * @param aclopKernelDesc [IN] pointer to instance of aclopKernelDesc | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| typedef aclError (*aclopCompileFunc)(int numInputs, const aclTensorDesc *const inputDesc[], int numOutputs, | |||
| const aclTensorDesc *const outputDesc[], const aclopAttr *opAttr, | |||
| aclopKernelDesc *aclopKernelDesc); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief register compile function | |||
| * | |||
| * @param opType [IN] op type | |||
| * @param func [IN] compile function | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclopUnregisterCompileFunc | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopRegisterCompileFunc(const char *opType, aclopCompileFunc func); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief unregister compile function | |||
| * | |||
| * @param opType [IN] op type | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopUnregisterCompileFunc(const char *opType); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set kernel args | |||
| * | |||
| * @param kernelDesc [IN] pointer to instance of aclopKernelDesc | |||
| * @param kernelId [IN] kernel id | |||
| * @param blockDim [IN] block dim | |||
| * @param args [IN] args | |||
| * @param argSize [IN] size in bytes of args | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopSetKernelArgs(aclopKernelDesc *kernelDesc, const char *kernelId, uint32_t blockDim, | |||
| const void *args, uint32_t argSize); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set workspace sizes | |||
| * | |||
| * @param kernelDesc [IN] pointer to instance of aclopKernelDesc | |||
| * @param numWorkspaces [IN] number of workspaces | |||
| * @param workspaceSizes [IN] pointer to array of sizes of workspaces | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopSetKernelWorkspaceSizes(aclopKernelDesc *kernelDesc, int numWorkspaces, | |||
| size_t *workspaceSizes); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief compile op with dynamic shape | |||
| * | |||
| * @param opType [IN] op type | |||
| * @param numInputs [IN] number of inputs | |||
| * @param inputDesc [IN] pointer to array of input tensor descriptions | |||
| * @param numOutputs [IN] number of outputs | |||
| * @param outputDesc [IN] pointer to array of output tensor descriptions | |||
| * @param attr [IN] pointer to instance of aclopAttr. | |||
| * may pass nullptr if the op has no attribute | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopUpdateParams(const char *opType, int numInputs, | |||
| const aclTensorDesc *const inputDesc[], int numOutputs, | |||
| const aclTensorDesc *const outputDesc[], const aclopAttr *attr); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief inferShape the specified operator synchronously | |||
| * | |||
| * @param opType [IN] type of op | |||
| * @param numInputs [IN] number of inputs | |||
| * @param inputDesc [IN] pointer to array of input tensor descriptions | |||
| * @param inputs [IN] pointer to array of input buffers | |||
| * @param numOutputs [IN] number of outputs | |||
| * @param outputDesc [OUT] pointer to array of output tensor descriptions | |||
| * @param attr [IN] pointer to instance of aclopAttr. | |||
| * may pass nullptr if the op has no attribute | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopInferShape(const char *opType, int numInputs, aclTensorDesc *inputDesc[], | |||
| aclDataBuffer *inputs[], int numOutputs, aclTensorDesc *outputDesc[], | |||
| aclopAttr *attr); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif // INC_EXTERNAL_ACL_ACL_OP_H_ | |||
| @@ -0,0 +1,105 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_EXTERNAL_ACL_ACL_OP_COMPILER_H_ | |||
| #define INC_EXTERNAL_ACL_ACL_OP_COMPILER_H_ | |||
| #include "acl_base.h" | |||
| #include "acl_op.h" | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| typedef enum aclCompileType { ACL_COMPILE_SYS, ACL_COMPILE_UNREGISTERED } aclopCompileType; | |||
| typedef enum { | |||
| ACL_PRECISION_MODE, | |||
| ACL_AICORE_NUM, | |||
| ACL_AUTO_TUNE_MODE, | |||
| ACL_OP_SELECT_IMPL_MODE, | |||
| ACL_OPTYPELIST_FOR_IMPLMODE, | |||
| ACL_OP_DEBUG_LEVEL, | |||
| ACL_DEBUG_DIR, | |||
| ACL_OP_COMPILER_CACHE_MODE, | |||
| ACL_OP_COMPILER_CACHE_DIR | |||
| } aclCompileOpt; | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief compile op | |||
| * | |||
| * @param opType [IN] op type | |||
| * @param numInputs [IN] number of inputs | |||
| * @param inputDesc [IN] pointer to array of input tensor descriptions | |||
| * @param numOutputs [IN] number of outputs | |||
| * @param outputDesc [IN] pointer to array of output tensor descriptions | |||
| * @param attr [IN] pointer to instance of aclopAttr. | |||
| * may pass nullptr if the op has no attribute | |||
| * @param engineType [IN] engine type | |||
| * @param compileFlag [IN] compile flag | |||
| * @param opPath [IN] path of op | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopCompile(const char *opType, int numInputs, const aclTensorDesc *const inputDesc[], | |||
| int numOutputs, const aclTensorDesc *const outputDesc[], | |||
| const aclopAttr *attr, aclopEngineType engineType, | |||
| aclopCompileType compileFlag, const char *opPath); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief compile and execute op | |||
| * | |||
| * @param opType [IN] op type | |||
| * @param numInputs [IN] number of inputs | |||
| * @param inputDesc [IN] pointer to array of input tensor descriptions | |||
| * @param inputs [IN] pointer to array of input buffers | |||
| * @param numOutputs [IN] number of outputs | |||
| * @param outputDesc [IN] pointer to array of output tensor descriptions | |||
| * @param outputs [IN] pointer to array of outputs buffers | |||
| * @param attr [IN] pointer to instance of aclopAttr. | |||
| * may pass nullptr if the op has no attribute | |||
| * @param engineType [IN] engine type | |||
| * @param compileFlag [IN] compile flag | |||
| * @param opPath [IN] path of op | |||
| * @param stream [IN] stream handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclopCompileAndExecute( | |||
| const char *opType, int numInputs, const aclTensorDesc *const inputDesc[], const aclDataBuffer *const inputs[], | |||
| int numOutputs, const aclTensorDesc *const outputDesc[], aclDataBuffer *const outputs[], const aclopAttr *attr, | |||
| aclopEngineType engineType, aclopCompileType compileFlag, const char *opPath, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set compile option | |||
| * | |||
| * @param aclCompileOpt [IN] compile option | |||
| * @param value [IN] pointer for the option value | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclSetCompileopt(aclCompileOpt opt, const char *value); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif // INC_EXTERNAL_ACL_ACL_OP_COMPILER_H_ | |||
| @@ -0,0 +1,297 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_EXTERNAL_ACL_PROF_H_ | |||
| #define INC_EXTERNAL_ACL_PROF_H_ | |||
| #include "acl_base.h" | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #define ACL_PROF_ACL_API 0x0001 | |||
| #define ACL_PROF_TASK_TIME 0x0002 | |||
| #define ACL_PROF_AICORE_METRICS 0x0004 | |||
| #define ACL_PROF_AICPU_TRACE 0x0008 | |||
| #define ACL_PROF_MAX_OP_NAME_LEN 257 | |||
| #define ACL_PROF_MAX_OP_TYPE_LEN 65 | |||
| typedef enum { | |||
| ACL_AICORE_ARITHMATIC_THROUGHPUT = 0, | |||
| ACL_AICORE_PIPELINE = 1, | |||
| ACL_AICORE_SYNCHRONIZATION = 2, | |||
| ACL_AICORE_MEMORY = 3, | |||
| ACL_AICORE_INTERNAL_MEMORY = 4, | |||
| ACL_AICORE_STALL = 5, | |||
| ACL_AICORE_NONE = 0xFF | |||
| } aclprofAicoreMetrics; | |||
| typedef struct aclprofConfig aclprofConfig; | |||
| typedef struct aclprofStopConfig aclprofStopConfig; | |||
| typedef struct aclprofAicoreEvents aclprofAicoreEvents; | |||
| typedef struct aclprofSubscribeConfig aclprofSubscribeConfig; | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief profiling initialize | |||
| * | |||
| * @param profilerResultPath [IN] path of profiling result | |||
| * @param length [IN] length of profilerResultPath | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclprofFinalize | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclprofInit(const char *profilerResultPath, size_t length); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief profiling finalize | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclprofInit | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclprofFinalize(); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Start profiling modules by profilerConfig | |||
| * | |||
| * @param profilerConfig [IN] config of profiling | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclprofStop | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclprofStart(const aclprofConfig *profilerConfig); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Create data of type aclprofConfig | |||
| * | |||
| * @param deviceIdList [IN] list of device id | |||
| * @param deviceNums [IN] number of devices | |||
| * @param aicoreMetrics [IN] type of aicore metrics | |||
| * @param aicoreEvents [IN] pointer to aicore events, only support NULL now | |||
| * @param dataTypeConfig [IN] config modules need profiling | |||
| * | |||
| * @retval the aclprofConfig pointer | |||
| * | |||
| * @see aclprofDestroyConfig | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclprofConfig *aclprofCreateConfig(uint32_t *deviceIdList, uint32_t deviceNums, | |||
| aclprofAicoreMetrics aicoreMetrics, | |||
| aclprofAicoreEvents *aicoreEvents, uint64_t dataTypeConfig); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Destroy data of type aclprofConfig | |||
| * | |||
| * @param profilerConfig [IN] config of profiling | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclprofCreateConfig | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclprofDestroyConfig(const aclprofConfig *profilerConfig); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief stop profiling modules by stopProfilingConfig | |||
| * | |||
| * @param profilerConfig [IN] pointer to stop config of profiling | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclprofStart | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclprofStop(const aclprofConfig *profilerConfig); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief subscribe profiling data of model | |||
| * | |||
| * @param modelId [IN] the model id subscribed | |||
| * @param profSubscribeConfig [IN] pointer to config of model subscribe | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclprofModelUnSubscribe | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclprofModelSubscribe(uint32_t modelId, const aclprofSubscribeConfig *profSubscribeConfig); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief unsubscribe profiling data of model | |||
| * | |||
| * @param modelId [IN] the model id unsubscribed | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclprofModelSubscribe | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclprofModelUnSubscribe(uint32_t modelId); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create subscribe config | |||
| * | |||
| * @param timeInfoSwitch [IN] switch whether get time info from model | |||
| * @param aicoreMetrics [IN] aicore metrics | |||
| * @param fd [IN] pointer to write pipe | |||
| * | |||
| * @retval the aclprofSubscribeConfig pointer | |||
| * | |||
| * @see aclprofDestroySubscribeConfig | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclprofSubscribeConfig *aclprofCreateSubscribeConfig(int8_t timeInfoSwitch, | |||
| aclprofAicoreMetrics aicoreMetrics, void *fd); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief destroy subscribe config | |||
| * | |||
| * @param profSubscribeConfig [IN] subscribe config | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclprofCreateSubscribeConfig | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclprofDestroySubscribeConfig(const aclprofSubscribeConfig *profSubscribeConfig); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create subscribe config | |||
| * | |||
| * @param opDescSize [OUT] size of op desc | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclprofGetOpDescSize(size_t *opDescSize); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get op number from subscription data | |||
| * | |||
| * @param opInfo [IN] pointer to subscription data | |||
| * @param opInfoLen [IN] memory size of subscription data | |||
| * @param opNumber [OUT] op number of subscription data | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclprofGetOpNum(const void *opInfo, size_t opInfoLen, uint32_t *opNumber); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get op type from subscription data | |||
| * | |||
| * @param opInfo [IN] pointer to subscription data | |||
| * @param opInfoLen [IN] memory size of subscription data | |||
| * @param index [IN] index of op array in opInfo | |||
| * @param opType [OUT] obtained op type string | |||
| * @param opTypeLen [IN] obtained length of op type string | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclprofGetOpType(const void *opInfo, size_t opInfoLen, uint32_t index, char *opType, | |||
| size_t opTypeLen); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get op type from subscription data | |||
| * | |||
| * @param opInfo [IN] pointer to subscription data | |||
| * @param opInfoLen [IN] memory size of subscription data | |||
| * @param index [IN] index of op array in opInfo | |||
| * @param opName [OUT] obtained op name string | |||
| * @param opNameLen [IN] obtained length of op name string | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclprofGetOpName(const void *opInfo, size_t opInfoLen, uint32_t index, char *opName, | |||
| size_t opNameLen); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get start time of specified op from subscription data | |||
| * | |||
| * @param opInfo [IN] pointer to subscription data | |||
| * @param opInfoLen [IN] memory size of subscription data | |||
| * @param index [IN] index of op array in opInfo | |||
| * | |||
| * @retval start time(us) of specified op with timestamp | |||
| * @retval 0 for failed | |||
| */ | |||
| ACL_FUNC_VISIBILITY uint64_t aclprofGetOpStart(const void *opInfo, size_t opInfoLen, uint32_t index); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get end time of specified op from subscription data | |||
| * | |||
| * @param opInfo [IN] pointer to subscription data | |||
| * @param opInfoLen [IN] memory size of subscription data | |||
| * @param index [IN] index of op array in opInfo | |||
| * | |||
| * @retval end time(us) of specified op with timestamp | |||
| * @retval 0 for failed | |||
| */ | |||
| ACL_FUNC_VISIBILITY uint64_t aclprofGetOpEnd(const void *opInfo, size_t opInfoLen, uint32_t index); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get excution time of specified op from subscription data | |||
| * | |||
| * @param opInfo [IN] pointer to subscription data | |||
| * @param opInfoLen [IN] memory size of subscription data | |||
| * @param index [IN] index of op array in opInfo | |||
| * | |||
| * @retval execution time(us) of specified op with timestamp | |||
| * @retval 0 for failed | |||
| */ | |||
| ACL_FUNC_VISIBILITY uint64_t aclprofGetOpDuration(const void *opInfo, size_t opInfoLen, uint32_t index); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get model id from subscription data | |||
| * | |||
| * @param opInfo [IN] pointer to subscription data | |||
| * @param opInfoLen [IN] memory size of subscription data | |||
| * | |||
| * @retval model id of subscription data | |||
| * @retval 0 for failed | |||
| */ | |||
| ACL_FUNC_VISIBILITY size_t aclprofGetModelId(const void *opInfo, size_t opInfoLen, uint32_t index); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif // INC_EXTERNAL_ACL_PROF_H_ | |||
| @@ -0,0 +1,932 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_EXTERNAL_ACL_ACL_RT_H_ | |||
| #define INC_EXTERNAL_ACL_ACL_RT_H_ | |||
| #include <stdint.h> | |||
| #include <stddef.h> | |||
| #include "acl_base.h" | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| typedef enum aclrtRunMode { | |||
| ACL_DEVICE, | |||
| ACL_HOST, | |||
| } aclrtRunMode; | |||
| typedef enum aclrtTsId { | |||
| ACL_TS_ID_AICORE = 0, | |||
| ACL_TS_ID_AIVECTOR = 1, | |||
| ACL_TS_ID_RESERVED = 2, | |||
| } aclrtTsId; | |||
| typedef enum aclrtEventStatus { | |||
| ACL_EVENT_STATUS_COMPLETE = 0, | |||
| ACL_EVENT_STATUS_NOT_READY = 1, | |||
| ACL_EVENT_STATUS_RESERVED = 2, | |||
| } aclrtEventStatus; | |||
| typedef enum aclrtCallbackBlockType { | |||
| ACL_CALLBACK_NO_BLOCK, | |||
| ACL_CALLBACK_BLOCK, | |||
| } aclrtCallbackBlockType; | |||
| typedef enum aclrtMemcpyKind { | |||
| ACL_MEMCPY_HOST_TO_HOST, | |||
| ACL_MEMCPY_HOST_TO_DEVICE, | |||
| ACL_MEMCPY_DEVICE_TO_HOST, | |||
| ACL_MEMCPY_DEVICE_TO_DEVICE, | |||
| } aclrtMemcpyKind; | |||
| typedef enum aclrtMemMallocPolicy { | |||
| ACL_MEM_MALLOC_HUGE_FIRST, | |||
| ACL_MEM_MALLOC_HUGE_ONLY, | |||
| ACL_MEM_MALLOC_NORMAL_ONLY, | |||
| ACL_MEM_MALLOC_HUGE_FIRST_P2P, | |||
| ACL_MEM_MALLOC_HUGE_ONLY_P2P, | |||
| ACL_MEM_MALLOC_NORMAL_ONLY_P2P, | |||
| } aclrtMemMallocPolicy; | |||
| typedef enum aclrtMemAttr { | |||
| ACL_DDR_MEM, | |||
| ACL_HBM_MEM, | |||
| ACL_DDR_MEM_HUGE, | |||
| ACL_DDR_MEM_NORMAL, | |||
| ACL_HBM_MEM_HUGE, | |||
| ACL_HBM_MEM_NORMAL, | |||
| ACL_DDR_MEM_P2P_HUGE, | |||
| ACL_DDR_MEM_P2P_NORMAL, | |||
| ACL_HBM_MEM_P2P_HUGE, | |||
| ACL_HBM_MEM_P2P_NORMAL, | |||
| } aclrtMemAttr; | |||
| typedef enum aclrtGroupAttr { | |||
| ACL_GROUP_AICORE_INT, | |||
| ACL_GROUP_AIV_INT, | |||
| ACL_GROUP_AIC_INT, | |||
| ACL_GROUP_SDMANUM_INT, | |||
| ACL_GROUP_ASQNUM_INT | |||
| } aclrtGroupAttr; | |||
| typedef struct tagRtGroupInfo aclrtGroupInfo; | |||
| typedef struct rtExceptionInfo aclrtExceptionInfo; | |||
| typedef void (*aclrtCallback)(void *userData); | |||
| typedef void (*aclrtExceptionInfoCallback)(aclrtExceptionInfo *exceptionInfo); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Set a callback function to handle exception information | |||
| * | |||
| * @param callback [IN] callback function to handle exception information | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtSetExceptionInfoCallback(aclrtExceptionInfoCallback callback); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get task id from exception information | |||
| * | |||
| * @param info [IN] pointer of exception information | |||
| * | |||
| * @retval The task id from exception information | |||
| * @retval 0xFFFFFFFF if info is null | |||
| */ | |||
| ACL_FUNC_VISIBILITY uint32_t aclrtGetTaskIdFromExceptionInfo(const aclrtExceptionInfo *info); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get stream id from exception information | |||
| * | |||
| * @param info [IN] pointer of exception information | |||
| * | |||
| * @retval The stream id from exception information | |||
| * @retval 0xFFFFFFFF if info is null | |||
| */ | |||
| ACL_FUNC_VISIBILITY uint32_t aclrtGetStreamIdFromExceptionInfo(const aclrtExceptionInfo *info); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get thread id from exception information | |||
| * | |||
| * @param info [IN] pointer of exception information | |||
| * | |||
| * @retval The thread id of fail task | |||
| * @retval 0xFFFFFFFF if info is null | |||
| */ | |||
| ACL_FUNC_VISIBILITY uint32_t aclrtGetThreadIdFromExceptionInfo(const aclrtExceptionInfo *info); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get device id from exception information | |||
| * | |||
| * @param info [IN] pointer of exception information | |||
| * | |||
| * @retval The thread id of fail task | |||
| * @retval 0xFFFFFFFF if info is null | |||
| */ | |||
| ACL_FUNC_VISIBILITY uint32_t aclrtGetDeviceIdFromExceptionInfo(const aclrtExceptionInfo *info); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief The thread that handles the callback function on the Stream | |||
| * | |||
| * @param threadId [IN] thread ID | |||
| * @param stream [IN] stream handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtSubscribeReport(uint64_t threadId, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Add a callback function to be executed on the host | |||
| * to the task queue of the Stream | |||
| * | |||
| * @param fn [IN] Specify the callback function to be added | |||
| * The function prototype of the callback function is: | |||
| * typedef void (*aclrtCallback)(void *userData); | |||
| * @param userData [IN] User data to be passed to the callback function | |||
| * @param blockType [IN] callback block type | |||
| * @param stream [IN] stream handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtLaunchCallback(aclrtCallback fn, void *userData, aclrtCallbackBlockType blockType, | |||
| aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief After waiting for a specified time, trigger callback processing | |||
| * | |||
| * @par Function | |||
| * The thread processing callback specified by | |||
| * the aclrtSubscribeReport interface | |||
| * | |||
| * @param timeout [IN] timeout value | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtSubscribeReport | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtProcessReport(int32_t timeout); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Cancel thread registration, | |||
| * the callback function on the specified Stream | |||
| * is no longer processed by the specified thread | |||
| * | |||
| * @param threadId [IN] thread ID | |||
| * @param stream [IN] stream handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtUnSubscribeReport(uint64_t threadId, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create context and associates it with the calling thread | |||
| * | |||
| * @par Function | |||
| * The following use cases are supported: | |||
| * @li If you don't call the aclrtCreateContext interface | |||
| * to explicitly create the context, | |||
| * the system will use the default context, which is implicitly created | |||
| * when the aclrtSetDevice interface is called. | |||
| * @li If multiple contexts are created in a process | |||
| * (there is no limit on the number of contexts), | |||
| * the current thread can only use one of them at the same time. | |||
| * It is recommended to explicitly specify the context of the current thread | |||
| * through the aclrtSetCurrentContext interface to increase. | |||
| * the maintainability of the program. | |||
| * | |||
| * @param context [OUT] point to the created context | |||
| * @param deviceId [IN] device to create context on | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtSetDevice | aclrtSetCurrentContext | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtCreateContext(aclrtContext *context, int32_t deviceId); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief destroy context instance | |||
| * | |||
| * @par Function | |||
| * Can only destroy context created through aclrtCreateContext interface | |||
| * | |||
| * @param context [IN] the context to destroy | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtCreateContext | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtDestroyContext(aclrtContext context); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set the context of the thread | |||
| * | |||
| * @par Function | |||
| * The following scenarios are supported: | |||
| * @li If the aclrtCreateContext interface is called in a thread to explicitly | |||
| * create a Context (for example: ctx1), the thread's Context can be specified | |||
| * without calling the aclrtSetCurrentContext interface. | |||
| * The system uses ctx1 as the context of thread1 by default. | |||
| * @li If the aclrtCreateContext interface is not explicitly created, | |||
| * the system uses the default context as the context of the thread. | |||
| * At this time, the aclrtDestroyContext interface cannot be used to release | |||
| * the default context. | |||
| * @li If the aclrtSetCurrentContext interface is called multiple times to | |||
| * set the thread's Context, the last one prevails. | |||
| * | |||
| * @par Restriction | |||
| * @li If the cevice corresponding to the context set for the thread | |||
| * has been reset, you cannot set the context as the context of the thread, | |||
| * otherwise a business exception will result. | |||
| * @li It is recommended to use the context created in a thread. | |||
| * If the aclrtCreateContext interface is called in thread A to create a context, | |||
| * and the context is used in thread B, | |||
| * the user must guarantee the execution order of tasks in the same stream | |||
| * under the same context in two threads. | |||
| * | |||
| * @param context [IN] the current context of the thread | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtCreateContext | aclrtDestroyContext | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtSetCurrentContext(aclrtContext context); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get the context of the thread | |||
| * | |||
| * @par Function | |||
| * If the user calls the aclrtSetCurrentContext interface | |||
| * multiple times to set the context of the current thread, | |||
| * then the last set context is obtained | |||
| * | |||
| * @param context [OUT] the current context of the thread | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtSetCurrentContext | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtGetCurrentContext(aclrtContext *context); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Specify the device to use for the operation | |||
| * implicitly create the default context and the default stream | |||
| * | |||
| * @par Function | |||
| * The following use cases are supported: | |||
| * @li Device can be specified in the process or thread. | |||
| * If you call the aclrtSetDevice interface multiple | |||
| * times to specify the same device, | |||
| * you only need to call the aclrtResetDevice interface to reset the device. | |||
| * @li The same device can be specified for operation | |||
| * in different processes or threads. | |||
| * @li Device is specified in a process, | |||
| * and multiple threads in the process can share this device to explicitly | |||
| * create a Context (aclrtCreateContext interface). | |||
| * @li In multi-device scenarios, you can switch to other devices | |||
| * through the aclrtSetDevice interface in the process. | |||
| * | |||
| * @param deviceId [IN] the device id | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtResetDevice |aclrtCreateContext | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtSetDevice(int32_t deviceId); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Reset the current operating Device and free resources on the device, | |||
| * including the default context, the default stream, | |||
| * and all streams created under the default context, | |||
| * and synchronizes the interface. | |||
| * If the task under the default context or stream has not been completed, | |||
| * the system will wait for the task to complete before releasing it. | |||
| * | |||
| * @par Restriction | |||
| * @li The Context, Stream, and Event that are explicitly created | |||
| * on the device to be reset. Before resetting, | |||
| * it is recommended to follow the following interface calling sequence, | |||
| * otherwise business abnormalities may be caused. | |||
| * @li Interface calling sequence: | |||
| * call aclrtDestroyEvent interface to release Event or | |||
| * call aclrtDestroyStream interface to release explicitly created Stream-> | |||
| * call aclrtDestroyContext to release explicitly created Context-> | |||
| * call aclrtResetDevice interface | |||
| * | |||
| * @param deviceId [IN] the device id | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtResetDevice(int32_t deviceId); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get target device of current thread | |||
| * | |||
| * @param deviceId [OUT] the device id | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtGetDevice(int32_t *deviceId); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get target side | |||
| * | |||
| * @param runMode [OUT] the run mode | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtGetRunMode(aclrtRunMode *runMode); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Wait for compute device to finish | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtSynchronizeDevice(void); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Set Scheduling TS | |||
| * | |||
| * @param tsId [IN] the ts id | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtSetTsDevice(aclrtTsId tsId); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get total device number. | |||
| * | |||
| * @param count [OUT] the device number | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtGetDeviceCount(uint32_t *count); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create event instance | |||
| * | |||
| * @param event [OUT] created event | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtCreateEvent(aclrtEvent *event); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief destroy event instance | |||
| * | |||
| * @par Function | |||
| * Only events created through the aclrtCreateEvent interface can be | |||
| * destroyed, synchronous interfaces. When destroying an event, | |||
| * the user must ensure that the tasks involved in the aclrtSynchronizeEvent | |||
| * interface or the aclrtStreamWaitEvent interface are completed before | |||
| * they are destroyed. | |||
| * | |||
| * @param event [IN] event to destroy | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtCreateEvent | aclrtSynchronizeEvent | aclrtStreamWaitEvent | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtDestroyEvent(aclrtEvent event); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Record an Event in the Stream | |||
| * | |||
| * @param event [IN] event to record | |||
| * @param stream [IN] stream handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtRecordEvent(aclrtEvent event, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Reset an event | |||
| * | |||
| * @par Function | |||
| * Users need to make sure to wait for the tasks in the Stream | |||
| * to complete before resetting the Event | |||
| * | |||
| * @param event [IN] event to reset | |||
| * @param stream [IN] stream handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtResetEvent(aclrtEvent event, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Queries an event's status | |||
| * | |||
| * @param event [IN] event to query | |||
| * @param status [OUT] event status | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtQueryEvent(aclrtEvent event, aclrtEventStatus *status); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Block Host Running, wait event to be complete | |||
| * | |||
| * @param event [IN] event to wait | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtSynchronizeEvent(aclrtEvent event); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief computes the elapsed time between events. | |||
| * | |||
| * @param ms [OUT] time between start and end in ms | |||
| * @param start [IN] starting event | |||
| * @param end [IN] ending event | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtCreateEvent | aclrtRecordEvent | aclrtSynchronizeStream | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtEventElapsedTime(float *ms, aclrtEvent start, aclrtEvent end); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief alloc memory on device | |||
| * | |||
| * @par Function | |||
| * alloc for size linear memory on device | |||
| * and return a pointer to allocated memory by *devPtr | |||
| * | |||
| * @par Restriction | |||
| * @li The memory requested by the aclrtMalloc interface needs to be released | |||
| * through the aclrtFree interface. | |||
| * @li Before calling the media data processing interface, | |||
| * if you need to apply memory on the device to store input or output data, | |||
| * you need to call acldvppMalloc to apply for memory. | |||
| * | |||
| * @param devPtr [OUT] pointer to pointer to allocated memory on device | |||
| * @param size [IN] alloc memory size | |||
| * @param policy [IN] memory alloc policy | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtFree | acldvppMalloc | aclrtMallocCached | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtMalloc(void **devPtr, size_t size, aclrtMemMallocPolicy policy); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief allocate memory on device with cache | |||
| * | |||
| * @par Function | |||
| * alloc for size linear memory on device | |||
| * and return a pointer to allocated memory by *devPtr | |||
| * | |||
| * @par Restriction | |||
| * @li The memory requested by the aclrtMallocCached interface needs to be released | |||
| * through the aclrtFree interface. | |||
| * | |||
| * @param devPtr [OUT] pointer to pointer to allocated memory on device | |||
| * @param size [IN] alloc memory size | |||
| * @param policy [IN] memory alloc policy | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtFree | aclrtMalloc | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtMallocCached(void **devPtr, size_t size, aclrtMemMallocPolicy policy); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief flush cache data to ddr | |||
| * | |||
| * @param devPtr [IN] the pointer that flush data to ddr | |||
| * @param size [IN] flush size | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtMemFlush(void *devPtr, size_t size); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief invalidate cache data | |||
| * | |||
| * @param devPtr [IN] pointer to invalidate cache data | |||
| * @param size [IN] invalidate size | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtMemInvalidate(void *devPtr, size_t size); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief free device memory | |||
| * | |||
| * @par Function | |||
| * can only free memory allocated through the aclrtMalloc interface | |||
| * | |||
| * @param devPtr [IN] Pointer to memory to be freed | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtMalloc | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtFree(void *devPtr); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief alloc memory on host | |||
| * | |||
| * @par Restriction | |||
| * @li The requested memory cannot be used in the Device | |||
| * and needs to be explicitly copied to the Device. | |||
| * @li The memory requested by the aclrtMallocHost interface | |||
| * needs to be released through the aclrtFreeHost interface. | |||
| * | |||
| * @param hostPtr [OUT] pointer to pointer to allocated memory on the host | |||
| * @param size [IN] alloc memory size | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtFreeHost | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtMallocHost(void **hostPtr, size_t size); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief free host memory | |||
| * | |||
| * @par Function | |||
| * can only free memory allocated through the aclrtMallocHost interface | |||
| * | |||
| * @param hostPtr [IN] free memory pointer | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtMallocHost | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtFreeHost(void *hostPtr); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief synchronous memory replication between host and device | |||
| * | |||
| * @param dst [IN] destination address pointer | |||
| * @param destMax [IN] Max length of the destination address memory | |||
| * @param src [IN] source address pointer | |||
| * @param count [IN] the length of byte to copy | |||
| * @param kind [IN] memcpy type | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtMemcpy(void *dst, size_t destMax, const void *src, size_t count, | |||
| aclrtMemcpyKind kind); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Initialize memory and set contents of memory to specified value | |||
| * | |||
| * @par Function | |||
| * The memory to be initialized is on the Host or device side, | |||
| * and the system determines whether | |||
| * it is host or device according to the address | |||
| * | |||
| * @param devPtr [IN] Starting address of memory | |||
| * @param maxCount [IN] Max length of destination address memory | |||
| * @param value [IN] Set value | |||
| * @param count [IN] The length of memory | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtMemset(void *devPtr, size_t maxCount, int32_t value, size_t count); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Asynchronous memory replication between Host and Device | |||
| * | |||
| * @par Function | |||
| * After calling this interface, | |||
| * be sure to call the aclrtSynchronizeStream interface to ensure that | |||
| * the task of memory replication has been completed | |||
| * | |||
| * @par Restriction | |||
| * @li For on-chip Device-to-Device memory copy, | |||
| * both the source and destination addresses must be 64-byte aligned | |||
| * | |||
| * @param dst [IN] destination address pointer | |||
| * @param destMax [IN] Max length of destination address memory | |||
| * @param src [IN] source address pointer | |||
| * @param count [IN] the number of byte to copy | |||
| * @param kind [IN] memcpy type | |||
| * @param stream [IN] asynchronized task stream | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtSynchronizeStream | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtMemcpyAsync(void *dst, size_t destMax, const void *src, size_t count, | |||
| aclrtMemcpyKind kind, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Asynchronous initialize memory | |||
| * and set contents of memory to specified value async | |||
| * | |||
| * @par Function | |||
| * The memory to be initialized is on the Host or device side, | |||
| * and the system determines whether | |||
| * it is host or device according to the address | |||
| * | |||
| * @param devPtr [IN] destination address pointer | |||
| * @param maxCount [IN] Max length of destination address memory | |||
| * @param value [IN] set value | |||
| * @param count [IN] the number of byte to set | |||
| * @param stream [IN] asynchronized task stream | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtSynchronizeStream | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtMemsetAsync(void *devPtr, size_t maxCount, int32_t value, size_t count, | |||
| aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create stream instance | |||
| * | |||
| * @param stream [OUT] the created stream | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtCreateStream(aclrtStream *stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief destroy stream instance | |||
| * | |||
| * @par Function | |||
| * Can only destroy streams created through the aclrtCreateStream interface | |||
| * | |||
| * @par Restriction | |||
| * Before calling the aclrtDestroyStream interface to destroy | |||
| * the specified Stream, you need to call the aclrtSynchronizeStream interface | |||
| * to ensure that the tasks in the Stream have been completed. | |||
| * | |||
| * @param stream [IN] the stream to destroy | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtCreateStream | aclrtSynchronizeStream | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtDestroyStream(aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief block the host until all tasks | |||
| * in the specified stream have completed | |||
| * | |||
| * @param stream [IN] the stream to wait | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtSynchronizeStream(aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Blocks the operation of the specified Stream until | |||
| * the specified Event is completed. | |||
| * Support for multiple streams waiting for the same event. | |||
| * | |||
| * @param stream [IN] the wait stream If using thedefault Stream, set NULL | |||
| * @param event [IN] the event to wait | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtStreamWaitEvent(aclrtStream stream, aclrtEvent event); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief set group | |||
| * | |||
| * @par Function | |||
| * set the task to the corresponding group | |||
| * | |||
| * @param groupId [IN] group id | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtGetGroupCount | aclrtGetAllGroupInfo | aclrtGetGroupInfoDetail | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtSetGroup(int32_t groupId); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get the number of group | |||
| * | |||
| * @par Function | |||
| * get the number of group. if the number of group is zero, | |||
| * it means that group is not supported or group is not created. | |||
| * | |||
| * @param count [OUT] the number of group | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtGetGroupCount(uint32_t *count); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create group information | |||
| * | |||
| * @retval null for failed. | |||
| * @retval OtherValues success. | |||
| * | |||
| * @see aclrtDestroyGroupInfo | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclrtGroupInfo *aclrtCreateGroupInfo(); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief destroy group information | |||
| * | |||
| * @param groupInfo [IN] pointer to group information | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtCreateGroupInfo | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtDestroyGroupInfo(aclrtGroupInfo *groupInfo); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get all group information | |||
| * | |||
| * @param groupInfo [OUT] pointer to group information | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtGetGroupCount | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtGetAllGroupInfo(aclrtGroupInfo *groupInfo); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief get detail information of group | |||
| * | |||
| * @param groupInfo [IN] pointer to group information | |||
| * @param groupId [IN] group index value | |||
| * @param attr [IN] group attribute | |||
| * @param attrValue [OUT] pointer to attribute value | |||
| * @param valueLen [IN] length of attribute value | |||
| * @param paramRetSize [OUT] pointer to real length of attribute value | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtGetGroupCount | aclrtGetAllGroupInfo | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtGetGroupInfoDetail(const aclrtGroupInfo *groupInfo, int32_t groupId, | |||
| aclrtGroupAttr attr, void *attrValue, size_t valueLen, | |||
| size_t *paramRetSize); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief checking whether current device and peer device support the p2p feature | |||
| * | |||
| * @param canAccessPeer [OUT] pointer to save the checking result | |||
| * @param deviceId [IN] current device id | |||
| * @param peerDeviceId [IN] peer device id | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtDeviceEnablePeerAccess | aclrtDeviceDisablePeerAccess | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtDeviceCanAccessPeer(int32_t *canAccessPeer, int32_t deviceId, int32_t peerDeviceId); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief enable the peer device to support the p2p feature | |||
| * | |||
| * @param peerDeviceId [IN] the peer device id | |||
| * @param flags [IN] reserved field, now it must be zero | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtDeviceCanAccessPeer | aclrtDeviceDisablePeerAccess | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtDeviceEnablePeerAccess(int32_t peerDeviceId, uint32_t flags); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief disable the peer device to support the p2p function | |||
| * | |||
| * @param peerDeviceId [IN] the peer device id | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see aclrtDeviceCanAccessPeer | aclrtDeviceEnablePeerAccess | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtDeviceDisablePeerAccess(int32_t peerDeviceId); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Obtain the free memory and total memory of specified attribute. | |||
| * the specified memory include normal memory and huge memory. | |||
| * | |||
| * @param attr [IN] the memory attribute of specified device | |||
| * @param free [OUT] the free memory of specified device | |||
| * @param total [OUT] the total memory of specified device. | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclrtGetMemInfo(aclrtMemAttr attr, size_t *free, size_t *total); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif // INC_EXTERNAL_ACL_ACL_RT_H_ | |||
| @@ -0,0 +1,276 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_EXTERNAL_ACL_ACL_TDT_H_ | |||
| #define INC_EXTERNAL_ACL_ACL_TDT_H_ | |||
| #include "acl/acl_base.h" | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| enum acltdtTensorType { | |||
| ACL_TENSOR_DATA_UNDEFINED = -1, | |||
| ACL_TENSOR_DATA_TENSOR, | |||
| ACL_TENSOR_DATA_END_OF_SEQUENCE, | |||
| ACL_TENSOR_DATA_ABNORMAL | |||
| }; | |||
| typedef struct acltdtDataItem acltdtDataItem; | |||
| typedef struct acltdtDataset acltdtDataset; | |||
| typedef struct acltdtChannelHandle acltdtChannelHandle; | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get tensor type from item | |||
| * | |||
| * @param dataItem [IN] pointer to the data item | |||
| * | |||
| * @retval Tensor type. | |||
| * @retval ACL_DT_UNDEFINED if dataItem is null | |||
| */ | |||
| ACL_FUNC_VISIBILITY acltdtTensorType acltdtGetTensorTypeFromItem(const acltdtDataItem *dataItem); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get data type from item | |||
| * | |||
| * @param dataItem [IN] pointer to the data item | |||
| * | |||
| * @retval Data type. | |||
| * @retval ACL_DT_UNDEFINED if dataItem is null | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclDataType acltdtGetDataTypeFromItem(const acltdtDataItem *dataItem); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get data address from item | |||
| * | |||
| * @param dataItem [IN] pointer to data item | |||
| * | |||
| * @retval null for failed | |||
| * @retval OtherValues success | |||
| */ | |||
| ACL_FUNC_VISIBILITY void *acltdtGetDataAddrFromItem(const acltdtDataItem *dataItem); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get data size from item | |||
| * | |||
| * @param dataItem [IN] pointer to data item | |||
| * | |||
| * @retval 0 for failed | |||
| * @retval OtherValues success | |||
| */ | |||
| ACL_FUNC_VISIBILITY size_t acltdtGetDataSizeFromItem(const acltdtDataItem *dataItem); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get dim's number from item | |||
| * | |||
| * @param dataItem [IN] pointer to data item | |||
| * | |||
| * @retval 0 for failed | |||
| * @retval OtherValues success | |||
| */ | |||
| ACL_FUNC_VISIBILITY size_t acltdtGetDimNumFromItem(const acltdtDataItem *dataItem); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get dims from item | |||
| * | |||
| * @param dataItem [IN] the struct of data item | |||
| * @param dims [IN|OUT] pointer to the dims of dataTtem | |||
| * @param dimNum [IN] the size of the dims | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError acltdtGetDimsFromItem(const acltdtDataItem *dataItem, int64_t *dims, size_t dimNum); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Create the struct of data item | |||
| * | |||
| * @param tdtType [IN] Tdt tensor type | |||
| * @param dims [IN] pointer of tdtDataItem's dims | |||
| * @param dimNum [IN] Dim number | |||
| * @param dataType [IN] Data type | |||
| * @param data [IN] Data pointer | |||
| * @param size [IN] Data size | |||
| * | |||
| * @retval null for failed | |||
| * @retval OtherValues success | |||
| * | |||
| * @see acltdtDestroyDataItem | |||
| */ | |||
| ACL_FUNC_VISIBILITY acltdtDataItem *acltdtCreateDataItem(acltdtTensorType tdtType, const int64_t *dims, size_t dimNum, | |||
| aclDataType dataType, void *data, size_t size); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Destroy the struct of data item | |||
| * | |||
| * @param dataItem [IN] pointer to the data item | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see acltdtCreateDataItem | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError acltdtDestroyDataItem(acltdtDataItem *dataItem); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Create the tdt dataset | |||
| * | |||
| * @retval null for failed | |||
| * @retval OtherValues success | |||
| * | |||
| * @see acltdtDestroyDataset | |||
| */ | |||
| ACL_FUNC_VISIBILITY acltdtDataset *acltdtCreateDataset(); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Destroy the tdt dataset | |||
| * | |||
| * @param dataset [IN] pointer to the dataset | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see acltdtCreateDataset | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError acltdtDestroyDataset(acltdtDataset *dataset); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get the data item | |||
| * | |||
| * @param dataset [IN] pointer to the dataset | |||
| * @param index [IN] index of the dataset | |||
| * | |||
| * @retval null for failed | |||
| * @retval OtherValues success | |||
| * | |||
| * @see acltdtAddDataItem | |||
| */ | |||
| ACL_FUNC_VISIBILITY acltdtDataItem *acltdtGetDataItem(const acltdtDataset *dataset, size_t index); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get the data item | |||
| * | |||
| * @param dataset [OUT] pointer to the dataset | |||
| * @param dataItem [IN] pointer to the data item | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see acltdtGetDataItem | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError acltdtAddDataItem(acltdtDataset *dataset, acltdtDataItem *dataItem); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Get the size of dataset | |||
| * | |||
| * @param dataset [IN] pointer to the dataset | |||
| * | |||
| * @retval 0 for failed | |||
| * @retval OtherValues success | |||
| */ | |||
| ACL_FUNC_VISIBILITY size_t acltdtGetDatasetSize(const acltdtDataset *dataset); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Stop the channel | |||
| * | |||
| * @param handle [IN] pointer to the channel handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see acltdtCreateChannel | acltdtDestroyChannel | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError acltdtStopChannel(acltdtChannelHandle *handle); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Create the channel | |||
| * | |||
| * @param deviceId [IN] the device id | |||
| * @param name [IN] the channel's name | |||
| * | |||
| * @retval null for failed | |||
| * @retval OtherValues success | |||
| * | |||
| * @see acltdtStopChannel | acltdtDestroyChannel | |||
| */ | |||
| ACL_FUNC_VISIBILITY acltdtChannelHandle *acltdtCreateChannel(uint32_t deviceId, const char *name); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Destroy the channel | |||
| * | |||
| * @param handle [IN] pointer to the channel handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see acltdtCreateChannel | acltdtStopChannel | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError acltdtDestroyChannel(acltdtChannelHandle *handle); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Send tensor to device | |||
| * | |||
| * @param handle [IN] pointer to the channel handle | |||
| * @param dataset [IN] pointer to the dataset | |||
| * @param timeout [IN] to be reserved, now it must be -1 | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see acltdtReceiveTensor | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError acltdtSendTensor(const acltdtChannelHandle *handle, const acltdtDataset *dataset, | |||
| int32_t timeout); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief Receive tensor from device | |||
| * | |||
| * @param handle [IN] pointer to the channel handle | |||
| * @param dataset [OUT] pointer to the dataset | |||
| * @param timeout [IN] to be reserved, now it must be -1 | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| * | |||
| * @see acltdtSendTensor | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError acltdtReceiveTensor(const acltdtChannelHandle *handle, acltdtDataset *dataset, | |||
| int32_t timeout); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif // INC_EXTERNAL_ACL_ACL_TDT_H_ | |||
| @@ -0,0 +1,57 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_EXTERNAL_GE_GE_ERROR_CODES_H_ | |||
| #define INC_EXTERNAL_GE_GE_ERROR_CODES_H_ | |||
| #include <stddef.h> | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| static const uint32_t ACL_ERROR_GE_PARAM_INVALID = 145000; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_NOT_INIT = 145001; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID = 145002; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_ID_INVALID = 145003; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID = 145004; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION = 145005; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID = 145006; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID = 145007; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_QUEUE_ID_INVALID = 145008; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED = 145009; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID = 145010; | |||
| static const uint32_t ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID = 145011; | |||
| static const uint32_t ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID = 145012; | |||
| static const uint32_t ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID = 145013; | |||
| static const uint32_t ACL_ERROR_GE_AIPP_BATCH_EMPTY = 145014; | |||
| static const uint32_t ACL_ERROR_GE_AIPP_NOT_EXIST = 145015; | |||
| static const uint32_t ACL_ERROR_GE_AIPP_MODE_INVALID = 145016; | |||
| static const uint32_t ACL_ERROR_GE_OP_TASK_TYPE_INVALID = 145017; | |||
| static const uint32_t ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID = 145018; | |||
| static const uint32_t ACL_ERROR_GE_MEMORY_ALLOCATION = 245000; | |||
| static const uint32_t ACL_ERROR_GE_INTERNAL_ERROR = 545000; | |||
| static const uint32_t ACL_ERROR_GE_LOAD_MODEL = 545001; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_LOAD_MODEL_PARTITION_FAILED = 545002; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_LOAD_WEIGHT_PARTITION_FAILED = 545003; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED = 545004; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_LOAD_KERNEL_PARTITION_FAILED = 545005; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA = 545006; | |||
| static const uint32_t ACL_ERROR_GE_COMMAND_HANDLE = 545007; | |||
| static const uint32_t ACL_ERROR_GE_GET_TENSOR_INFO = 545008; | |||
| static const uint32_t ACL_ERROR_GE_UNLOAD_MODEL = 545009; | |||
| #ifdef __cplusplus | |||
| } // namespace ge | |||
| #endif | |||
| #endif // INC_EXTERNAL_GE_GE_ERROR_CODES_H_ | |||
| @@ -0,0 +1,91 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef __INC_EXTERNEL_RT_ERROR_CODES_H__ | |||
| #define __INC_EXTERNEL_RT_ERROR_CODES_H__ | |||
| #include <stddef.h> | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| static const int32_t ACL_RT_SUCCESS = 0; // success | |||
| static const int32_t ACL_ERROR_RT_PARAM_INVALID = 107000; // param invalid | |||
| static const int32_t ACL_ERROR_RT_INVALID_DEVICEID = 107001; // invalid device id | |||
| static const int32_t ACL_ERROR_RT_CONTEXT_NULL = 107002; // current context null | |||
| static const int32_t ACL_ERROR_RT_STREAM_CONTEXT = 107003; // stream not in current context | |||
| static const int32_t ACL_ERROR_RT_MODEL_CONTEXT = 107004; // model not in current context | |||
| static const int32_t ACL_ERROR_RT_STREAM_MODEL = 107005; // stream not in model | |||
| static const int32_t ACL_ERROR_RT_EVENT_TIMESTAMP_INVALID = 107006; // event timestamp invalid | |||
| static const int32_t ACL_ERROR_RT_EVENT_TIMESTAMP_REVERSAL = 107007; // event timestamp reversal | |||
| static const int32_t ACL_ERROR_RT_ADDR_UNALIGNED = 107008; // memory address unaligned | |||
| static const int32_t ACL_ERROR_RT_FILE_OPEN = 107009; // open file failed | |||
| static const int32_t ACL_ERROR_RT_FILE_WRITE = 107010; // write file failed | |||
| static const int32_t ACL_ERROR_RT_STREAM_SUBSCRIBE = 107011; // error subscribe stream | |||
| static const int32_t ACL_ERROR_RT_THREAD_SUBSCRIBE = 107012; // error subscribe thread | |||
| static const int32_t ACL_ERROR_RT_GROUP_NOT_SET = 107013; // group not set | |||
| static const int32_t ACL_ERROR_RT_GROUP_NOT_CREATE = 107014; // group not create | |||
| static const int32_t ACL_ERROR_RT_STREAM_NO_CB_REG = 107015; // callback not register to stream | |||
| static const int32_t ACL_ERROR_RT_INVALID_MEMORY_TYPE = 107016; // invalid memory type | |||
| static const int32_t ACL_ERROR_RT_FEATURE_NOT_SUPPROT = 207000; // feature not support | |||
| static const int32_t ACL_ERROR_RT_MEMORY_ALLOCATION = 207001; // memory allocation error | |||
| static const int32_t ACL_ERROR_RT_MEMORY_FREE = 207002; // memory free error | |||
| static const int32_t ACL_ERROR_RT_INTERNEL_ERROR = 507000; // runtime internel error | |||
| static const int32_t ACL_ERROR_RT_TS_ERROR = 507001; // ts internel error | |||
| static const int32_t ACL_ERROR_RT_STREAM_TASK_FULL = 507002; // task full in stream | |||
| static const int32_t ACL_ERROR_RT_STREAM_TASK_EMPTY = 507003; // task empty in stream | |||
| static const int32_t ACL_ERROR_RT_STREAM_NOT_COMPLETE = 507004; // stream not complete | |||
| static const int32_t ACL_ERROR_RT_END_OF_SEQUENCE = 507005; // end of sequence | |||
| static const int32_t ACL_ERROR_RT_EVENT_NOT_COMPLETE = 507006; // event not complete | |||
| static const int32_t ACL_ERROR_RT_CONTEXT_RELEASE_ERROR = 507007; // context release error | |||
| static const int32_t ACL_ERROR_RT_SOC_VERSION = 507008; // soc version error | |||
| static const int32_t ACL_ERROR_RT_TASK_TYPE_NOT_SUPPORT = 507009; // task type not support | |||
| static const int32_t ACL_ERROR_RT_LOST_HEARTBEAT = 507010; // ts lost heartbeat | |||
| static const int32_t ACL_ERROR_RT_MODEL_EXECUTE = 507011; // model execute failed | |||
| static const int32_t ACL_ERROR_RT_REPORT_TIMEOUT = 507012; // report timeout | |||
| static const int32_t ACL_ERROR_RT_SYS_DMA = 507013; // sys dma error | |||
| static const int32_t ACL_ERROR_RT_AICORE_TIMEOUT = 507014; // aicore timeout | |||
| static const int32_t ACL_ERROR_RT_AICORE_EXCEPTION = 507015; // aicore exception | |||
| static const int32_t ACL_ERROR_RT_AICORE_TRAP_EXCEPTION = 507016; // aicore trap exception | |||
| static const int32_t ACL_ERROR_RT_AICPU_TIMEOUT = 507017; // aicpu timeout | |||
| static const int32_t ACL_ERROR_RT_AICPU_EXCEPTION = 507018; // aicpu exception | |||
| static const int32_t ACL_ERROR_RT_AICPU_DATADUMP_RSP_ERR = 507019; // aicpu datadump response error | |||
| static const int32_t ACL_ERROR_RT_AICPU_MODEL_RSP_ERR = 507020; // aicpu model operate response error | |||
| static const int32_t ACL_ERROR_RT_PROFILING_ERROR = 507021; // profiling error | |||
| static const int32_t ACL_ERROR_RT_IPC_ERROR = 507022; // ipc error | |||
| static const int32_t ACL_ERROR_RT_MODEL_ABORT_NORMAL = 507023; // model abort normal | |||
| static const int32_t ACL_ERROR_RT_KERNEL_UNREGISTERING = 507024; // kernel unregistering | |||
| static const int32_t ACL_ERROR_RT_RINGBUFFER_NOT_INIT = 507025; // ringbuffer not init | |||
| static const int32_t ACL_ERROR_RT_RINGBUFFER_NO_DATA = 507026; // ringbuffer no data | |||
| static const int32_t ACL_ERROR_RT_KERNEL_LOOKUP = 507027; // kernel lookup error | |||
| static const int32_t ACL_ERROR_RT_KERNEL_DUPLICATE = 507028; // kernel register duplicate | |||
| static const int32_t ACL_ERROR_RT_DEBUG_REGISTER_FAIL = 507029; // debug register failed | |||
| static const int32_t ACL_ERROR_RT_DEBUG_UNREGISTER_FAIL = 507030; // debug unregister failed | |||
| static const int32_t ACL_ERROR_RT_LABEL_CONTEXT = 507031; // label not in current context | |||
| static const int32_t ACL_ERROR_RT_PROGRAM_USE_OUT = 507032; // program register num use out | |||
| static const int32_t ACL_ERROR_RT_DEV_SETUP_ERROR = 507033; // device setup error | |||
| static const int32_t ACL_ERROR_RT_DRV_INTERNEL_ERROR = 507899; // drv internel error | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif // __INC_EXTERNEL_RT_ERROR_CODES_H__ | |||
| @@ -0,0 +1,333 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_EXTERNAL_ACL_OPS_ACL_CBLAS_H_ | |||
| #define INC_EXTERNAL_ACL_OPS_ACL_CBLAS_H_ | |||
| #include "acl/acl.h" | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| typedef enum aclTransType { ACL_TRANS_N, ACL_TRANS_T, ACL_TRANS_NZ, ACL_TRANS_NZ_T } aclTransType; | |||
| typedef enum aclComputeType { ACL_COMPUTE_HIGH_PRECISION, ACL_COMPUTE_LOW_PRECISION } aclComputeType; | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief perform the matrix-vector multiplication | |||
| * | |||
| * @param transA [IN] transpose type of matrix A | |||
| * @param m [IN] number of rows of matrix A | |||
| * @param n [IN] number of columns of matrix A | |||
| * @param alpha [IN] pointer to scalar used for multiplication. | |||
| * of same type as dataTypeC | |||
| * @param a [IN] pointer to matrix A | |||
| * @param lda [IN] leading dimension used to store the matrix A | |||
| * @param dataTypeA [IN] datatype of matrix A | |||
| * @param x [IN] pointer to vector x | |||
| * @param incx [IN] stride between consecutive elements of vector x | |||
| * @param dataTypeX [IN] datatype of vector x | |||
| * @param beta [IN] pointer to scalar used for multiplication. | |||
| * of same type as dataTypeC If beta == 0, | |||
| * then y does not have to be a valid input | |||
| * @param y [IN|OUT] pointer to vector y | |||
| * @param incy [IN] stride between consecutive elements of vector y | |||
| * @param dataTypeY [IN] datatype of vector y | |||
| * @param type [IN] computation type | |||
| * @param stream [IN] stream | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclblasGemvEx(aclTransType transA, int m, int n, const void *alpha, const void *a, int lda, | |||
| aclDataType dataTypeA, const void *x, int incx, aclDataType dataTypeX, | |||
| const void *beta, void *y, int incy, aclDataType dataTypeY, | |||
| aclComputeType type, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create a handle for performing the matrix-vector multiplication | |||
| * | |||
| * @param transA [IN] transpose type of matrix A | |||
| * @param m [IN] number of rows of matrix A | |||
| * @param n [IN] number of columns of matrix A | |||
| * @param dataTypeA [IN] datatype of matrix A | |||
| * @param dataTypeX [IN] datatype of vector x | |||
| * @param dataTypeY [IN] datatype of vector y | |||
| * @param type [IN] computation type | |||
| * @param handle [OUT] pointer to the pointer to the handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclblasCreateHandleForGemvEx(aclTransType transA, int m, int n, aclDataType dataTypeA, | |||
| aclDataType dataTypeX, aclDataType dataTypeY, | |||
| aclComputeType type, aclopHandle **handle); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief perform the matrix-vector multiplication | |||
| * | |||
| * @param transA [IN] transpose type of matrix A | |||
| * @param m [IN] number of rows of matrix A | |||
| * @param n [IN] number of columns of matrix A | |||
| * @param alpha [IN] pointer to scalar used for multiplication | |||
| * @param a [IN] pointer to matrix A | |||
| * @param lda [IN] leading dimension used to store the matrix A | |||
| * @param x [IN] pointer to vector x | |||
| * @param incx [IN] stride between consecutive elements of vector x | |||
| * @param beta [IN] pointer to scalar used for multiplication. | |||
| * If beta value == 0, | |||
| * then y does not have to be a valid input | |||
| * @param y [IN|OUT] pointer to vector y | |||
| * @param incy [IN] stride between consecutive elements of vector y | |||
| * @param type [IN] computation type | |||
| * @param stream [IN] stream | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclblasHgemv(aclTransType transA, int m, int n, const aclFloat16 *alpha, | |||
| const aclFloat16 *a, int lda, const aclFloat16 *x, int incx, | |||
| const aclFloat16 *beta, aclFloat16 *y, int incy, aclComputeType type, | |||
| aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create a handle for performing the matrix-vector multiplication | |||
| * | |||
| * @param transA [IN] transpose type of matrix A | |||
| * @param m [IN] number of rows of matrix A | |||
| * @param n [IN] number of columns of matrix A | |||
| * @param type [IN] computation type | |||
| * @param handle [OUT] pointer to the pointer to the handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclblasCreateHandleForHgemv(aclTransType transA, int m, int n, aclComputeType type, | |||
| aclopHandle **handle); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief perform the matrix-vector multiplication | |||
| * | |||
| * @param transA [IN] transpose type of matrix A | |||
| * @param m [IN] number of rows of matrix A | |||
| * @param n [IN] number of columns of matrix A | |||
| * @param alpha [IN] pointer to scalar used for multiplication | |||
| * @param a [IN] pointer to matrix A | |||
| * @param lda [IN] leading dimension used to store the matrix A | |||
| * @param x [IN] pointer to vector x | |||
| * @param incx [IN] stride between consecutive elements of vector x | |||
| * @param beta [IN] pointer to scalar used for multiplication. | |||
| * If beta value == 0, | |||
| * then y does not have to be a valid input | |||
| * @param y [IN|OUT] pointer to vector y | |||
| * @param incy [IN] stride between consecutive elements of vector y | |||
| * @param type [IN] computation type | |||
| * @param stream [IN] stream | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclblasS8gemv(aclTransType transA, int m, int n, const int32_t *alpha, const int8_t *a, | |||
| int lda, const int8_t *x, int incx, const int32_t *beta, int32_t *y, | |||
| int incy, aclComputeType type, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create a handle for performing the matrix-vector multiplication | |||
| * | |||
| * @param transA [IN] transpose type of matrix A | |||
| * @param m [IN] number of rows of matrix A | |||
| * @param n [IN] number of columns of matrix A | |||
| * @param handle [OUT] pointer to the pointer to the handle | |||
| * @param type [IN] computation type | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclblasCreateHandleForS8gemv(aclTransType transA, int m, int n, aclComputeType type, | |||
| aclopHandle **handle); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief perform the matrix-matrix multiplication | |||
| * | |||
| * @param transA [IN] transpose type of matrix A | |||
| * @param transB [IN] transpose type of matrix B | |||
| * @param transC [IN] transpose type of matrix C | |||
| * @param m [IN] number of rows of matrix A and matrix C | |||
| * @param n [IN] number of columns of matrix B and matrix C | |||
| * @param k [IN] number of columns of matrix A and rows of matrix B | |||
| * @param alpha [IN] pointer to scalar used for multiplication. of same type as dataTypeC | |||
| * @param matrixA [IN] pointer to matrix A | |||
| * @param lda [IN] leading dimension array used to store matrix A | |||
| * @param dataTypeA [IN] datatype of matrix A | |||
| * @param matrixB [IN] pointer to matrix B | |||
| * @param ldb [IN] leading dimension array used to store matrix B | |||
| * @param dataTypeB [IN] datatype of matrix B | |||
| * @param beta [IN] pointer to scalar used for multiplication. | |||
| * of same type as dataTypeC If beta == 0, | |||
| * then matrixC does not have to be a valid input | |||
| * @param matrixC [IN|OUT] pointer to matrix C | |||
| * @param ldc [IN] leading dimension array used to store matrix C | |||
| * @param dataTypeC [IN] datatype of matrix C | |||
| * @param type [IN] computation type | |||
| * @param stream [IN] stream | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclblasGemmEx(aclTransType transA, aclTransType transB, aclTransType transC, int m, int n, | |||
| int k, const void *alpha, const void *matrixA, int lda, | |||
| aclDataType dataTypeA, const void *matrixB, int ldb, aclDataType dataTypeB, | |||
| const void *beta, void *matrixC, int ldc, aclDataType dataTypeC, | |||
| aclComputeType type, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create a handle for performing the matrix-matrix multiplication | |||
| * | |||
| * @param transA [IN] transpose type of matrix A | |||
| * @param transB [IN] transpose type of matrix B | |||
| * @param transC [IN] transpose type of matrix C | |||
| * @param m [IN] number of rows of matrix A and matrix C | |||
| * @param n [IN] number of columns of matrix B and matrix C | |||
| * @param k [IN] number of columns of matrix A and rows of matrix B | |||
| * @param dataTypeA [IN] datatype of matrix A | |||
| * @param dataTypeB [IN] datatype of matrix B | |||
| * @param dataTypeC [IN] datatype of matrix C | |||
| * @param type [IN] computation type | |||
| * @param handle [OUT] pointer to the pointer to the handle | |||
| * @param type [IN] computation type | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclblasCreateHandleForGemmEx(aclTransType transA, aclTransType transB, aclTransType transC, | |||
| int m, int n, int k, aclDataType dataTypeA, | |||
| aclDataType dataTypeB, aclDataType dataTypeC, | |||
| aclComputeType type, aclopHandle **handle); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief perform the matrix-matrix multiplication | |||
| * | |||
| * @param transA [IN] transpose type of matrix A | |||
| * @param transB [IN] transpose type of matrix B | |||
| * @param transC [IN] transpose type of matrix C | |||
| * @param m [IN] number of rows of matrix A and matrix C | |||
| * @param n [IN] number of columns of matrix B and matrix C | |||
| * @param k [IN] number of columns of matrix A and rows of matrix B | |||
| * @param alpha [IN] pointer to scalar used for multiplication | |||
| * @param matrixA [IN] pointer to matrix A | |||
| * @param lda [IN] leading dimension used to store the matrix A | |||
| * @param matrixB [IN] pointer to matrix B | |||
| * @param ldb [IN] leading dimension used to store the matrix B | |||
| * @param beta [IN] pointer to scalar used for multiplication. | |||
| * If beta value == 0, | |||
| * then matrixC does not have to be a valid input | |||
| * @param matrixC [IN|OUT] pointer to matrix C | |||
| * @param ldc [IN] leading dimension used to store the matrix C | |||
| * @param type [IN] computation type | |||
| * @param stream [IN] stream | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclblasHgemm(aclTransType transA, aclTransType transB, aclTransType transC, int m, int n, | |||
| int k, const aclFloat16 *alpha, const aclFloat16 *matrixA, int lda, | |||
| const aclFloat16 *matrixB, int ldb, const aclFloat16 *beta, | |||
| aclFloat16 *matrixC, int ldc, aclComputeType type, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create a handle for performing the matrix-matrix multiplication | |||
| * | |||
| * @param transA [IN] transpose type of matrix A | |||
| * @param transB [IN] transpose type of matrix B | |||
| * @param transC [IN] transpose type of matrix C | |||
| * @param m [IN] number of rows of matrix A and matrix C | |||
| * @param n [IN] number of columns of matrix B and matrix C | |||
| * @param k [IN] number of columns of matrix A and rows of matrix B | |||
| * @param type [IN] computation type | |||
| * @param handle [OUT] pointer to the pointer to the handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclblasCreateHandleForHgemm(aclTransType transA, aclTransType transB, aclTransType transC, | |||
| int m, int n, int k, aclComputeType type, | |||
| aclopHandle **handle); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief perform the matrix-matrix multiplication | |||
| * | |||
| * @param transA [IN] transpose type of matrix A | |||
| * @param transB [IN] transpose type of matrix B | |||
| * @param transC [IN] transpose type of matrix C | |||
| * @param m [IN] number of rows of matrix A and matrix C | |||
| * @param n [IN] number of columns of matrix B and matrix C | |||
| * @param k [IN] number of columns of matrix A and rows of matrix B | |||
| * @param alpha [IN] pointer to scalar used for multiplication | |||
| * @param matrixA [IN] pointer to matrix A | |||
| * @param lda [IN] leading dimension used to store the matrix A | |||
| * @param matrixB [IN] pointer to matrix B | |||
| * @param ldb [IN] leading dimension used to store the matrix B | |||
| * @param beta [IN] pointer to scalar used for multiplication. | |||
| * If beta value == 0, | |||
| * then matrixC does not have to be a valid input | |||
| * @param matrixC [IN|OUT] pointer to matrix C | |||
| * @param ldc [IN] leading dimension used to store the matrix C | |||
| * @param type [IN] computation type | |||
| * @param stream [IN] stream | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclblasS8gemm(aclTransType transA, aclTransType transB, aclTransType transC, int m, int n, | |||
| int k, const int32_t *alpha, const int8_t *matrixA, int lda, | |||
| const int8_t *matrixB, int ldb, const int32_t *beta, int32_t *matrixC, | |||
| int ldc, aclComputeType type, aclrtStream stream); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief create a handle for performing the matrix-matrix multiplication | |||
| * | |||
| * @param transA [IN] transpose type of matrix A | |||
| * @param transB [IN] transpose type of matrix B | |||
| * @param transC [IN] transpose type of matrix C | |||
| * @param m [IN] number of rows of matrix A and matrix C | |||
| * @param n [IN] number of columns of matrix B and matrix C | |||
| * @param k [IN] number of columns of matrix A and rows of matrix B | |||
| * @param type [IN] computation type | |||
| * @param handle [OUT] pointer to the pointer to the handle | |||
| * | |||
| * @retval ACL_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ACL_FUNC_VISIBILITY aclError aclblasCreateHandleForS8gemm(aclTransType transA, aclTransType transB, aclTransType transC, | |||
| int m, int n, int k, aclComputeType type, | |||
| aclopHandle **handle); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif // INC_EXTERNAL_ACL_OPS_ACL_CBLAS_H_ | |||
| @@ -29,16 +29,26 @@ | |||
| namespace ge { | |||
| typedef uint32_t (*pCallBackFunc)(uint32_t graph_id, const std::map<std::string, ge::Tensor> ¶ms_list); | |||
| namespace session { | |||
| typedef uint32_t (*pCallBackFunc)(uint32_t graph_id, const std::map<AscendString, ge::Tensor> ¶ms_list); | |||
| } | |||
| // Initialize GE | |||
| ATTRIBUTED_DEPRECATED(Status GEInitialize(const std::map<AscendString, AscendString> &)) | |||
| Status GEInitialize(const std::map<std::string, std::string> &options); | |||
| Status GEInitialize(const std::map<AscendString, AscendString> &options); | |||
| // Finalize GE, release all resources | |||
| Status GEFinalize(); | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(Session(const std::map<AscendString, AscendString> &)) | |||
| explicit Session(const std::map<std::string, std::string> &options); | |||
| explicit Session(const std::map<AscendString, AscendString> &options); | |||
| ~Session(); | |||
| /// | |||
| @@ -57,8 +67,38 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { | |||
| /// @param [in] options graph options | |||
| /// @return Status result of function | |||
| /// | |||
| ATTRIBUTED_DEPRECATED(Status AddGraph(uint32_t, const Graph &, const std::map<AscendString, AscendString> &)) | |||
| Status AddGraph(uint32_t graphId, const Graph &graph, const std::map<std::string, std::string> &options); | |||
| /// | |||
| /// @ingroup client | |||
| /// @brief add a graph with a specific graphId and graphOptions | |||
| /// @param [in] graphId graph id | |||
| /// @param [in] graph the graph | |||
| /// @param [in] options graph options | |||
| /// @return Status result of function | |||
| /// | |||
| Status AddGraph(uint32_t graphId, const Graph &graph, const std::map<AscendString, AscendString> &options); | |||
| /// | |||
| /// @ingroup client | |||
| /// @brief add a copy graph with a specific graphId | |||
| /// @param [in] graphId graph id | |||
| /// @param [in] graph the graph | |||
| /// @return Status result of function | |||
| /// | |||
| Status AddGraphWithCopy(uint32_t graph_id, const Graph &graph); | |||
| /// | |||
| /// @ingroup client | |||
| /// @brief add a copy graph with a specific graphId and graphOptions | |||
| /// @param [in] graphId graph id | |||
| /// @param [in] graph the graph | |||
| /// @param [in] options graph options | |||
| /// @return Status result of function | |||
| /// | |||
| Status AddGraphWithCopy(uint32_t graph_id, const Graph &graph, const std::map<AscendString, AscendString> &options); | |||
| /// | |||
| /// @ingroup ge_graph | |||
| /// @brief remove a graph of the session with specific session id | |||
| @@ -105,8 +145,18 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { | |||
| /// @param [out] var_values: variable values | |||
| /// @return Status result of function | |||
| /// | |||
| ATTRIBUTED_DEPRECATED(Status GetVariables(const std::vector<std::string> &, std::vector<Tensor> &)) | |||
| Status GetVariables(const std::vector<std::string> &var_names, std::vector<Tensor> &var_values); | |||
| /// | |||
| /// @ingroup ge_graph | |||
| /// @brief get variables in the session with specific session id | |||
| /// @param [in] var_names: variable names | |||
| /// @param [out] var_values: variable values | |||
| /// @return Status result of function | |||
| /// | |||
| Status GetVariables(const std::vector<AscendString> &var_names, std::vector<Tensor> &var_values); | |||
| /// | |||
| /// @ingroup ge_graph | |||
| /// @brief register callback func with specific summary or checkpoint by users | |||
| @@ -116,8 +166,11 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { | |||
| /// Please ensure that the implementation of the function is trusted. | |||
| /// @return Status result of function | |||
| /// | |||
| ATTRIBUTED_DEPRECATED(Status RegisterCallBackFunc(const char *, const session::pCallBackFunc &)) | |||
| Status RegisterCallBackFunc(const std::string &key, const pCallBackFunc &callback); | |||
| Status RegisterCallBackFunc(const char *key, const session::pCallBackFunc &callback); | |||
| bool IsGraphNeedRebuild(uint32_t graphId); | |||
| private: | |||
| @@ -19,8 +19,15 @@ | |||
| #include <map> | |||
| #include <string> | |||
| #include "ge_error_codes.h" | |||
| namespace ge { | |||
| #ifdef __GNUC__ | |||
| #define ATTRIBUTED_DEPRECATED(replacement) __attribute__((deprecated("Please use " #replacement " instead."))) | |||
| #else | |||
| #define ATTRIBUTED_DEPRECATED(replacement) __declspec(deprecated("Please use " #replacement " instead.")) | |||
| #endif | |||
| class StatusFactory { | |||
| public: | |||
| static StatusFactory *Instance() { | |||
| @@ -36,6 +43,17 @@ class StatusFactory { | |||
| err_desc_[err] = desc; | |||
| } | |||
| void RegisterErrorNo(uint32_t err, const char *desc) { | |||
| if (desc == nullptr) { | |||
| return; | |||
| } | |||
| std::string error_desc = desc; | |||
| if (err_desc_.find(err) != err_desc_.end()) { | |||
| return; | |||
| } | |||
| err_desc_[err] = error_desc; | |||
| } | |||
| std::string GetErrDesc(uint32_t err) { | |||
| auto iter_find = err_desc_.find(err); | |||
| if (iter_find == err_desc_.end()) { | |||
| @@ -55,6 +73,7 @@ class StatusFactory { | |||
| class ErrorNoRegisterar { | |||
| public: | |||
| ErrorNoRegisterar(uint32_t err, const std::string &desc) { StatusFactory::Instance()->RegisterErrorNo(err, desc); } | |||
| ErrorNoRegisterar(uint32_t err, const char *desc) { StatusFactory::Instance()->RegisterErrorNo(err, desc); } | |||
| ~ErrorNoRegisterar() {} | |||
| }; | |||
| @@ -66,11 +85,47 @@ class ErrorNoRegisterar { | |||
| ((0xFF & (static_cast<uint8_t>(modid))) << 12) | (0x0FFF & (static_cast<uint16_t>(value))); \ | |||
| const ErrorNoRegisterar g_##name##_errorno(name, desc); | |||
| #define GE_ERRORNO_EXTERNAL(name, desc) const ErrorNoRegisterar g_##name##_errorno(name, desc); | |||
| using Status = uint32_t; | |||
| // General error code | |||
| GE_ERRORNO(0, 0, 0, 0, 0, SUCCESS, 0, "success"); | |||
| GE_ERRORNO(0b11, 0b11, 0b111, 0xFF, 0b11111, FAILED, 0xFFF, "failed"); /*lint !e401*/ | |||
| GE_ERRORNO(0b11, 0b11, 0b111, 0xFF, 0b11111, FAILED, 0xFFF, "failed"); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_PARAM_INVALID, "Parameter invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_NOT_INIT, "GE executor not initialized yet."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "Model file path invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_ID_INVALID, "Model id invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID, "Model key path invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION, "Model does not support encryption."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, "Data size of model invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID, "Model addr invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_QUEUE_ID_INVALID, "Queue id of model invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED, "The model loaded repeatedly."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID, "Model partition num invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID, "Dynamic input addr invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID, "Dynamic input size invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID, "Dynamic batch size invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_AIPP_BATCH_EMPTY, "AIPP batch parameter empty."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_AIPP_NOT_EXIST, "AIPP parameter not exist."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_AIPP_MODE_INVALID, "AIPP mode invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_OP_TASK_TYPE_INVALID, "Task type invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID, "Kernel type invalid."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_MEMORY_ALLOCATION, "Memory allocation error."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_INTERNAL_ERROR, "Internal error."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_LOAD_MODEL, "Load model error."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_MODEL_PARTITION_FAILED, "Failed to load model partition."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_WEIGHT_PARTITION_FAILED, "Failed to load weight partition."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED, "Failed to load task partition."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_KERNEL_PARTITION_FAILED, "Failed to load op kernel partition."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA, "Failed to release the model data."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_COMMAND_HANDLE, "Command handle error."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_GET_TENSOR_INFO, "Get tensor info error."); | |||
| GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_UNLOAD_MODEL, "Load model error."); | |||
| } // namespace ge | |||
| #endif // INC_EXTERNAL_GE_GE_API_ERROR_CODES_H_ | |||
| @@ -65,7 +65,47 @@ const char *const OPTION_EXEC_ENABLE_TAILING_OPTIMIZATION = "ge.exec.isTailingOp | |||
| // Option key: memory init | |||
| const char *const GRAPH_MEMORY_MAX_SIZE = "ge.graphMemoryMaxSize"; | |||
| const char *const VARIABLE_MEMORY_MAX_SIZE = "ge.variableMemoryMaxSize"; | |||
| namespace configure_option { | |||
| const char *const STREAM_NUM = "ge.streamNum"; | |||
| const char *const HEAD_STREAM = "ge.headStream"; | |||
| const char *const PERF_LEVEL = "ge.perfLevel"; | |||
| const char *const ENCRYPT_MODE = "ge.encryptMode"; | |||
| const char *const EK_FILE = "ge.ekFile"; | |||
| const char *const CERT_FILE = "ge.certFile"; | |||
| const char *const HW_KEY_FILE = "ge.hwKeyFile"; | |||
| const char *const PRIVATE_KEY_FILE = "ge.privateKeyFile"; | |||
| const char *const FRAMEWORK_TYPE = "ge.frameworkType"; | |||
| const char *const CALIBRATION_CONF_FILE = "ge.calibrationConfFile"; | |||
| const char *const INSERT_OP_FILE = "ge.insertOpFile"; | |||
| const char *const OUTPUT_NODE_NAME = "ge.outputNodeName"; | |||
| const char *const COMPRESS_FLAG = "ge.compressFlag"; | |||
| const char *const PRECISION_MODE = "ge.exec.precision_mode"; | |||
| const char *const SINGLE_OP_FLAG = "ge.exec.single_op"; | |||
| const char *const TRAIN_FLAG = "ge.trainFlag"; | |||
| const char *const RUN_FLAG = "ge.runFlag"; | |||
| const char *const LOCAL_FMKOP_FLAG = "ge.enabledLocalFmkop"; | |||
| const char *const TBE_PLUGIN_PATH_FLAG = "ge.TBE_plugin_path"; | |||
| const char *const DDK_VERSION_FLAG = "ge.DDK_version"; | |||
| const char *const GE_FE_FLAG = "ge.feFlag"; | |||
| const char *const STREAM_MAX_PARALLEL_NUM = "ge.streamMaxParallelNum"; | |||
| const char *const OUTPUT_DATATYPE = "ge.outputDatatype"; | |||
| const char *const OP_SELECT_IMPL_MODE = "ge.opSelectImplmode"; | |||
| const char *const OPTYPELIST_FOR_IMPLMODE = "ge.optypelistForImplmode"; | |||
| const char *const HCOM_PARALLEL = "ge.hcomParallel"; | |||
| const char *const AUTO_TUNE_MODE = "ge.autoTuneMode"; | |||
| const char *const SOC_VERSION = "ge.socVersion"; | |||
| const char *const CORE_TYPE = "ge.engineType"; | |||
| const char *const AICORE_NUM = "ge.aicoreNum"; | |||
| const char *const L1_FUSION = "ge.l1Fusion"; | |||
| const char *const BUFFER_OPTIMIZE = "ge.bufferOptimize"; | |||
| const char *const ENABLE_SMALL_CHANNEL = "ge.enableSmallChannel"; | |||
| const char *const ENABLE_COMPRESS_WEIGHT = "ge.enableCompressWeight"; | |||
| const char *const FUSION_SWITCH_FILE = "ge.fusionSwitchFile"; | |||
| const char *const SAVE_ORIGINAL_MODEL = "ge.saveOriginalModel"; | |||
| const char *const ORIGINAL_MODEL_FILE = "ge.originalModelFile"; | |||
| const char *const INPUT_FP16_NODES = "ge.INPUT_NODES_SET_FP16"; | |||
| const char *const OP_DEBUG_LEVEL = "ge.opDebugLevel"; | |||
| } // namespace configure_option | |||
| // Configure stream num by Session constructor options param, | |||
| // its value should be int32_t type, default value is "1" | |||
| const std::string STREAM_NUM = "ge.streamNum"; | |||
| @@ -174,6 +214,9 @@ const std::string HCOM_PARALLEL = "ge.hcomParallel"; | |||
| // configure whether to use dynamic batch size | |||
| const char *const kDynamicBatchSize = "ge.dynamicBatchSize"; | |||
| const std::string INPUT_SHAPE = "ge.inputShape"; | |||
| const std::string DYNAMIC_NODE_TYPE = "ge.dynamicNodeType"; | |||
| // configure whether to use dynamic image size | |||
| const char *const kDynamicImageSize = "ge.dynamicImageSize"; | |||
| @@ -222,6 +265,18 @@ const char *const OPTION_GE_MAX_DUMP_OP_NUM = "ge.maxDumpOpNum"; | |||
| // Its value should be "0" or "1", default value is "1" | |||
| const char *const ENABLE_PRINT_OP_PASS = "ge.enablePrintOpPass"; | |||
| // Configure operator compilation path | |||
| // Its value should be file path, default value is "./" | |||
| const char *const DEBUG_DIR = "ge.debugDir"; | |||
| // Configure operator compiler cache path | |||
| // Its value should be file path, default value is "./" | |||
| const char *const OP_COMPILER_CACHE_DIR = "ge.op_compiler_cache_dir"; | |||
| // Configure operator compiler cache mode | |||
| // Its value should be "disable", "enable" or "force", default value is "disable" | |||
| const char *const OP_COMPILER_CACHE_MODE = "ge.op_compiler_cache_mode"; | |||
| // Configure whether to use single stream. | |||
| // Its value should be "true" or "false", default value is "false" | |||
| const char *const ENABLE_SINGLE_STREAM = "ge.enableSingleStream"; | |||
| @@ -233,6 +288,12 @@ const std::string INPUT_FP16_NODES = "ge.INPUT_NODES_SET_FP16"; | |||
| // 0: close debug; 1: open TBE compiler; 2: open ccec compiler | |||
| const std::string OP_DEBUG_LEVEL = "ge.opDebugLevel"; | |||
| // Configure model bank path | |||
| const std::string MDL_BANK_PATH_FLAG = "ge.mdl_bank_path"; | |||
| // Configure op bank path | |||
| const std::string OP_BANK_PATH_FLAG = "ge.op_bank_path"; | |||
| // Graph run mode | |||
| enum GraphRunMode { PREDICTION = 0, TRAIN }; | |||
| @@ -273,6 +334,11 @@ namespace ir_option { | |||
| static const char *const INPUT_FORMAT = "input_format"; | |||
| static const char *const INPUT_SHAPE = "input_shape"; | |||
| static const char *const OP_NAME_MAP = "op_name_map"; | |||
| static const char *const IS_DYNAMIC_INPUT = "is_dynamic_input"; | |||
| static const char *const IS_INPUT_ADJUST_HW_LAYOUT = "is_input_adjust_hw_layout"; | |||
| static const char *const IS_OUTPUT_ADJUST_HW_LAYOUT = "is_output_adjust_hw_layout"; | |||
| static const char *const ENABLE_SCOPE_FUSION_PASSES = "enable_scope_fusion_passes"; | |||
| static const char *const OUTPUT = "output"; | |||
| static const char *const DYNAMIC_BATCH_SIZE = kDynamicBatchSize; | |||
| static const char *const DYNAMIC_IMAGE_SIZE = kDynamicImageSize; | |||
| static const char *const DYNAMIC_DIMS = kDynamicDims; | |||
| @@ -295,14 +361,50 @@ static const char *const OUT_NODES = ge::OUTPUT_NODE_NAME.c_str(); | |||
| static const char *const INPUT_FP16_NODES = ge::INPUT_FP16_NODES.c_str(); | |||
| static const char *const LOG_LEVEL = "log"; | |||
| static const char *const OPTYPELIST_FOR_IMPLMODE = ge::OPTYPELIST_FOR_IMPLMODE.c_str(); | |||
| static const char *const DEBUG_DIR = ge::DEBUG_DIR; | |||
| static const char *const OP_COMPILER_CACHE_DIR = ge::OP_COMPILER_CACHE_DIR; | |||
| static const char *const OP_COMPILER_CACHE_MODE = ge::OP_COMPILER_CACHE_MODE; | |||
| static const char *const MDL_BANK_PATH_FLAG = ge::MDL_BANK_PATH_FLAG.c_str(); | |||
| static const char *const OP_BANK_PATH_FLAG = ge::OP_BANK_PATH_FLAG.c_str(); | |||
| static const char *const OP_DEBUG_LEVEL = ge::OP_DEBUG_LEVEL.c_str(); | |||
| // for interface: aclgrphBuildModel | |||
| const std::set<std::string> ir_builder_suppported_options = { | |||
| INPUT_FORMAT, INPUT_SHAPE, OP_NAME_MAP, | |||
| DYNAMIC_BATCH_SIZE, DYNAMIC_IMAGE_SIZE, DYNAMIC_DIMS, | |||
| INSERT_OP_FILE, PRECISION_MODE, EXEC_DISABLE_REUSED_MEMORY, | |||
| AUTO_TUNE_MODE, OUTPUT_TYPE, OUT_NODES, | |||
| INPUT_FP16_NODES, LOG_LEVEL}; | |||
| const std::set<std::string> ir_builder_suppported_options = {INPUT_FORMAT, | |||
| INPUT_SHAPE, | |||
| OP_NAME_MAP, | |||
| DYNAMIC_BATCH_SIZE, | |||
| DYNAMIC_IMAGE_SIZE, | |||
| DYNAMIC_DIMS, | |||
| INSERT_OP_FILE, | |||
| PRECISION_MODE, | |||
| EXEC_DISABLE_REUSED_MEMORY, | |||
| AUTO_TUNE_MODE, | |||
| OUTPUT_TYPE, | |||
| OUT_NODES, | |||
| INPUT_FP16_NODES, | |||
| LOG_LEVEL, | |||
| OP_DEBUG_LEVEL, | |||
| DEBUG_DIR, | |||
| OP_COMPILER_CACHE_DIR, | |||
| OP_COMPILER_CACHE_MODE, | |||
| MDL_BANK_PATH_FLAG, | |||
| OP_BANK_PATH_FLAG}; | |||
| // for interface: aclgrphParse | |||
| const std::set<std::string> ir_parser_suppported_options = {INPUT_FORMAT, | |||
| INPUT_SHAPE, | |||
| OP_NAME_MAP, | |||
| IS_DYNAMIC_INPUT, | |||
| INPUT_FP16_NODES, | |||
| IS_INPUT_ADJUST_HW_LAYOUT, | |||
| IS_OUTPUT_ADJUST_HW_LAYOUT, | |||
| OUTPUT, | |||
| OUTPUT_TYPE, | |||
| OUT_NODES, | |||
| COMPRESS_WEIGHT_CONF, | |||
| ENABLE_SCOPE_FUSION_PASSES, | |||
| LOG_LEVEL}; | |||
| // for interface: aclgrphBuildInitialize | |||
| const std::set<std::string> global_options = {CORE_TYPE, | |||
| SOC_VERSION, | |||
| @@ -317,7 +419,10 @@ const std::set<std::string> global_options = {CORE_TYPE, | |||
| FUSION_SWITCH_FILE, | |||
| ENABLE_SMALL_CHANNEL, | |||
| OP_SELECT_IMPL_MODE, | |||
| OPTYPELIST_FOR_IMPLMODE}; | |||
| OPTYPELIST_FOR_IMPLMODE, | |||
| DEBUG_DIR, | |||
| OP_COMPILER_CACHE_DIR, | |||
| OP_COMPILER_CACHE_MODE}; | |||
| } // namespace ir_option | |||
| } // namespace ge | |||
| @@ -0,0 +1,58 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_EXTERNAL_GE_GE_ERROR_CODES_H_ | |||
| #define INC_EXTERNAL_GE_GE_ERROR_CODES_H_ | |||
| #include <stddef.h> | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| static const uint32_t ACL_ERROR_GE_PARAM_INVALID = 145000; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_NOT_INIT = 145001; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID = 145002; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_ID_INVALID = 145003; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID = 145004; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION = 145005; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID = 145006; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID = 145007; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_QUEUE_ID_INVALID = 145008; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED = 145009; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID = 145010; | |||
| static const uint32_t ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID = 145011; | |||
| static const uint32_t ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID = 145012; | |||
| static const uint32_t ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID = 145013; | |||
| static const uint32_t ACL_ERROR_GE_AIPP_BATCH_EMPTY = 145014; | |||
| static const uint32_t ACL_ERROR_GE_AIPP_NOT_EXIST = 145015; | |||
| static const uint32_t ACL_ERROR_GE_AIPP_MODE_INVALID = 145016; | |||
| static const uint32_t ACL_ERROR_GE_OP_TASK_TYPE_INVALID = 145017; | |||
| static const uint32_t ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID = 145018; | |||
| static const uint32_t ACL_ERROR_GE_MEMORY_ALLOCATION = 245000; | |||
| static const uint32_t ACL_ERROR_GE_INTERNAL_ERROR = 545000; | |||
| static const uint32_t ACL_ERROR_GE_LOAD_MODEL = 545001; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_LOAD_MODEL_PARTITION_FAILED = 545002; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_LOAD_WEIGHT_PARTITION_FAILED = 545003; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED = 545004; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_LOAD_KERNEL_PARTITION_FAILED = 545005; | |||
| static const uint32_t ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA = 545006; | |||
| static const uint32_t ACL_ERROR_GE_COMMAND_HANDLE = 545007; | |||
| static const uint32_t ACL_ERROR_GE_GET_TENSOR_INFO = 545008; | |||
| static const uint32_t ACL_ERROR_GE_UNLOAD_MODEL = 545009; | |||
| #ifdef __cplusplus | |||
| } // namespace ge | |||
| #endif | |||
| #endif // INC_EXTERNAL_GE_GE_ERROR_CODES_H_ | |||
| @@ -44,8 +44,11 @@ struct ModelBufferData { | |||
| * @retval GRAPH_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ATTRIBUTED_DEPRECATED(graphStatus aclgrphBuildInitialize(std::map<AscendString, AscendString> &)) | |||
| graphStatus aclgrphBuildInitialize(std::map<std::string, std::string> global_options); | |||
| graphStatus aclgrphBuildInitialize(std::map<AscendString, AscendString> &global_options); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief build model.Notice the model is stored in buffer | |||
| @@ -63,9 +66,14 @@ void aclgrphBuildFinalize(); | |||
| * @retval GRAPH_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ATTRIBUTED_DEPRECATED(graphStatus aclgrphBuildModel(const ge::Graph &, const std::map<AscendString, AscendString> &, | |||
| ModelBufferData &)) | |||
| graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map<std::string, std::string> &build_options, | |||
| ModelBufferData &model); | |||
| graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map<AscendString, AscendString> &build_options, | |||
| ModelBufferData &model); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief save model buffer to file | |||
| @@ -75,8 +83,11 @@ graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map<std::string | |||
| * @retval GRAPH_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| ATTRIBUTED_DEPRECATED(graphStatus aclgrphSaveModel(const char *, const ModelBufferData &)) | |||
| graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData &model); | |||
| graphStatus aclgrphSaveModel(const char *output_file, const ModelBufferData &model); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief query IR interface version | |||
| @@ -89,5 +100,26 @@ graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData &m | |||
| */ | |||
| graphStatus aclgrphGetIRVersion(int *major_version, int *minor_version, int *patch_version); | |||
| }; // namespace ge | |||
| #endif | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief infer shape and data type | |||
| * | |||
| * @param graph[IN] the graph ready to build | |||
| * @retval GRAPH_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| graphStatus aclgrphInferShapeAndType(ge::Graph &graph); | |||
| /** | |||
| * @ingroup AscendCL | |||
| * @brief dump graph | |||
| * | |||
| * @param graph[IN] the graph ready to build | |||
| * @param file[IN] file path | |||
| * @param file[IN] file path string len | |||
| * @retval GRAPH_SUCCESS The function is successfully executed. | |||
| * @retval OtherValues Failure | |||
| */ | |||
| graphStatus aclgrphDumpGraph(const ge::Graph &graph, const char *file, const size_t len); | |||
| }; // namespace ge | |||
| #endif // INC_EXTERNAL_GE_IR_BUILD_H_ | |||
| @@ -25,22 +25,11 @@ | |||
| namespace ge { | |||
| enum ProfDataTypeConfig { | |||
| kProfAcl = 0x0001, | |||
| kProfTaskTime = 0x0002, | |||
| kProfAiCoreMetrics = 0x0004, | |||
| kProfAicpuTrace = 0x0008, | |||
| kProfModelExecute = 0x0010, | |||
| kProfRuntimeApi = 0x0020, | |||
| kProfRuntimeTrace = 0x0040, | |||
| kProfScheduleTimeline = 0x0080, | |||
| kProfScheduleTrace = 0x0100, | |||
| kProfAiVectorCoreMetrics = 0x0200, | |||
| kProfSubtaskTime = 0x0400, | |||
| kProfTrainingTrace = 0x0800, | |||
| kProfHcclTrace = 0x1000, | |||
| kProfDataProcess = 0x2000, | |||
| kProfTaskTrace = 0x3842, | |||
| kProfModelLoad = 0x8000000000000000 | |||
| kProfHcclTrace = 0x1000 | |||
| }; | |||
| enum ProfilingAicoreMetrics { | |||
| @@ -49,20 +38,64 @@ enum ProfilingAicoreMetrics { | |||
| kAicoreSynchronization = 2, | |||
| kAicoreMemory = 3, | |||
| kAicoreInternalMemory = 4, | |||
| kAicoreStall = 5, | |||
| kAicoreMetricsAll = 255 // only for op_trace | |||
| kAicoreStall = 5 | |||
| }; | |||
| typedef struct ProfAicoreEvents ProfAicoreEvents; | |||
| typedef struct aclgrphProfConfig aclgrphProfConfig; | |||
| /// | |||
| /// @ingroup AscendCL | |||
| /// @brief Initialize the profiling and set profiling configuration path | |||
| /// @param [in] profiler_path: configuration path of profiling | |||
| /// @param [in] length: length of configuration path | |||
| /// @return Status result of function | |||
| /// | |||
| Status aclgrphProfInit(const char *profiler_path, uint32_t length); | |||
| /// | |||
| /// @ingroup AscendCL | |||
| /// @brief Finalize profiling | |||
| /// @return Status result of function | |||
| /// | |||
| Status aclgrphProfFinalize(); | |||
| /// | |||
| /// @ingroup AscendCL | |||
| /// @brief Create data of type aclgrphProfConfig | |||
| /// @param [in] deviceid_list: device id list | |||
| /// @param [in] device_nums: device numbers | |||
| /// @param [in] aicore_metrics: type of aicore metrics | |||
| /// @param [in] aicore_events: pointer to aicore events be reserved, only support NULL now | |||
| /// @param [in] data_type_config: modules need profiling | |||
| /// @return Status result of function | |||
| /// | |||
| aclgrphProfConfig *aclgrphProfCreateConfig(uint32_t *deviceid_list, uint32_t device_nums, | |||
| ProfilingAicoreMetrics aicore_metrics, ProfAicoreEvents *aicore_events, | |||
| uint64_t data_type_config); | |||
| /// | |||
| /// @ingroup AscendCL | |||
| /// @brief Destroy data of type aclgrphProfConfig | |||
| /// @param [in] profiler_config: config of profiling | |||
| /// @return Status result of function | |||
| /// | |||
| Status aclgrphProfDestroyConfig(aclgrphProfConfig *profiler_config); | |||
| /// | |||
| /// @ingroup AscendCL | |||
| /// @brief Start profiling of modules which is configured by profiler config | |||
| /// @param [in] profiler_config: config of profiling | |||
| /// @return Status result of function | |||
| /// | |||
| Status aclgrphProfStart(aclgrphProfConfig *profiler_config); | |||
| /// | |||
| /// @ingroup AscendCL | |||
| /// @brief Stop profiling of modules which is configured by profiler config | |||
| /// @param [in] profiler_config: config of profiling | |||
| /// @return Status result of function | |||
| /// | |||
| Status aclgrphProfStop(aclgrphProfConfig *profiler_config); | |||
| } // namespace ge | |||
| @@ -0,0 +1,64 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_EXTERNAL_GRAPH_ASCEND_STRING_H_ | |||
| #define INC_EXTERNAL_GRAPH_ASCEND_STRING_H_ | |||
| #include <string> | |||
| #include <memory> | |||
| #include <functional> | |||
| namespace ge { | |||
| class AscendString { | |||
| public: | |||
| AscendString() = default; | |||
| ~AscendString() = default; | |||
| AscendString(const char* name); | |||
| const char* GetString() const; | |||
| bool operator<(const AscendString& d) const; | |||
| bool operator>(const AscendString& d) const; | |||
| bool operator<=(const AscendString& d) const; | |||
| bool operator>=(const AscendString& d) const; | |||
| bool operator==(const AscendString& d) const; | |||
| bool operator!=(const AscendString& d) const; | |||
| private: | |||
| std::shared_ptr<std::string> name_; | |||
| }; | |||
| } // namespace ge | |||
| namespace std { | |||
| template <> | |||
| struct hash<ge::AscendString> { | |||
| size_t operator()(const ge::AscendString& name) const { | |||
| std::string str_name; | |||
| if (name.GetString() != nullptr) { | |||
| str_name = name.GetString(); | |||
| } | |||
| return hash<string>()(str_name); | |||
| } | |||
| }; | |||
| } // namespace std | |||
| #endif // INC_EXTERNAL_GRAPH_ASCEND_STRING_H_ | |||
| @@ -23,6 +23,7 @@ | |||
| #include <vector> | |||
| #include "./ge_error_codes.h" | |||
| #include "ascend_string.h" | |||
| using std::make_shared; | |||
| using std::map; | |||
| @@ -34,7 +35,6 @@ using std::vector; | |||
| namespace ge { | |||
| class AttrValueImpl; | |||
| /*lint -e148*/ | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrValue { | |||
| public: | |||
| using INT = int64_t; | |||
| @@ -61,6 +61,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrValue { | |||
| return val; | |||
| } | |||
| graphStatus GetValue(AscendString &val); | |||
| std::shared_ptr<AttrValueImpl> impl; | |||
| private: | |||
| @@ -70,6 +72,5 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrValue { | |||
| VALUE_SET_GET_DEC(AttrValue::FLOAT) | |||
| #undef VALUE_SET_GET_DEC | |||
| }; | |||
| /*lint +e148*/ | |||
| } // namespace ge | |||
| #endif // INC_EXTERNAL_GRAPH_ATTR_VALUE_H_ | |||
| @@ -28,11 +28,18 @@ namespace ge { | |||
| #else | |||
| #define GE_FUNC_DEV_VISIBILITY | |||
| #endif | |||
| #ifdef __GNUC__ | |||
| #define ATTRIBUTED_DEPRECATED(replacement) __attribute__((deprecated("Please use " #replacement " instead."))) | |||
| #else | |||
| #define ATTRIBUTED_DEPRECATED(replacement) __declspec(deprecated("Please use " #replacement " instead.")) | |||
| #endif | |||
| using graphStatus = uint32_t; | |||
| const graphStatus GRAPH_FAILED = 0xFFFFFFFF; | |||
| const graphStatus GRAPH_SUCCESS = 0; | |||
| const graphStatus GRAPH_NOT_CHANGED = 1343242304; | |||
| const graphStatus GRAPH_PARAM_INVALID = 50331649; | |||
| const graphStatus GRAPH_NODE_WITHOUT_CONST_INPUT = 50331648; | |||
| } // namespace ge | |||
| #endif // INC_EXTERNAL_GRAPH_GE_ERROR_CODES_H_ | |||
| @@ -0,0 +1,129 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_EXTERNAL_GRAPH_NODE_H_ | |||
| #define INC_EXTERNAL_GRAPH_NODE_H_ | |||
| #include <vector> | |||
| #include <cstdint> | |||
| #include "./ge_error_codes.h" | |||
| #include "./types.h" | |||
| #include "./tensor.h" | |||
| #include "./ascend_string.h" | |||
| namespace ge { | |||
| class AttrValue; | |||
| class GNode; | |||
| class OpDesc; | |||
| class Graph; | |||
| class ComputeGraph; | |||
| using GNodePtr = std::shared_ptr<GNode>; | |||
| using GraphPtr = std::shared_ptr<Graph>; | |||
| using OpBytes = std::vector<uint8_t>; | |||
| using OpDescPtr = std::shared_ptr<OpDesc>; | |||
| using ComputeGraphPtr = std::shared_ptr<ComputeGraph>; | |||
| class NodeImpl; | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GNode { | |||
| public: | |||
| GNode(); | |||
| ~GNode() = default; | |||
| graphStatus GetType(AscendString &type) const; | |||
| graphStatus GetName(AscendString &name) const; | |||
| std::pair<GNodePtr, int32_t> GetInDataNodesAndPortIndexs(const int32_t index) const; | |||
| std::vector<GNodePtr> GetInControlNodes() const; | |||
| std::vector<std::pair<GNodePtr, int32_t>> GetOutDataNodesAndPortIndexs(const int32_t index) const; | |||
| std::vector<GNodePtr> GetOutControlNodes() const; | |||
| graphStatus GetInputConstData(const int32_t index, Tensor &data) const; | |||
| graphStatus GetInputIndexByName(const AscendString &name, int32_t &index); | |||
| graphStatus GetOutputIndexByName(const AscendString &name, int32_t &index); | |||
| size_t GetInputsSize() const; | |||
| size_t GetOutputsSize() const; | |||
| graphStatus GetInputDesc(const int32_t index, TensorDesc &tensor_desc) const; | |||
| graphStatus UpdateInputDesc(const int32_t index, const TensorDesc &tensor_desc); | |||
| graphStatus GetOutputDesc(const int32_t index, TensorDesc &tensor_desc) const; | |||
| graphStatus UpdateOutputDesc(const int32_t index, const TensorDesc &tensor_desc); | |||
| graphStatus GetAttr(const AscendString &name, int64_t &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, int32_t &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, uint32_t &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, float &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, AscendString &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, bool &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, Tensor &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, std::vector<int64_t> &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, std::vector<int32_t> &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, std::vector<uint32_t> &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, std::vector<float> &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, std::vector<AscendString> &attr_values) const; | |||
| graphStatus GetAttr(const AscendString &name, std::vector<bool> &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, std::vector<Tensor> &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, OpBytes &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, std::vector<std::vector<int64_t>> &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, std::vector<ge::DataType> &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, ge::DataType &attr_value) const; | |||
| graphStatus GetAttr(const AscendString &name, AttrValue &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, int64_t &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, int32_t &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, uint32_t &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, float &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, AscendString &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, bool &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, Tensor &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, std::vector<int64_t> &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, std::vector<int32_t> &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, std::vector<uint32_t> &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, std::vector<float> &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, std::vector<AscendString> &attr_values) const; | |||
| graphStatus SetAttr(const AscendString &name, std::vector<bool> &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, std::vector<Tensor> &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, OpBytes &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, std::vector<std::vector<int64_t>> &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, std::vector<ge::DataType> &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, ge::DataType &attr_value) const; | |||
| graphStatus SetAttr(const AscendString &name, AttrValue &attr_value) const; | |||
| bool HasAttr(const AscendString &name); | |||
| graphStatus GetSubgraph(uint32_t index, GraphPtr &graph) const; | |||
| graphStatus GetALLSubgraphs(std::vector<GraphPtr> &graph_list) const; | |||
| private: | |||
| std::shared_ptr<NodeImpl> impl_; | |||
| friend class NodeAdapter; | |||
| }; | |||
| } // namespace ge | |||
| #endif // INC_EXTERNAL_GRAPH_NODE_H_ | |||
| @@ -23,18 +23,24 @@ | |||
| #include <vector> | |||
| #include "./operator.h" | |||
| #include "./gnode.h" | |||
| namespace ge { | |||
| class Graph; | |||
| class GraphImpl; | |||
| using GraphImplPtr = std::shared_ptr<GraphImpl>; | |||
| using GraphPtr = std::shared_ptr<Graph>; | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Graph { | |||
| friend class GraphUtils; | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(Graph(const char *)) | |||
| explicit Graph(const std::string &name); | |||
| explicit Graph(const char *name); | |||
| Graph() = default; | |||
| ~Graph() = default; | |||
| @@ -45,26 +51,47 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Graph { | |||
| Graph &SetOutputs(const std::vector<std::pair<Operator, std::vector<size_t>>> &output_indexs); | |||
| ATTRIBUTED_DEPRECATED(Graph &SetOutputs(const std::vector < std::pair < ge::Operator, AscendString) &) | |||
| Graph &SetOutputs(const std::vector<std::pair<ge::Operator, std::string>> &outputs); | |||
| Graph &SetOutputs(const std::vector<std::pair<ge::Operator, AscendString>> &outputs); | |||
| Graph &SetTargets(const std::vector<Operator> &targets); | |||
| bool IsValid() const; | |||
| graphStatus AddOp(const ge::Operator &op); | |||
| graphStatus FindOpByName(const string &name, ge::Operator &op) const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus FindOpByName(const char *, ge::Operator &)) | |||
| graphStatus FindOpByName(const std::string &name, ge::Operator &op) const; | |||
| graphStatus FindOpByName(const char *name, ge::Operator &op) const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus FindOpByType(const char *, std::vector<ge::Operator> &)) | |||
| graphStatus FindOpByType(const std::string &type, std::vector<ge::Operator> &ops) const; | |||
| graphStatus FindOpByType(const string &type, std::vector<ge::Operator> &ops) const; | |||
| graphStatus FindOpByType(const char *type, std::vector<ge::Operator> &ops) const; | |||
| graphStatus GetAllOpName(std::vector<string> &op_name) const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAllOpName(std::vector<AscendString> &) const) | |||
| graphStatus GetAllOpName(std::vector<std::string> &op_name) const; | |||
| graphStatus SaveToFile(const string &file_name) const; | |||
| graphStatus GetAllOpName(std::vector<AscendString> &names) const; | |||
| graphStatus LoadFromFile(const string &file_name); | |||
| ATTRIBUTED_DEPRECATED(graphStatus SaveToFile(const char *file_name) const) | |||
| graphStatus SaveToFile(const std::string &file_name) const; | |||
| graphStatus SaveToFile(const char *file_name) const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus LoadFromFile(const char *)) | |||
| graphStatus LoadFromFile(const std::string &file_name); | |||
| graphStatus LoadFromFile(const char *file_name); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetName(AscendString &) const) | |||
| const std::string &GetName() const; | |||
| graphStatus GetName(AscendString &name) const; | |||
| /// | |||
| /// Set is need train iteration. | |||
| /// If set true, it means this graph need to be run iteration some | |||
| @@ -73,6 +100,22 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Graph { | |||
| /// | |||
| void SetNeedIteration(bool need_iteration); | |||
| std::vector<GNode> GetAllNodes() const; | |||
| std::vector<GNode> GetDirectNode() const; | |||
| graphStatus RemoveNode(GNode &node); | |||
| graphStatus RemoveEdge(GNode &src_node, const int32_t src_port_index, GNode &dst_node, const int32_t dst_port_index); | |||
| GNode AddNodeByOp(const Operator &op); | |||
| graphStatus AddDataEdge(GNode &src_node, const int32_t src_port_index, GNode &dst_node, const int32_t dst_port_index); | |||
| graphStatus AddControlEdge(GNode &src_node, GNode &dst_node); | |||
| static GraphPtr ConstructFromInputs(const std::vector<Operator> &inputs, const AscendString &name); | |||
| private: | |||
| GraphImplPtr impl_{nullptr}; | |||
| }; | |||
| @@ -23,6 +23,7 @@ | |||
| #include "./tensor.h" | |||
| #include "./types.h" | |||
| #include "ascend_string.h" | |||
| namespace ge { | |||
| class InferenceContext; | |||
| @@ -63,8 +64,13 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InferenceContext { | |||
| void SetOutputHandleShapesAndTypes(const std::vector<std::vector<ShapeAndType>> &shapes_and_types); | |||
| void SetOutputHandleShapesAndTypes(std::vector<std::vector<ShapeAndType>> &&shapes_and_types); | |||
| ATTRIBUTED_DEPRECATED(void SetMarks(const std::vector<AscendString> &)) | |||
| void SetMarks(const std::vector<std::string> &marks); | |||
| void SetMarks(const std::vector<AscendString> &marks); | |||
| ATTRIBUTED_DEPRECATED(void GetMarks(std::vector<AscendString> &) const) | |||
| const std::vector<std::string> &GetMarks() const; | |||
| void GetMarks(std::vector<AscendString> &marks) const; | |||
| static std::unique_ptr<InferenceContext> Create(); | |||
| @@ -63,7 +63,6 @@ using std::function; | |||
| using std::shared_ptr; | |||
| using std::string; | |||
| /*lint -e148*/ | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { | |||
| public: | |||
| friend class OperatorImpl; | |||
| @@ -73,6 +72,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { | |||
| using OpInt = int64_t; | |||
| using OpFloat = float; | |||
| using OpString = string; | |||
| using OpAscendString = AscendString; | |||
| using OpBool = bool; | |||
| using OpTensor = Tensor; | |||
| using OpType = ge::DataType; | |||
| @@ -80,6 +80,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { | |||
| using OpListInt = std::vector<int64_t>; | |||
| using OpListFloat = std::vector<float>; | |||
| using OpListString = std::vector<string>; | |||
| using OpListAcendString = std::vector<AscendString>; | |||
| using OpListBool = std::vector<bool>; | |||
| using OpListTensor = std::vector<Tensor>; | |||
| using OpBytes = std::vector<uint8_t>; | |||
| @@ -88,133 +89,297 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { | |||
| using OpListNamedAttrs = std::vector<ge::NamedAttrs>; | |||
| Operator() {} | |||
| ATTRIBUTED_DEPRECATED(Operator(const char *)) | |||
| explicit Operator(const string &type); | |||
| Operator(const string &name, const string &type); // lint !e148 | |||
| explicit Operator(const char *type); | |||
| ATTRIBUTED_DEPRECATED(Operator(const AscendString &, const AscendString &)) | |||
| Operator(const string &name, const string &type); | |||
| Operator(const AscendString &name, const AscendString &type); | |||
| Operator(const char *name, const char *type); | |||
| virtual ~Operator() = default; | |||
| bool IsEmpty() const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetName(AscendString &) const) | |||
| string GetName() const; | |||
| graphStatus GetName(AscendString &name) const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetOpType(AscendString &) const) | |||
| string GetOpType() const; | |||
| graphStatus GetOpType(AscendString &type) const; | |||
| // Only has one output index = 0 | |||
| ATTRIBUTED_DEPRECATED(Operator &SetInput(const char *, const Operator &)) | |||
| Operator &SetInput(const string &dst_name, const Operator &src_oprt); | |||
| Operator &SetInput(const string &dst_name, const Operator &src_oprt, const string &name); // lint !e148 | |||
| Operator &SetInput(const char *dst_name, const Operator &src_oprt); | |||
| ATTRIBUTED_DEPRECATED(Operator &SetInput(const char *, const Operator &, const char *)) | |||
| Operator &SetInput(const string &dst_name, const Operator &src_oprt, const string &name); | |||
| Operator &SetInput(const char *dst_name, const Operator &src_oprt, const char *name); | |||
| ATTRIBUTED_DEPRECATED(Operator &SetInput(const char *, const Operator &, uint32_t)) | |||
| Operator &SetInput(const string &dst_name, const Operator &src_oprt, uint32_t index); | |||
| Operator &SetInput(const char *dst_name, const Operator &src_oprt, uint32_t index); | |||
| Operator &AddControlInput(const Operator &src_oprt); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetInputConstData(const char *, Tensor &) const) | |||
| graphStatus GetInputConstData(const string &dst_name, Tensor &data) const; | |||
| graphStatus GetInputConstData(const char *dst_name, Tensor &data) const; | |||
| ATTRIBUTED_DEPRECATED(TensorDesc GetInputDesc(const char *, uint32_t len) const) | |||
| TensorDesc GetInputDesc(const string &name) const; | |||
| TensorDesc GetInputDesc(const char *name, uint32_t len) const; | |||
| TensorDesc GetInputDesc(uint32_t index) const; | |||
| ATTRIBUTED_DEPRECATED(int GetDynamicOutputNum(const char *) const) | |||
| int GetDynamicOutputNum(const string &name) const; | |||
| int GetDynamicOutputNum(const char *name) const; | |||
| ATTRIBUTED_DEPRECATED(int GetDynamicInputNum(const char *)) | |||
| int GetDynamicInputNum(const string &name) const; | |||
| int GetDynamicInputNum(const char *name) const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus TryGetInputDesc(const char *, TensorDesc &) const) | |||
| graphStatus TryGetInputDesc(const string &name, TensorDesc &tensor_desc) const; | |||
| graphStatus TryGetInputDesc(const char *name, TensorDesc &tensor_desc) const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus UpdateInputDesc(const char *, const TensorDesc &)) | |||
| graphStatus UpdateInputDesc(const string &name, const TensorDesc &tensor_desc); | |||
| graphStatus UpdateInputDesc(const char *name, const TensorDesc &tensor_desc); | |||
| ATTRIBUTED_DEPRECATED(TensorDesc GetOutputDesc(const char *, uint32_t len) const) | |||
| TensorDesc GetOutputDesc(const string &name) const; | |||
| TensorDesc GetOutputDesc(const char *name, uint32_t len) const; | |||
| TensorDesc GetOutputDesc(uint32_t index) const; | |||
| graphStatus UpdateOutputDesc(const string &name, const TensorDesc &tensor_desc); // lint !e148 | |||
| ATTRIBUTED_DEPRECATED(graphStatus UpdateOutputDesc(const char *, const TensorDesc &tensor_desc)) | |||
| graphStatus UpdateOutputDesc(const string &name, const TensorDesc &tensor_desc); | |||
| graphStatus UpdateOutputDesc(const char *name, const TensorDesc &tensor_desc); | |||
| ATTRIBUTED_DEPRECATED(TensorDesc GetDynamicInputDesc(const char *, uint32_t) const) | |||
| TensorDesc GetDynamicInputDesc(const string &name, uint32_t index) const; | |||
| graphStatus UpdateDynamicInputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); // lint !e148 | |||
| TensorDesc GetDynamicInputDesc(const char *name, uint32_t index) const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus UpdateDynamicInputDesc(const char *, uint32_t, const TensorDesc &)) | |||
| graphStatus UpdateDynamicInputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); | |||
| graphStatus UpdateDynamicInputDesc(const char *name, uint32_t index, const TensorDesc &tensor_desc); | |||
| ATTRIBUTED_DEPRECATED(TensorDesc GetDynamicOutputDesc(const char *, uint32_t) const) | |||
| TensorDesc GetDynamicOutputDesc(const string &name, uint32_t index) const; | |||
| graphStatus UpdateDynamicOutputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); // lint !e148 | |||
| TensorDesc GetDynamicOutputDesc(const char *name, uint32_t index) const; | |||
| graphStatus InferShapeAndType(); // lint !e148 | |||
| ATTRIBUTED_DEPRECATED(graphStatus UpdateDynamicOutputDesc(const char *, uint32_t, const TensorDesc &)) | |||
| graphStatus UpdateDynamicOutputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); | |||
| graphStatus UpdateDynamicOutputDesc(const char *name, uint32_t index, const TensorDesc &tensor_desc); | |||
| graphStatus InferShapeAndType(); | |||
| void SetInferenceContext(const InferenceContextPtr &inference_context); | |||
| InferenceContextPtr GetInferenceContext() const; | |||
| graphStatus VerifyAllAttr(bool disable_common_verifier = false); // lint !e148 | |||
| graphStatus VerifyAllAttr(bool disable_common_verifier = false); | |||
| size_t GetInputsSize() const; | |||
| size_t GetOutputsSize() const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAllAttrNamesAndTypes(std::map<AscendString, AscendString> &) const) | |||
| const std::map<std::string, std::string> GetAllAttrNamesAndTypes() const; | |||
| graphStatus GetAllAttrNamesAndTypes(std::map<AscendString, AscendString> &attr_name_types) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, int64_t)) | |||
| Operator &SetAttr(const string &name, int64_t attr_value); | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, int32_t)) | |||
| Operator &SetAttr(const string &name, int32_t attr_value); | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, uint32_t)) | |||
| Operator &SetAttr(const string &name, uint32_t attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, int64_t &) const) | |||
| graphStatus GetAttr(const string &name, int64_t &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, int32_t &) const) | |||
| graphStatus GetAttr(const string &name, int32_t &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, uint32_t &) const) | |||
| graphStatus GetAttr(const string &name, uint32_t &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<int64_t> &)) | |||
| Operator &SetAttr(const string &name, const std::vector<int64_t> &attr_value); | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<int32_t> &)) | |||
| Operator &SetAttr(const string &name, const std::vector<int32_t> &attr_value); | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<uint32_t> &)) | |||
| Operator &SetAttr(const string &name, const std::vector<uint32_t> &attr_value); | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, std::initializer_list<int64_t> &&)) | |||
| Operator &SetAttr(const string &name, std::initializer_list<int64_t> &&attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *name, std::vector<int64_t> &) const) | |||
| graphStatus GetAttr(const string &name, std::vector<int64_t> &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *name, std::vector<int32_t> &) const) | |||
| graphStatus GetAttr(const string &name, std::vector<int32_t> &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const string &, std::vector<uint32_t> &) const) | |||
| graphStatus GetAttr(const string &name, std::vector<uint32_t> &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, float attr_value)) | |||
| Operator &SetAttr(const string &name, float attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, float &) const) | |||
| graphStatus GetAttr(const string &name, float &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<float> &)) | |||
| Operator &SetAttr(const string &name, const std::vector<float> &attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector<float> &) const) | |||
| graphStatus GetAttr(const string &name, std::vector<float> &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, AttrValue &&)) | |||
| Operator &SetAttr(const string &name, AttrValue &&attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, AttrValue &) const) | |||
| graphStatus GetAttr(const string &name, AttrValue &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const AscendString &)) | |||
| Operator &SetAttr(const string &name, const string &attr_value); | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const string &)) | |||
| graphStatus GetAttr(const string &name, string &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<AscendString> &)) | |||
| Operator &SetAttr(const string &name, const std::vector<string> &attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const string &, std::vector<AscendString> &) const) | |||
| graphStatus GetAttr(const string &name, std::vector<string> &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, bool)) | |||
| Operator &SetAttr(const string &name, bool attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, bool &) const) | |||
| graphStatus GetAttr(const string &name, bool &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<bool> &)) | |||
| Operator &SetAttr(const string &name, const std::vector<bool> &attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector<bool> &) const) | |||
| graphStatus GetAttr(const string &name, std::vector<bool> &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const Tensor &)) | |||
| Operator &SetAttr(const string &name, const Tensor &attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, Tensor &) const) | |||
| graphStatus GetAttr(const string &name, Tensor &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<Tensor> &)) | |||
| Operator &SetAttr(const string &name, const std::vector<Tensor> &attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector<Tensor> &) const) | |||
| graphStatus GetAttr(const string &name, std::vector<Tensor> &attr_value) const; | |||
| // Bytes type | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const OpBytes &)) | |||
| Operator &SetAttr(const string &name, const OpBytes &attr_value); | |||
| // Bytes type | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, OpBytes &) const) | |||
| graphStatus GetAttr(const string &name, OpBytes &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<std::vector<int64_t>> &)) | |||
| Operator &SetAttr(const string &name, const std::vector<std::vector<int64_t>> &attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector<std::vector<int64_t>> &) const) | |||
| graphStatus GetAttr(const string &name, std::vector<std::vector<int64_t>> &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<ge::DataType> &)) | |||
| Operator &SetAttr(const string &name, const std::vector<ge::DataType> &attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector<ge::DataType> &) const) | |||
| graphStatus GetAttr(const string &name, std::vector<ge::DataType> &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const ge::DataType &)) | |||
| Operator &SetAttr(const string &name, const ge::DataType &attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, ge::DataType &) const) | |||
| graphStatus GetAttr(const string &name, ge::DataType &attr_value) const; | |||
| // func type | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const ge::NamedAttrs &)) | |||
| Operator &SetAttr(const string &name, const ge::NamedAttrs &attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, ge::NamedAttrs &) const) | |||
| graphStatus GetAttr(const string &name, ge::NamedAttrs &attr_value) const; | |||
| ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<ge::NamedAttrs> &)) | |||
| Operator &SetAttr(const string &name, const std::vector<ge::NamedAttrs> &attr_value); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector<ge::NamedAttrs> &) const) | |||
| graphStatus GetAttr(const string &name, std::vector<ge::NamedAttrs> &attr_value) const; | |||
| Operator &SetAttr(const char *name, int64_t attr_value); | |||
| Operator &SetAttr(const char *name, int32_t attr_value); | |||
| Operator &SetAttr(const char *name, uint32_t attr_value); | |||
| graphStatus GetAttr(const char *name, int64_t &attr_value) const; | |||
| graphStatus GetAttr(const char *name, int32_t &attr_value) const; | |||
| graphStatus GetAttr(const char *name, uint32_t &attr_value) const; | |||
| Operator &SetAttr(const char *name, const std::vector<int64_t> &attr_value); | |||
| Operator &SetAttr(const char *name, const std::vector<int32_t> &attr_value); | |||
| Operator &SetAttr(const char *name, const std::vector<uint32_t> &attr_value); | |||
| Operator &SetAttr(const char *name, std::initializer_list<int64_t> &&attr_value); | |||
| graphStatus GetAttr(const char *name, std::vector<int64_t> &attr_value) const; | |||
| graphStatus GetAttr(const char *name, std::vector<int32_t> &attr_value) const; | |||
| graphStatus GetAttr(const char *name, std::vector<uint32_t> &attr_value) const; | |||
| Operator &SetAttr(const char *name, float attr_value); | |||
| graphStatus GetAttr(const char *name, float &attr_value) const; | |||
| Operator &SetAttr(const char *name, const std::vector<float> &attr_value); | |||
| graphStatus GetAttr(const char *name, std::vector<float> &attr_value) const; | |||
| Operator &SetAttr(const char *name, AttrValue &&attr_value); | |||
| graphStatus GetAttr(const char *name, AttrValue &attr_value) const; | |||
| Operator &SetAttr(const char *name, const char *attr_value); | |||
| Operator &SetAttr(const char *name, const AscendString &attr_value); | |||
| graphStatus GetAttr(const char *name, AscendString &attr_value) const; | |||
| Operator &SetAttr(const char *name, const std::vector<AscendString> &attr_values); | |||
| graphStatus GetAttr(const char *name, std::vector<AscendString> &attr_values) const; | |||
| Operator &SetAttr(const char *name, bool attr_value); | |||
| graphStatus GetAttr(const char *name, bool &attr_value) const; | |||
| Operator &SetAttr(const char *name, const std::vector<bool> &attr_value); | |||
| graphStatus GetAttr(const char *name, std::vector<bool> &attr_value) const; | |||
| Operator &SetAttr(const char *name, const Tensor &attr_value); | |||
| graphStatus GetAttr(const char *name, Tensor &attr_value) const; | |||
| Operator &SetAttr(const char *name, const std::vector<Tensor> &attr_value); | |||
| graphStatus GetAttr(const char *name, std::vector<Tensor> &attr_value) const; | |||
| // Bytes type | |||
| Operator &SetAttr(const char *name, const OpBytes &attr_value); | |||
| // Bytes type | |||
| graphStatus GetAttr(const char *name, OpBytes &attr_value) const; | |||
| Operator &SetAttr(const char *name, const std::vector<std::vector<int64_t>> &attr_value); | |||
| graphStatus GetAttr(const char *name, std::vector<std::vector<int64_t>> &attr_value) const; | |||
| Operator &SetAttr(const char *name, const std::vector<ge::DataType> &attr_value); | |||
| graphStatus GetAttr(const char *name, std::vector<ge::DataType> &attr_value) const; | |||
| Operator &SetAttr(const char *name, const ge::DataType &attr_value); | |||
| graphStatus GetAttr(const char *name, ge::DataType &attr_value) const; | |||
| // func type | |||
| Operator &SetAttr(const char *name, const ge::NamedAttrs &attr_value); | |||
| graphStatus GetAttr(const char *name, ge::NamedAttrs &attr_value) const; | |||
| Operator &SetAttr(const char *name, const std::vector<ge::NamedAttrs> &attr_value); | |||
| graphStatus GetAttr(const char *name, std::vector<ge::NamedAttrs> &attr_value) const; | |||
| void BreakConnect() const; | |||
| size_t GetSubgraphNamesCount() const; | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetSubgraphNames(std::vector<AscendString> &) const) | |||
| std::vector<std::string> GetSubgraphNames() const; | |||
| graphStatus GetSubgraphNames(std::vector<AscendString> &names) const; | |||
| ATTRIBUTED_DEPRECATED(SubgraphBuilder GetSubgraphBuilder(const char *) const) | |||
| SubgraphBuilder GetSubgraphBuilder(const string &name) const; | |||
| SubgraphBuilder GetSubgraphBuilder(const char *name) const; | |||
| ATTRIBUTED_DEPRECATED(Graph GetSubgraph(const char *) const) | |||
| Graph GetSubgraph(const string &name) const; | |||
| Graph GetSubgraph(const char *name) const; | |||
| ATTRIBUTED_DEPRECATED(SubgraphBuilder GetDynamicSubgraphBuilder(const char *, uint32_t) const) | |||
| SubgraphBuilder GetDynamicSubgraphBuilder(const string &name, uint32_t index) const; | |||
| SubgraphBuilder GetDynamicSubgraphBuilder(const char *name, uint32_t index) const; | |||
| ATTRIBUTED_DEPRECATED(Graph GetDynamicSubgraph(const char *, uint32_t) const) | |||
| Graph GetDynamicSubgraph(const string &name, uint32_t index) const; | |||
| Graph GetDynamicSubgraph(const char *name, uint32_t index) const; | |||
| protected: | |||
| void AttrRegister(const string &name, float attr_value); | |||
| @@ -256,20 +421,20 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { | |||
| void RequiredAttrRegister(const string &name); | |||
| graphStatus VerifyAll(); // lint !e148 | |||
| graphStatus VerifyAll(); | |||
| // Only has one output index = 0 | |||
| Operator &SetInput(const string &dst_name, uint32_t dst_index, const Operator &src_oprt); | |||
| Operator &SetInput(const string &dst_name, uint32_t dst_index, const Operator &src_oprt, | |||
| const string &name); // lint !e148 | |||
| Operator &SetInput(const string &dst_name, uint32_t dst_index, const Operator &src_oprt, const string &name); | |||
| void SubgraphRegister(const string &ir_name, bool dynamic); | |||
| void SubgraphCountRegister(const string &ir_name, uint32_t count); | |||
| void SetSubgraphBuilder(const string &ir_name, uint32_t index, const SubgraphBuilder &builder); | |||
| Graph GetSubgraphImpl(const string &name) const; | |||
| private: | |||
| Operator &SetInput(const string &dst_name, const OutHandler &out_handler); // lint !e148 | |||
| Operator &SetInput(const string &dst_name, const OutHandler &out_handler); | |||
| OutHandler GetOutput(const string &name) const; | |||
| @@ -283,7 +448,6 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { | |||
| std::shared_ptr<const Node> GetNode() const; | |||
| }; | |||
| /*lint +e148*/ | |||
| } // namespace ge | |||
| #endif // INC_EXTERNAL_GRAPH_OPERATOR_H_ | |||
| @@ -27,40 +27,58 @@ | |||
| namespace ge { | |||
| using OpCreator = std::function<Operator(const std::string &)>; | |||
| using OpCreatorV2 = std::function<Operator(const AscendString &)>; | |||
| using InferShapeFunc = std::function<graphStatus(Operator &)>; | |||
| using InferFormatFunc = std::function<graphStatus(Operator &)>; | |||
| using VerifyFunc = std::function<graphStatus(Operator &)>; | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorFactory { | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(static Operator CreateOperator(const char *, const char *)) | |||
| static Operator CreateOperator(const std::string &operator_name, const std::string &operator_type); | |||
| static Operator CreateOperator(const char *operator_name, const char *operator_type); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetOpsTypeList(std::vector<AscendString> &)) | |||
| static graphStatus GetOpsTypeList(std::vector<std::string> &all_ops); | |||
| static graphStatus GetOpsTypeList(std::vector<AscendString> &all_ops); | |||
| ATTRIBUTED_DEPRECATED(bool IsExistOp(const char *)) | |||
| static bool IsExistOp(const string &operator_type); | |||
| static bool IsExistOp(const char *operator_type); | |||
| }; | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorCreatorRegister { | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(OperatorCreatorRegister(const char *, OpCreatorV2 const &)) | |||
| OperatorCreatorRegister(const string &operator_type, OpCreator const &op_creator); | |||
| OperatorCreatorRegister(const char *operator_type, OpCreatorV2 const &op_creator); | |||
| ~OperatorCreatorRegister() = default; | |||
| }; | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InferShapeFuncRegister { | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(InferShapeFuncRegister(const char *, const InferShapeFunc &)) | |||
| InferShapeFuncRegister(const std::string &operator_type, const InferShapeFunc &infer_shape_func); | |||
| InferShapeFuncRegister(const char *operator_type, const InferShapeFunc &infer_shape_func); | |||
| ~InferShapeFuncRegister() = default; | |||
| }; | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InferFormatFuncRegister { | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(InferFormatFuncRegister(const char *, const InferFormatFunc &)) | |||
| InferFormatFuncRegister(const std::string &operator_type, const InferFormatFunc &infer_format_func); | |||
| InferFormatFuncRegister(const char *operator_type, const InferFormatFunc &infer_format_func); | |||
| ~InferFormatFuncRegister() = default; | |||
| }; | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY VerifyFuncRegister { | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(VerifyFuncRegister(const char *, const VerifyFunc &)) | |||
| VerifyFuncRegister(const std::string &operator_type, const VerifyFunc &verify_func); | |||
| VerifyFuncRegister(const char *operator_type, const VerifyFunc &verify_func); | |||
| ~VerifyFuncRegister() = default; | |||
| }; | |||
| } // namespace ge | |||
| @@ -54,144 +54,167 @@ class OpReg { | |||
| OpReg &INFER_SHAPE_AND_TYPE() { return *this; } | |||
| }; | |||
| #define REG_OP(x) \ | |||
| namespace op { \ | |||
| class x : public Operator { \ | |||
| typedef x _THIS_TYPE; \ | |||
| \ | |||
| public: \ | |||
| explicit x(const string &name) : Operator(name, #x) { __##x(); } \ | |||
| x() : Operator(#x) { __##x(); } \ | |||
| \ | |||
| private: \ | |||
| void __##x() { \ | |||
| #define REG_OP(x) \ | |||
| namespace op { \ | |||
| class x : public Operator { \ | |||
| typedef x _THIS_TYPE; \ | |||
| \ | |||
| public: \ | |||
| ATTRIBUTED_DEPRECATED(x(const AscendString &)) \ | |||
| explicit x(const string &name) : Operator(name, #x) { __##x(); } \ | |||
| explicit x(const char *name) : Operator(name, #x) { __##x(); } \ | |||
| explicit x(const AscendString &name) : Operator(name, #x) { __##x(); } \ | |||
| x() : Operator(#x) { __##x(); } \ | |||
| \ | |||
| private: \ | |||
| void __##x() { \ | |||
| OpReg() | |||
| #define ATTR(x, Type, ...) \ | |||
| N(); \ | |||
| __attr_##x(); \ | |||
| } \ | |||
| \ | |||
| public: \ | |||
| static const string name_attr_##x() { return #x; } \ | |||
| Op##Type get_attr_##x() const { \ | |||
| Op##Type ret = __VA_ARGS__; \ | |||
| if (Operator::GetAttr(#x, ret) == GRAPH_FAILED) { \ | |||
| return ret; \ | |||
| } \ | |||
| return ret; \ | |||
| } \ | |||
| _THIS_TYPE &set_attr_##x(const Op##Type &v) { \ | |||
| Operator::SetAttr(#x, v); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_attr_##x(const function<Op##Type()> &v) { return *this; } \ | |||
| \ | |||
| private: \ | |||
| void __attr_##x() { \ | |||
| Operator::AttrRegister(#x, Op##Type(__VA_ARGS__)); \ | |||
| string attr_name(#x); \ | |||
| #define ATTR(x, Type, ...) \ | |||
| N(); \ | |||
| __attr_##x(); \ | |||
| } \ | |||
| \ | |||
| public: \ | |||
| ATTRIBUTED_DEPRECATED(static const void name_attr_##x(AscendString &)) \ | |||
| static const string name_attr_##x() { return #x; } \ | |||
| static const void name_attr_##x(AscendString &attr) { attr = AscendString(#x); } \ | |||
| Op##Type get_attr_##x() const { \ | |||
| Op##Type ret = __VA_ARGS__; \ | |||
| if (Operator::GetAttr(#x, ret) == GRAPH_FAILED) { \ | |||
| return ret; \ | |||
| } \ | |||
| return ret; \ | |||
| } \ | |||
| _THIS_TYPE &set_attr_##x(const Op##Type &v) { \ | |||
| Operator::SetAttr(#x, v); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_attr_##x(const function<Op##Type()> &v) { return *this; } \ | |||
| \ | |||
| private: \ | |||
| void __attr_##x() { \ | |||
| Operator::AttrRegister(#x, Op##Type(__VA_ARGS__)); \ | |||
| string attr_name(#x); \ | |||
| (void)OpReg() | |||
| #define REQUIRED_ATTR(x, Type) \ | |||
| N(); \ | |||
| __required_attr_##x(); \ | |||
| } \ | |||
| \ | |||
| public: \ | |||
| static const string name_attr_##x() { return #x; } \ | |||
| Op##Type get_attr_##x() const { \ | |||
| Op##Type ret; \ | |||
| if (Operator::GetAttr(#x, ret) == GRAPH_FAILED) { \ | |||
| return ret; \ | |||
| } \ | |||
| return ret; \ | |||
| } \ | |||
| _THIS_TYPE &set_attr_##x(const Op##Type &v) { \ | |||
| Operator::SetAttr(#x, v); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_attr_##x(const function<Op##Type()> &v) { return *this; } \ | |||
| \ | |||
| private: \ | |||
| void __required_attr_##x() { \ | |||
| Operator::RequiredAttrRegister(#x); \ | |||
| string attr_name(#x); \ | |||
| #define REQUIRED_ATTR(x, Type) \ | |||
| N(); \ | |||
| __required_attr_##x(); \ | |||
| } \ | |||
| \ | |||
| public: \ | |||
| ATTRIBUTED_DEPRECATED(static const void name_attr_##x(AscendString &)) \ | |||
| static const string name_attr_##x() { return #x; } \ | |||
| static const void name_attr_##x(AscendString &attr_name) { attr_name = AscendString(#x); } \ | |||
| Op##Type get_attr_##x() const { \ | |||
| Op##Type ret; \ | |||
| if (Operator::GetAttr(#x, ret) == GRAPH_FAILED) { \ | |||
| return ret; \ | |||
| } \ | |||
| return ret; \ | |||
| } \ | |||
| _THIS_TYPE &set_attr_##x(const Op##Type &v) { \ | |||
| Operator::SetAttr(#x, v); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_attr_##x(const function<Op##Type()> &v) { return *this; } \ | |||
| \ | |||
| private: \ | |||
| void __required_attr_##x() { \ | |||
| Operator::RequiredAttrRegister(#x); \ | |||
| string attr_name(#x); \ | |||
| (void)OpReg() | |||
| #define INPUT(x, t) \ | |||
| N(); \ | |||
| __input_##x(); \ | |||
| } \ | |||
| \ | |||
| public: \ | |||
| static const string name_in_##x() { return #x; } \ | |||
| _THIS_TYPE &set_input_##x(Operator &v, const string &srcName) { \ | |||
| Operator::SetInput(#x, v, srcName); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_input_##x(Operator &v, uint32_t index) { \ | |||
| Operator::SetInput(#x, v, index); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_input_##x(Operator &v) { \ | |||
| Operator::SetInput(#x, v); \ | |||
| return *this; \ | |||
| } \ | |||
| TensorDesc get_input_desc_##x() const { return Operator::GetInputDesc(#x); } \ | |||
| graphStatus update_input_desc_##x(const TensorDesc &tensorDesc) { \ | |||
| return Operator::UpdateInputDesc(#x, tensorDesc); \ | |||
| } \ | |||
| \ | |||
| private: \ | |||
| void __input_##x() { \ | |||
| Operator::InputRegister(#x); \ | |||
| #define INPUT(x, t) \ | |||
| N(); \ | |||
| __input_##x(); \ | |||
| } \ | |||
| \ | |||
| public: \ | |||
| ATTRIBUTED_DEPRECATED(static const void name_in_##x(AscendString &)) \ | |||
| static const string name_in_##x() { return #x; } \ | |||
| static const void name_in_##x(AscendString &name) { name = AscendString(#x); } \ | |||
| ATTRIBUTED_DEPRECATED(_THIS_TYPE &set_input_##x(Operator &, const char *)) \ | |||
| _THIS_TYPE &set_input_##x(Operator &v, const string &srcName) { \ | |||
| Operator::SetInput(#x, v, srcName); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_input_##x(Operator &v, const char *srcName) { \ | |||
| Operator::SetInput(#x, v, srcName); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_input_##x(Operator &v, uint32_t index) { \ | |||
| Operator::SetInput(#x, v, index); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_input_##x(Operator &v) { \ | |||
| Operator::SetInput(#x, v); \ | |||
| return *this; \ | |||
| } \ | |||
| TensorDesc get_input_desc_##x() const { return Operator::GetInputDesc(#x, 0); } \ | |||
| graphStatus update_input_desc_##x(const TensorDesc &tensorDesc) { \ | |||
| return Operator::UpdateInputDesc(#x, tensorDesc); \ | |||
| } \ | |||
| \ | |||
| private: \ | |||
| void __input_##x() { \ | |||
| Operator::InputRegister(#x); \ | |||
| (void)OpReg() | |||
| #define OPTIONAL_INPUT(x, t) \ | |||
| N(); \ | |||
| __optional_input_##x(); \ | |||
| } \ | |||
| \ | |||
| public: \ | |||
| static const string name_in_##x() { return #x; } \ | |||
| _THIS_TYPE &set_input_##x(Operator &v) { \ | |||
| Operator::SetInput(#x, v); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_input_##x(Operator &v, const string &srcName) { \ | |||
| Operator::SetInput(#x, v, srcName); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_input_##x(Operator &v, uint32_t index) { \ | |||
| Operator::SetInput(#x, v, index); \ | |||
| return *this; \ | |||
| } \ | |||
| TensorDesc get_input_desc_##x() const { return Operator::GetInputDesc(#x); } \ | |||
| graphStatus update_input_desc_##x(const TensorDesc &tensorDesc) { \ | |||
| return Operator::UpdateInputDesc(#x, tensorDesc); \ | |||
| } \ | |||
| \ | |||
| private: \ | |||
| void __optional_input_##x() { \ | |||
| Operator::OptionalInputRegister(#x); \ | |||
| #define OPTIONAL_INPUT(x, t) \ | |||
| N(); \ | |||
| __optional_input_##x(); \ | |||
| } \ | |||
| \ | |||
| public: \ | |||
| ATTRIBUTED_DEPRECATED(static const void name_in_##x(AscendString &)) \ | |||
| static const string name_in_##x() { return #x; } \ | |||
| static const void name_in_##x(AscendString &name) { name = AscendString(#x); } \ | |||
| _THIS_TYPE &set_input_##x(Operator &v) { \ | |||
| Operator::SetInput(#x, v); \ | |||
| return *this; \ | |||
| } \ | |||
| ATTRIBUTED_DEPRECATED(_THIS_TYPE &set_input_##x(Operator &, const char *)) \ | |||
| _THIS_TYPE &set_input_##x(Operator &v, const string &srcName) { \ | |||
| Operator::SetInput(#x, v, srcName); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_input_##x(Operator &v, const char *srcName) { \ | |||
| Operator::SetInput(#x, v, srcName); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_input_##x(Operator &v, uint32_t index) { \ | |||
| Operator::SetInput(#x, v, index); \ | |||
| return *this; \ | |||
| } \ | |||
| TensorDesc get_input_desc_##x() const { return Operator::GetInputDesc(#x, 0); } \ | |||
| graphStatus update_input_desc_##x(const TensorDesc &tensorDesc) { \ | |||
| return Operator::UpdateInputDesc(#x, tensorDesc); \ | |||
| } \ | |||
| \ | |||
| private: \ | |||
| void __optional_input_##x() { \ | |||
| Operator::OptionalInputRegister(#x); \ | |||
| (void)OpReg() | |||
| #define OUTPUT(x, t) \ | |||
| N(); \ | |||
| __out_##x(); \ | |||
| } \ | |||
| \ | |||
| public: \ | |||
| static const string name_out_##x() { return #x; } \ | |||
| TensorDesc get_output_desc_##x() const { return Operator::GetOutputDesc(#x); } \ | |||
| graphStatus update_output_desc_##x(const TensorDesc &tensorDesc) { \ | |||
| return Operator::UpdateOutputDesc(#x, tensorDesc); \ | |||
| } \ | |||
| \ | |||
| private: \ | |||
| void __out_##x() { \ | |||
| Operator::OutputRegister(#x); \ | |||
| #define OUTPUT(x, t) \ | |||
| N(); \ | |||
| __out_##x(); \ | |||
| } \ | |||
| \ | |||
| public: \ | |||
| ATTRIBUTED_DEPRECATED(static const void name_out_##x(AscendString &)) \ | |||
| static const string name_out_##x() { return #x; } \ | |||
| static const void name_out_##x(AscendString &name) { name = AscendString(#x); } \ | |||
| TensorDesc get_output_desc_##x() const { return Operator::GetOutputDesc(#x, 0); } \ | |||
| graphStatus update_output_desc_##x(const TensorDesc &tensorDesc) { \ | |||
| return Operator::UpdateOutputDesc(#x, tensorDesc); \ | |||
| } \ | |||
| \ | |||
| private: \ | |||
| void __out_##x() { \ | |||
| Operator::OutputRegister(#x); \ | |||
| (void)OpReg() | |||
| #define DYNAMIC_INPUT(x, t) \ | |||
| @@ -216,9 +239,14 @@ class OpReg { | |||
| Operator::SetInput(#x, dstIndex, v); \ | |||
| return *this; \ | |||
| } \ | |||
| ATTRIBUTED_DEPRECATED(_THIS_TYPE &set_dynamic_input_##x(uint32_t, Operator &, const char *)) \ | |||
| _THIS_TYPE &set_dynamic_input_##x(uint32_t dstIndex, Operator &v, const string &srcName) { \ | |||
| Operator::SetInput(#x, dstIndex, v, srcName); \ | |||
| return *this; \ | |||
| } \ | |||
| _THIS_TYPE &set_dynamic_input_##x(uint32_t dstIndex, Operator &v, const char *srcName) { \ | |||
| Operator::SetInput(#x, dstIndex, v, srcName); \ | |||
| return *this; \ | |||
| } \ | |||
| \ | |||
| private: \ | |||
| @@ -252,7 +280,9 @@ class OpReg { | |||
| } \ | |||
| \ | |||
| public: \ | |||
| ATTRIBUTED_DEPRECATED(static const void name_graph_##x(AscendString &)) \ | |||
| static const string name_graph_##x() { return #x; } \ | |||
| static const void name_graph_##x(AscendString &name) { name = AscendString(#x); } \ | |||
| SubgraphBuilder get_subgraph_builder_##x() const { return Operator::GetSubgraphBuilder(#x); } \ | |||
| _THIS_TYPE &set_subgraph_builder_##x(const SubgraphBuilder &v) { \ | |||
| Operator::SetSubgraphBuilder(#x, 0, v); \ | |||
| @@ -272,7 +302,9 @@ class OpReg { | |||
| } \ | |||
| \ | |||
| public: \ | |||
| ATTRIBUTED_DEPRECATED(static const void name_graph_##x(AscendString &)) \ | |||
| static const string name_graph_##x() { return #x; } \ | |||
| static const void name_graph_##x(AscendString &name) { name = AscendString(#x); } \ | |||
| _THIS_TYPE &create_dynamic_subgraph_##x(uint32_t num) { \ | |||
| Operator::SubgraphCountRegister(#x, num); \ | |||
| return *this; \ | |||
| @@ -292,15 +324,15 @@ class OpReg { | |||
| (void)OpReg() | |||
| #define PASTE(g_register, y) g_register##y | |||
| #define __OP_END_IMPL__(x, y) \ | |||
| N(); \ | |||
| } \ | |||
| static_assert( \ | |||
| std::is_same<x, _THIS_TYPE>::value, \ | |||
| "The class name entered into the OP_END_FACTORY_REG needs to be the same as the operator name you define."); \ | |||
| } \ | |||
| ; \ | |||
| static const OperatorCreatorRegister PASTE(g_register, y)(#x, [](const std::string &name) { return x(name); }); \ | |||
| #define __OP_END_IMPL__(x, y) \ | |||
| N(); \ | |||
| } \ | |||
| static_assert( \ | |||
| std::is_same<x, _THIS_TYPE>::value, \ | |||
| "The class name entered into the OP_END_FACTORY_REG needs to be the same as the operator name you define."); \ | |||
| } \ | |||
| ; \ | |||
| static const OperatorCreatorRegister PASTE(g_register, y)(#x, [](const AscendString &name) { return x(name); }); \ | |||
| } | |||
| #define OP_END_FACTORY_REG(x) __OP_END_IMPL__(x, __COUNTER__) | |||
| @@ -347,30 +379,30 @@ class OpReg { | |||
| // Common shape inferencer | |||
| #define ELMTWISE_INFER_SHAPEANDTYPE(in_name, out_name) \ | |||
| [](Operator op) -> graphStatus { \ | |||
| auto x_shape = op.GetInputDesc(in_name).GetShape().GetDims(); \ | |||
| auto x_type = op.GetInputDesc(in_name).GetDataType(); \ | |||
| TensorDesc op_output_desc = op.GetOutputDesc(out_name); \ | |||
| op_output_desc.SetShape(ge::Shape(x_shape)); \ | |||
| op_output_desc.SetOriginShape(ge::Shape(x_shape)); \ | |||
| op_output_desc.SetDataType(x_type); \ | |||
| return op.UpdateOutputDesc(out_name, op_output_desc); \ | |||
| #define ELMTWISE_INFER_SHAPEANDTYPE(in_name, out_name) \ | |||
| [](Operator op) -> graphStatus { \ | |||
| auto x_shape = op.GetInputDesc(in_name, 0).GetShape().GetDims(); \ | |||
| auto x_type = op.GetInputDesc(in_name, 0).GetDataType(); \ | |||
| TensorDesc op_output_desc = op.GetOutputDesc(out_name, 0); \ | |||
| op_output_desc.SetShape(ge::Shape(x_shape)); \ | |||
| op_output_desc.SetOriginShape(ge::Shape(x_shape)); \ | |||
| op_output_desc.SetDataType(x_type); \ | |||
| return op.UpdateOutputDesc(out_name, op_output_desc); \ | |||
| } | |||
| graphStatus BroadCastInfer(const function<vector<int64_t>()> &get_in1_shape, | |||
| const function<vector<int64_t>()> &get_in2_shape, | |||
| const function<void(const vector<int64_t> &y_shape)> &set_out_shape); | |||
| #define BROADCAST_INFER(in1_name, in2_name, out_name) \ | |||
| [](Operator op) -> graphStatus { \ | |||
| return BroadCastInfer([&]() { return op.GetInputDesc(in1_name).GetShape().GetDims(); }, \ | |||
| [&]() { return op.GetInputDesc(in2_name).GetShape().GetDims(); }, \ | |||
| [&](const vector<int64_t> &y_shape) { \ | |||
| TensorDesc op_output_desc = op.GetOutputDesc(out_name); \ | |||
| op_output_desc.SetShape(ge::Shape(y_shape)); \ | |||
| (void)op.UpdateOutputDesc(out_name, op_output_desc); \ | |||
| }); \ | |||
| #define BROADCAST_INFER(in1_name, in2_name, out_name) \ | |||
| [](Operator op) -> graphStatus { \ | |||
| return BroadCastInfer([&]() { return op.GetInputDesc(in1_name, 0).GetShape().GetDims(); }, \ | |||
| [&]() { return op.GetInputDesc(in2_name, 0).GetShape().GetDims(); }, \ | |||
| [&](const vector<int64_t> &y_shape) { \ | |||
| TensorDesc op_output_desc = op.GetOutputDesc(out_name, 0); \ | |||
| op_output_desc.SetShape(ge::Shape(y_shape)); \ | |||
| (void)op.UpdateOutputDesc(out_name, op_output_desc); \ | |||
| }); \ | |||
| } | |||
| } // namespace ge | |||
| #endif // INC_EXTERNAL_GRAPH_OPERATOR_REG_H_ | |||
| @@ -25,6 +25,7 @@ | |||
| #include "./ge_error_codes.h" | |||
| #include "./types.h" | |||
| #include "ascend_string.h" | |||
| namespace ge { | |||
| class ShapeImpl; | |||
| @@ -81,8 +82,13 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY TensorDesc { | |||
| DataType GetDataType() const; | |||
| void SetDataType(DataType dt); | |||
| ATTRIBUTED_DEPRECATED(graphStatus GetName(AscendString &)) | |||
| std::string GetName() const; | |||
| graphStatus GetName(AscendString &name); | |||
| ATTRIBUTED_DEPRECATED(void SetName(const char *)) | |||
| void SetName(const std::string &name); | |||
| void SetName(const char *name); | |||
| // Attr acess | |||
| void SetSize(int64_t size); | |||
| @@ -115,8 +121,12 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Tensor { | |||
| graphStatus SetData(std::vector<uint8_t> &&data); | |||
| graphStatus SetData(const std::vector<uint8_t> &data); | |||
| graphStatus SetData(const uint8_t *data, size_t size); | |||
| ATTRIBUTED_DEPRECATED(graphStatus SetData(const char *data)) | |||
| graphStatus SetData(const std::string &data); | |||
| graphStatus SetData(const char *data); | |||
| ATTRIBUTED_DEPRECATED(graphStatus SetData(const std::vector<AscendString> &)) | |||
| graphStatus SetData(const std::vector<std::string> &data); | |||
| graphStatus SetData(const std::vector<AscendString> &datas); | |||
| graphStatus IsValid(); | |||
| Tensor Clone() const; | |||
| @@ -126,6 +136,5 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Tensor { | |||
| friend class TensorAdapter; | |||
| }; | |||
| } // namespace ge | |||
| /*lint +e148*/ | |||
| #endif // INC_EXTERNAL_GRAPH_TENSOR_H_ | |||
| @@ -0,0 +1,134 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| /** | |||
| * @file hccl.h | |||
| * @brief HCCL API | |||
| */ | |||
| #ifndef HCCL_H_ | |||
| #define HCCL_H_ | |||
| #include <hccl/hccl_types.h> | |||
| #include <acl/acl.h> | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif // __cplusplus | |||
| /** | |||
| * @brief Initialize HCCL. | |||
| * | |||
| * @param clusterInfo A string identifying the cluster info file path, include file name. | |||
| * @param rank A integer identifying the identify for the rank. | |||
| * @param comm A pointer identifying the initialized communication resource. | |||
| * @return HcclResult | |||
| * @see HcclCommDestroy() | |||
| */ | |||
| extern HcclResult HcclCommInitClusterInfo(const char *clusterInfo, uint32_t rank, HcclComm *comm); | |||
| /** | |||
| * @brief Get hccl root info. | |||
| * | |||
| * @param rootInfo A pointer identifying the hccl root info. | |||
| * @return HcclResult | |||
| */ | |||
| extern HcclResult HcclGetRootInfo(HcclRootInfo *rootInfo); | |||
| /** | |||
| * @brief Initialize HCCL with root info. | |||
| * | |||
| * @param nRanks A integer identifying the rank size of the cluster. | |||
| * @param rootInfo A struct identifying the hccl root info. | |||
| * @param rank A integer identifying the identify for the rank. | |||
| * @param comm A pointer identifying the initialized communication resource. | |||
| * @return HcclResult | |||
| * @see HcclCommDestroy() | |||
| */ | |||
| extern HcclResult HcclCommInitRootInfo(uint32_t nRanks, const HcclRootInfo *rootInfo, uint32_t rank, HcclComm *comm); | |||
| /** | |||
| * @brief AllReduce operator. | |||
| * | |||
| * @param sendBuf A pointer identifying the input data address of the operator. | |||
| * @param recvBuf A pointer identifying the output data address of the operator. | |||
| * @param count An integer(u64) identifying the number of the output data. | |||
| * @param dataType The data type of the operator, must be one of the following types: int8, int16, int32, float16, | |||
| * float32. | |||
| * @param op The reduction type of the operator, must be one of the following types: sum, min, max, prod. | |||
| * @param comm A pointer identifying the communication resource based on. | |||
| * @param stream A pointer identifying the stream information. | |||
| * @return HcclResult | |||
| */ | |||
| extern HcclResult HcclAllReduce(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, HcclReduceOp op, | |||
| HcclComm comm, aclrtStream stream); | |||
| /** | |||
| * @brief Broadcast operator. | |||
| * | |||
| * @param buf A pointer identifying the data address of the operator. | |||
| * @param count An integer(u64) identifying the number of the data. | |||
| * @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32. | |||
| * @param root An integer(u32) identifying the the root rank in the operator. | |||
| * @param comm A pointer identifying the communication resource based on | |||
| * @param stream A pointer identifying the stream information. | |||
| * @return HcclResult | |||
| */ | |||
| extern HcclResult HcclBroadcast(void *buf, uint64_t count, HcclDataType dataType, uint32_t root, HcclComm comm, | |||
| aclrtStream stream); | |||
| /** | |||
| * @brief ReduceScatter operator. | |||
| * | |||
| * @param sendBuf A pointer identifying the input data address of the operator. | |||
| * @param recvBuf A pointer identifying the output data address of the operator. | |||
| * @param recvCount An integer(u64) identifying the number of the output data. | |||
| * @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32. | |||
| * @param op The reduction type of the operator, must be one of the following types: sum, min, max, prod. | |||
| * @param comm A pointer identifying the communication resource based on. | |||
| * @param stream A pointer identifying the stream information. | |||
| * @return HcclResult | |||
| */ | |||
| extern HcclResult HcclReduceScatter(void *sendBuf, void *recvBuf, uint64_t recvCount, HcclDataType dataType, | |||
| HcclReduceOp op, HcclComm comm, aclrtStream stream); | |||
| /** | |||
| * @brief AllGather operator. | |||
| * | |||
| * @param sendBuf A pointer identifying the input data address of the operator. | |||
| * @param recvBuf A pointer identifying the output data address of the operator. | |||
| * @param sendCount An integer(u64) identifying the number of the input data. | |||
| * @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32. | |||
| * @param comm A pointer identifying the communication resource based on. | |||
| * @param stream A pointer identifying the stream information. | |||
| * @return HcclResult | |||
| */ | |||
| extern HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, | |||
| aclrtStream stream); | |||
| /** | |||
| * @brief Destroy HCCL comm | |||
| * | |||
| * @param comm A pointer identifying the communication resource targetting | |||
| * @return HcclResult | |||
| * @see HcclCommInitClusterInfo() | |||
| */ | |||
| extern HcclResult HcclCommDestroy(HcclComm comm); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif // __cplusplus | |||
| #endif // HCCL_H_ | |||
| @@ -0,0 +1,101 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| /** | |||
| * @file hccl_types.h | |||
| * @brief HCCL data type definition | |||
| * | |||
| */ | |||
| #ifndef HCCL_TYPES_H_ | |||
| #define HCCL_TYPES_H_ | |||
| #include <stdint.h> | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif // __cplusplus | |||
| /** | |||
| * @brief HCCL functions return value definition | |||
| */ | |||
| typedef enum { | |||
| HCCL_SUCCESS = 0, /**< success */ | |||
| HCCL_E_PARA = 1, /**< parameter error */ | |||
| HCCL_E_PTR = 2, /**< empty pointer */ | |||
| HCCL_E_MEMORY = 3, /**< memory error */ | |||
| HCCL_E_INTERNAL = 4, /**< internal error */ | |||
| HCCL_E_NOT_SUPPORT = 5, /**< not support feature */ | |||
| HCCL_E_NOT_FOUND = 6, /**< not found specific resource */ | |||
| HCCL_E_UNAVAIL = 7, /**< resource unavailable */ | |||
| HCCL_E_SYSCALL = 8, /**< call system interface error */ | |||
| HCCL_E_TIMEOUT = 9, /**< timeout */ | |||
| HCCL_E_OPEN_FILE_FAILURE = 10, /**< open file fail */ | |||
| HCCL_E_TCP_CONNECT = 11, /**< tcp connect fail */ | |||
| HCCL_E_ROCE_CONNECT = 12, /**< roce connect fail */ | |||
| HCCL_E_TCP_TRANSFER = 13, /**< tcp transfer fail */ | |||
| HCCL_E_ROCE_TRANSFER = 14, /**< roce transfer fail */ | |||
| HCCL_E_RUNTIME = 15, /**< call runtime api fail */ | |||
| HCCL_E_DRV = 16, /**< call driver api fail */ | |||
| HCCL_E_PROFILING = 17, /**< call profiling api fail */ | |||
| HCCL_E_CCE = 18, /**< call cce api fail */ | |||
| HCCL_E_NETWORK = 19, /**< call network api fail */ | |||
| HCCL_E_RESERVED /**< reserved */ | |||
| } HcclResult; | |||
| /** | |||
| * @brief handle to HCCL communicator | |||
| */ | |||
| typedef void *HcclComm; | |||
| /** | |||
| * @brief HCCL Reduction opperation | |||
| */ | |||
| typedef enum { | |||
| HCCL_REDUCE_SUM = 0, /**< sum */ | |||
| HCCL_REDUCE_PROD = 1, /**< prod */ | |||
| HCCL_REDUCE_MAX = 2, /**< max */ | |||
| HCCL_REDUCE_MIN = 3, /**< min */ | |||
| HCCL_REDUCE_RESERVED /**< reserved */ | |||
| } HcclReduceOp; | |||
| /** | |||
| * @brief HCCL data type | |||
| */ | |||
| typedef enum { | |||
| HCCL_DATA_TYPE_INT8 = 0, /**< int8 */ | |||
| HCCL_DATA_TYPE_INT16 = 1, /**< int16 */ | |||
| HCCL_DATA_TYPE_INT32 = 2, /**< int32 */ | |||
| HCCL_DATA_TYPE_FP16 = 3, /**< fp16 */ | |||
| HCCL_DATA_TYPE_FP32 = 4, /**< fp32 */ | |||
| HCCL_DATA_TYPE_INT64 = 5, /**< int64 */ | |||
| HCCL_DATA_TYPE_UINT64 = 6, /**< uint64 */ | |||
| HCCL_DATA_TYPE_RESERVED /**< reserved */ | |||
| } HcclDataType; | |||
| const uint32_t HCCL_ROOT_INFO_BYTES = 4108; // 4108: root info length | |||
| /** | |||
| * @brief HCCL root info | |||
| */ | |||
| typedef struct HcclRootInfoDef { | |||
| char internal[HCCL_ROOT_INFO_BYTES]; | |||
| } HcclRootInfo; | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif // __cplusplus | |||
| #endif // HCCL_TYPES_H_ | |||
| @@ -40,7 +40,6 @@ using std::to_string; | |||
| using std::unique_ptr; | |||
| using std::vector; | |||
| /*lint -e148*/ | |||
| namespace ge { | |||
| class Operator; | |||
| class TensorDesc; | |||
| @@ -77,7 +76,10 @@ struct DynamicInputOutputInfo { | |||
| Status AutoMappingByOpFn(const ge::Operator &op_src, ge::Operator &op); | |||
| Status AutoMappingByOpFnDynamic(const ge::Operator &op_src, ge::Operator &op, | |||
| const vector<DynamicInputOutputInfo> &dynamic_name_attr_value); | |||
| ATTRIBUTED_DEPRECATED(Status AutoMappingByOpFn(const ge::Operator &, ge::Operator &)) | |||
| Status AutoMappingFn(const google::protobuf::Message *op_src, ge::Operator &op); | |||
| ATTRIBUTED_DEPRECATED(Status AutoMappingByOpFnDynamic(const ge::Operator &, ge::Operator &, | |||
| const vector<DynamicInputOutputInfo> &)) | |||
| Status AutoMappingFnDynamic(const google::protobuf::Message *op_src, ge::Operator &op, | |||
| std::map<std::string, std::pair<std::string, std::string>> dynamic_name_attr_value, | |||
| int in_pos = -1, int out_pos = -1); | |||
| @@ -95,19 +97,30 @@ using FusionParseParamFunc = | |||
| std::function<domi::Status(const std::vector<const google::protobuf::Message *>, ge::Operator &)>; | |||
| using FusionParseParamByOpFunc = std::function<domi::Status(const std::vector<ge::Operator> &, ge::Operator &)>; | |||
| using ParseSubgraphFunc = std::function<Status(const std::string &subgraph_name, const ge::Graph &graph)>; | |||
| using ParseOpToGraphFunc = std::function<Status(const ge::Operator &, ge::Graph &)>; | |||
| using ParseSubgraphFuncV2 = std::function<Status(const ge::AscendString &subgraph_name, const ge::Graph &graph)>; | |||
| class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData { | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(OpRegistrationData(const char *)) | |||
| OpRegistrationData(const std::string &om_optype); | |||
| OpRegistrationData(const char *om_optype); | |||
| ~OpRegistrationData(); | |||
| OpRegistrationData &FrameworkType(const domi::FrameworkType &fmk_type); | |||
| ATTRIBUTED_DEPRECATED(OpRegistrationData &OriginOpType(const std::vector<ge::AscendString> &)) | |||
| OpRegistrationData &OriginOpType(const std::initializer_list<std::string> &ori_optype_list); | |||
| OpRegistrationData &OriginOpType(const std::vector<ge::AscendString> &ori_op_type_list); | |||
| ATTRIBUTED_DEPRECATED(OpRegistrationData &OriginOpType(const char *)) | |||
| OpRegistrationData &OriginOpType(const std::string &ori_optype); | |||
| OpRegistrationData &OriginOpType(const char *ori_op_type); | |||
| OpRegistrationData &ParseParamsFn(const ParseParamFunc &parseParamFn); | |||
| OpRegistrationData &ParseParamsByOperatorFn(const ParseParamByOpFunc &parse_param_by_op_fn); | |||
| @@ -116,25 +129,42 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData { | |||
| OpRegistrationData &FusionParseParamsFn(const FusionParseParamByOpFunc &fusion_parse_param_fn); | |||
| ATTRIBUTED_DEPRECATED(OpRegistrationData &ParseSubgraphPostFn(const ParseSubgraphFuncV2 &)) | |||
| OpRegistrationData &ParseSubgraphPostFn(const ParseSubgraphFunc &subgraph_post_fn); | |||
| OpRegistrationData &ParseSubgraphPostFn(const ParseSubgraphFuncV2 &subgraph_post_fn); | |||
| OpRegistrationData &ImplyType(const domi::ImplyType &imply_type); | |||
| ATTRIBUTED_DEPRECATED(OpRegistrationData &DelInputWithCond(int, const char *, bool)) | |||
| OpRegistrationData &DelInputWithCond(int inputIdx, const std::string &attrName, bool attrValue); | |||
| OpRegistrationData &DelInputWithCond(int input_idx, const char *attr_name, bool attr_value); | |||
| ATTRIBUTED_DEPRECATED(OpRegistrationData &DelInputWithOriginalType(int, const char *)) | |||
| OpRegistrationData &DelInputWithOriginalType(int input_idx, const std::string &ori_type); | |||
| OpRegistrationData &DelInputWithOriginalType(int input_idx, const char *ori_type); | |||
| OpRegistrationData &InputReorderVector(const vector<int> &input_order); | |||
| OpRegistrationData &ParseOpToGraphFn(const ParseOpToGraphFunc &parse_op_to_graph_fn); | |||
| domi::ImplyType GetImplyType() const; | |||
| ATTRIBUTED_DEPRECATED(Status GetOmOptype(ge::AscendString &) const) | |||
| std::string GetOmOptype() const; | |||
| Status GetOmOptype(ge::AscendString &om_op_type) const; | |||
| ATTRIBUTED_DEPRECATED(GetOriginOpTypeSet(std::set<ge::AscendString> &) const) | |||
| std::set<std::string> GetOriginOpTypeSet() const; | |||
| Status GetOriginOpTypeSet(std::set<ge::AscendString> &ori_op_type) const; | |||
| domi::FrameworkType GetFrameworkType() const; | |||
| ParseParamFunc GetParseParamFn() const; | |||
| ParseParamByOpFunc GetParseParamByOperatorFn() const; | |||
| FusionParseParamFunc GetFusionParseParamFn() const; | |||
| FusionParseParamByOpFunc GetFusionParseParamByOpFn() const; | |||
| ParseSubgraphFunc GetParseSubgraphPostFn() const; | |||
| ParseOpToGraphFunc GetParseOpToGraphFn() const; | |||
| Status GetParseSubgraphPostFn(ParseSubgraphFuncV2 &func) const; | |||
| private: | |||
| std::shared_ptr<OpRegistrationDataImpl> impl_; | |||
| @@ -159,5 +189,4 @@ namespace ge { | |||
| using OpRegistrationData = domi::OpRegistrationData; | |||
| using OpReceiver = domi::OpReceiver; | |||
| } // namespace ge | |||
| /*lint +e148*/ | |||
| #endif // INC_EXTERNAL_REGISTER_REGISTER_H_ | |||
| @@ -28,7 +28,11 @@ namespace domi { | |||
| #else | |||
| #define FMK_FUNC_DEV_VISIBILITY | |||
| #endif | |||
| #ifdef __GNUC__ | |||
| #define ATTRIBUTED_DEPRECATED(replacement) __attribute__((deprecated("Please use " #replacement " instead."))) | |||
| #else | |||
| #define ATTRIBUTED_DEPRECATED(replacement) __declspec(deprecated("Please use " #replacement " instead.")) | |||
| #endif | |||
| /// CCE defined constant | |||
| /// | |||
| @@ -54,14 +54,25 @@ class ScopePassManager; | |||
| class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY Scope { | |||
| public: | |||
| Scope(); | |||
| ATTRIBUTED_DEPRECATED(Status Init(const char *, const char *, Scope *)) | |||
| Status Init(const std::string &name, const std::string &sub_type = "", Scope *father_scope = nullptr); | |||
| Status Init(const char *name, const char *sub_type, Scope *father_scope = nullptr); | |||
| ~Scope(); | |||
| ATTRIBUTED_DEPRECATED(Status Name(AscendString &) const) | |||
| const std::string &Name() const; | |||
| Status Name(AscendString &name) const; | |||
| ATTRIBUTED_DEPRECATED(Status SubType(AscendString &) const) | |||
| const std::string &SubType() const; | |||
| Status SubType(AscendString &sub_type) const; | |||
| ATTRIBUTED_DEPRECATED(Status AllNodesMap(std::unordered_map<AscendString, ge::OperatorPtr> &) const) | |||
| const std::unordered_map<std::string, ge::OperatorPtr> &AllNodesMap() const; | |||
| Status AllNodesMap(std::unordered_map<AscendString, ge::OperatorPtr> &node_map) const; | |||
| ATTRIBUTED_DEPRECATED(Scope *GetSubScope(const char *scope_name) const) | |||
| Scope *GetSubScope(const std::string &scope_name) const; | |||
| Scope *GetSubScope(const char *scope_name) const; | |||
| ATTRIBUTED_DEPRECATED(Status LastName(AscendString &) const) | |||
| const std::string LastName() const; | |||
| Status LastName(AscendString &name) const; | |||
| const std::vector<Scope *> &GetAllSubScopes() const; | |||
| const Scope *GetFatherScope() const; | |||
| @@ -80,45 +91,85 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY FusionScopesResult { | |||
| FusionScopesResult(); | |||
| Status Init(); | |||
| ~FusionScopesResult(); | |||
| ATTRIBUTED_DEPRECATED(void SetName(const char *)) | |||
| void SetName(const std::string &name); | |||
| void SetName(const char *name); | |||
| ATTRIBUTED_DEPRECATED(void SetType(const char *)) | |||
| void SetType(const std::string &type); | |||
| void SetType(const char *type); | |||
| ATTRIBUTED_DEPRECATED(void SetDescription(const char *)) | |||
| void SetDescription(const std::string &description); | |||
| void SetDescription(const char *description); | |||
| ATTRIBUTED_DEPRECATED(const Status Name(AscendString &) const) | |||
| const std::string &Name() const; | |||
| const Status Name(AscendString &name) const; | |||
| const std::vector<ge::OperatorPtr> &Nodes() const; | |||
| ATTRIBUTED_DEPRECATED(void InsertInputs(const char *, const std::vector<int32_t> &)) | |||
| void InsertInputs(const std::string &inner_op_name, const std::vector<int32_t> &index_map); | |||
| void InsertInputs(const char *inner_op_name, const std::vector<int32_t> &index_map); | |||
| ATTRIBUTED_DEPRECATED(void InsertOutputs(const char *, const std::vector<int32_t> &)) | |||
| void InsertOutputs(const std::string &inner_op_name, const std::vector<int32_t> &index_map); | |||
| void InsertOutputs(const char *inner_op_name, const std::vector<int32_t> &index_map); | |||
| class InnerNodeInfo { | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(InnerNodeInfo(const char *)) | |||
| explicit InnerNodeInfo(const std::string &fusion_node_name); | |||
| explicit InnerNodeInfo(const char *fusion_node_name); | |||
| ATTRIBUTED_DEPRECATED(InnerNodeInfo(const char *, const char *, const char *)) | |||
| InnerNodeInfo(const std::string &fusion_node_name, const std::string &name, const std::string &type); | |||
| InnerNodeInfo(const char *fusion_node_name, const char *name, const char *type); | |||
| InnerNodeInfo(InnerNodeInfo &&other) noexcept; | |||
| InnerNodeInfo &operator=(InnerNodeInfo &&other) noexcept; | |||
| InnerNodeInfo(const InnerNodeInfo &) = delete; | |||
| InnerNodeInfo &operator=(const InnerNodeInfo &) = delete; | |||
| ~InnerNodeInfo(); | |||
| ATTRIBUTED_DEPRECATED(InnerNodeInfo &SetName(const char *)) | |||
| InnerNodeInfo &SetName(const std::string &name); | |||
| InnerNodeInfo &SetName(const char *name); | |||
| ATTRIBUTED_DEPRECATED(InnerNodeInfo &SetType(const char *)) | |||
| InnerNodeInfo &SetType(const std::string &type); | |||
| InnerNodeInfo &SetType(const char *type); | |||
| ATTRIBUTED_DEPRECATED(InnerNodeInfo &InsertInput(const char *, int32_t)) | |||
| InnerNodeInfo &InsertInput(const std::string &input_node, int32_t peer_out_idx); | |||
| InnerNodeInfo &InsertInput(const char *input_node, int32_t peer_out_idx); | |||
| ATTRIBUTED_DEPRECATED(InnerNodeInfo &InsertOutput(const char *, int32_t)) | |||
| InnerNodeInfo &InsertOutput(const std::string &output_node, int32_t peer_in_idx); | |||
| InnerNodeInfo &InsertOutput(const char *output_node, int32_t peer_in_idx); | |||
| ge::graphStatus BuildInnerNode(); | |||
| ATTRIBUTED_DEPRECATED(ge::graphStatus SetInputFormat(const char *, const char *)) | |||
| ge::graphStatus SetInputFormat(const std::string &input_name, const std::string &format); | |||
| ge::graphStatus SetInputFormat(const char *input_name, const char *format); | |||
| ATTRIBUTED_DEPRECATED(ge::graphStatus SetOutputFormat(const char *, const char *)) | |||
| ge::graphStatus SetOutputFormat(const std::string &output_name, const std::string &format); | |||
| ge::graphStatus SetOutputFormat(const char *output_name, const char *format); | |||
| ATTRIBUTED_DEPRECATED(ge::graphStatus SetDynamicInputFormat(const char *, uint32_t index, const char *)) | |||
| ge::graphStatus SetDynamicInputFormat(const std::string &input_name, uint32_t index, const std::string &format); | |||
| ge::graphStatus SetDynamicInputFormat(const char *input_name, uint32_t index, const char *format); | |||
| ATTRIBUTED_DEPRECATED(ge::graphStatus SetDynamicOutputFormat(const char *, uint32_t, const char *)) | |||
| ge::graphStatus SetDynamicOutputFormat(const std::string &output_name, uint32_t index, const std::string &format); | |||
| ge::graphStatus SetDynamicOutputFormat(const char *output_name, uint32_t index, const char *format); | |||
| ge::Operator *MutableOperator(); | |||
| ATTRIBUTED_DEPRECATED(ge::graphStatus GetName(AscendString &) const) | |||
| std::string GetName() const; | |||
| ge::graphStatus GetName(AscendString &name) const; | |||
| ATTRIBUTED_DEPRECATED(ge::graphStatus GetType(AscendString &) const) | |||
| std::string GetType() const; | |||
| ge::graphStatus GetType(AscendString &type) const; | |||
| ATTRIBUTED_DEPRECATED(ge::graphStatus GetInputs(std::vector<std::pair<AscendString, int32_t>> &) const) | |||
| std::vector<std::pair<std::string, int32_t>> GetInputs() const; | |||
| ge::graphStatus GetInputs(std::vector<std::pair<AscendString, int32_t>> &inputs) const; | |||
| ATTRIBUTED_DEPRECATED(ge::graphStatus GetOutputs(std::vector<std::pair<AscendString, int32_t>> &) const) | |||
| std::vector<std::pair<std::string, int32_t>> GetOutputs() const; | |||
| ge::graphStatus GetOutputs(std::vector<std::pair<AscendString, int32_t>> &outputs) const; | |||
| private: | |||
| class InnerNodeInfoImpl; | |||
| std::unique_ptr<InnerNodeInfoImpl> impl_; | |||
| }; | |||
| ATTRIBUTED_DEPRECATED(InnerNodeInfo *AddInnerNode(const char *, const char *)) | |||
| InnerNodeInfo *AddInnerNode(const std::string &name, const std::string &type); | |||
| InnerNodeInfo *AddInnerNode(const char *name, const char *type); | |||
| InnerNodeInfo *MutableRecentInnerNode(); | |||
| InnerNodeInfo *MutableInnerNode(uint32_t index); | |||
| ge::graphStatus CheckInnerNodesInfo(); | |||
| @@ -157,7 +208,9 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeGraph { | |||
| ~ScopeGraph(); | |||
| const ScopeTree *GetScopeTree() const; | |||
| ATTRIBUTED_DEPRECATED(Status GetNodesMap(std::unordered_map<AscendString, ge::OperatorPtr> &) const) | |||
| const std::unordered_map<std::string, ge::OperatorPtr> &GetNodesMap() const; | |||
| Status GetNodesMap(std::unordered_map<AscendString, ge::OperatorPtr> &nodes_map) const; | |||
| private: | |||
| class ScopeGraphImpl; | |||
| @@ -176,7 +229,9 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeAttrValue { | |||
| void SetIntValue(int64_t value); | |||
| void SetFloatValue(float value); | |||
| ATTRIBUTED_DEPRECATED(void SetStringValue(const char *)) | |||
| void SetStringValue(std::string value); | |||
| void SetStringValue(const char *value); | |||
| void SetBoolValue(bool value); | |||
| private: | |||
| @@ -193,7 +248,9 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeBaseFeature { | |||
| class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeOpTypeFeature : ScopeBaseFeature { | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(NodeOpTypeFeature(const char *, int, int)) | |||
| NodeOpTypeFeature(std::string nodeType, int num, int step = 0); | |||
| NodeOpTypeFeature(const char *node_type, int num, int step = 0); | |||
| NodeOpTypeFeature(NodeOpTypeFeature const &feature); | |||
| NodeOpTypeFeature &operator=(NodeOpTypeFeature const &feature); | |||
| ~NodeOpTypeFeature(); | |||
| @@ -206,7 +263,9 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeOpTypeFeature : ScopeBa | |||
| class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeAttrFeature : ScopeBaseFeature { | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(NodeAttrFeature(const char *, const char *, ge::DataType, ScopeAttrValue &)) | |||
| NodeAttrFeature(std::string nodeType, std::string attr_name, ge::DataType datatype, ScopeAttrValue &attr_value); | |||
| NodeAttrFeature(const char *node_type, const char *attr_name, ge::DataType datatype, ScopeAttrValue &attr_value); | |||
| NodeAttrFeature(NodeAttrFeature const &feature); | |||
| NodeAttrFeature &operator=(NodeAttrFeature const &feature); | |||
| ~NodeAttrFeature(); | |||
| @@ -219,8 +278,10 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeAttrFeature : ScopeBase | |||
| class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFeature : ScopeBaseFeature { | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(ScopeFeature(const char *, int32_t, const char *, const char *, int)) | |||
| ScopeFeature(std::string sub_type, int32_t num, std::string suffix = "", std::string sub_scope_mask = "", | |||
| int step = 0); | |||
| ScopeFeature(const char *sub_type, int32_t num, const char *suffix, const char *sub_scope_mask, int step = 0); | |||
| ScopeFeature(ScopeFeature const &feature); | |||
| ScopeFeature &operator=(ScopeFeature const &feature); | |||
| ~ScopeFeature(); | |||
| @@ -235,8 +296,9 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopePattern { | |||
| public: | |||
| ScopePattern(); | |||
| ~ScopePattern(); | |||
| ATTRIBUTED_DEPRECATED(ScopePattern &SetSubType(const char *)) | |||
| ScopePattern &SetSubType(const std::string &sub_type); | |||
| ScopePattern &SetSubType(const char *sub_type); | |||
| ScopePattern &AddNodeOpTypeFeature(NodeOpTypeFeature feature); | |||
| ScopePattern &AddNodeAttrFeature(NodeAttrFeature feature); | |||
| ScopePattern &AddScopeFeature(ScopeFeature feature); | |||
| @@ -296,19 +358,23 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFusionPassRegistry { | |||
| return instance; | |||
| } | |||
| ATTRIBUTED_DEPRECATED(void RegisterScopeFusionPass(const char *, CreateFn, bool)) | |||
| void RegisterScopeFusionPass(const std::string &pass_name, CreateFn create_fn, bool is_general); | |||
| void RegisterScopeFusionPass(const char *pass_name, CreateFn create_fn, bool is_general); | |||
| private: | |||
| ScopeFusionPassRegistry(); | |||
| class ScopeFusionPassRegistryImpl; | |||
| /*lint -e148*/ | |||
| std::unique_ptr<ScopeFusionPassRegistryImpl> impl_; | |||
| friend class TensorFlowModelParser; | |||
| }; | |||
| class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeUtil { | |||
| public: | |||
| ATTRIBUTED_DEPRECATED(static AscendString StringReplaceAll(const char *, const char *, const char *)) | |||
| static std::string StringReplaceAll(std::string str, const std::string &old_value, const std::string &new_value); | |||
| static AscendString StringReplaceAll(const char *str, const char *old_value, const char *new_value); | |||
| static void FreeScopePatterns(ScopeFusionPatterns &patterns); | |||
| static void FreeOneBatchPattern(std::vector<ScopePattern *> &one_batch_pattern); | |||
| }; | |||
| @@ -0,0 +1,91 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef __INC_EXTERNEL_RT_ERROR_CODES_H__ | |||
| #define __INC_EXTERNEL_RT_ERROR_CODES_H__ | |||
| #include <stddef.h> | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| static const int32_t ACL_RT_SUCCESS = 0; // success | |||
| static const int32_t ACL_ERROR_RT_PARAM_INVALID = 107000; // param invalid | |||
| static const int32_t ACL_ERROR_RT_INVALID_DEVICEID = 107001; // invalid device id | |||
| static const int32_t ACL_ERROR_RT_CONTEXT_NULL = 107002; // current context null | |||
| static const int32_t ACL_ERROR_RT_STREAM_CONTEXT = 107003; // stream not in current context | |||
| static const int32_t ACL_ERROR_RT_MODEL_CONTEXT = 107004; // model not in current context | |||
| static const int32_t ACL_ERROR_RT_STREAM_MODEL = 107005; // stream not in model | |||
| static const int32_t ACL_ERROR_RT_EVENT_TIMESTAMP_INVALID = 107006; // event timestamp invalid | |||
| static const int32_t ACL_ERROR_RT_EVENT_TIMESTAMP_REVERSAL = 107007; // event timestamp reversal | |||
| static const int32_t ACL_ERROR_RT_ADDR_UNALIGNED = 107008; // memory address unaligned | |||
| static const int32_t ACL_ERROR_RT_FILE_OPEN = 107009; // open file failed | |||
| static const int32_t ACL_ERROR_RT_FILE_WRITE = 107010; // write file failed | |||
| static const int32_t ACL_ERROR_RT_STREAM_SUBSCRIBE = 107011; // error subscribe stream | |||
| static const int32_t ACL_ERROR_RT_THREAD_SUBSCRIBE = 107012; // error subscribe thread | |||
| static const int32_t ACL_ERROR_RT_GROUP_NOT_SET = 107013; // group not set | |||
| static const int32_t ACL_ERROR_RT_GROUP_NOT_CREATE = 107014; // group not create | |||
| static const int32_t ACL_ERROR_RT_STREAM_NO_CB_REG = 107015; // callback not register to stream | |||
| static const int32_t ACL_ERROR_RT_INVALID_MEMORY_TYPE = 107016; // invalid memory type | |||
| static const int32_t ACL_ERROR_RT_FEATURE_NOT_SUPPROT = 207000; // feature not support | |||
| static const int32_t ACL_ERROR_RT_MEMORY_ALLOCATION = 207001; // memory allocation error | |||
| static const int32_t ACL_ERROR_RT_MEMORY_FREE = 207002; // memory free error | |||
| static const int32_t ACL_ERROR_RT_INTERNEL_ERROR = 507000; // runtime internel error | |||
| static const int32_t ACL_ERROR_RT_TS_ERROR = 507001; // ts internel error | |||
| static const int32_t ACL_ERROR_RT_STREAM_TASK_FULL = 507002; // task full in stream | |||
| static const int32_t ACL_ERROR_RT_STREAM_TASK_EMPTY = 507003; // task empty in stream | |||
| static const int32_t ACL_ERROR_RT_STREAM_NOT_COMPLETE = 507004; // stream not complete | |||
| static const int32_t ACL_ERROR_RT_END_OF_SEQUENCE = 507005; // end of sequence | |||
| static const int32_t ACL_ERROR_RT_EVENT_NOT_COMPLETE = 507006; // event not complete | |||
| static const int32_t ACL_ERROR_RT_CONTEXT_RELEASE_ERROR = 507007; // context release error | |||
| static const int32_t ACL_ERROR_RT_SOC_VERSION = 507008; // soc version error | |||
| static const int32_t ACL_ERROR_RT_TASK_TYPE_NOT_SUPPORT = 507009; // task type not support | |||
| static const int32_t ACL_ERROR_RT_LOST_HEARTBEAT = 507010; // ts lost heartbeat | |||
| static const int32_t ACL_ERROR_RT_MODEL_EXECUTE = 507011; // model execute failed | |||
| static const int32_t ACL_ERROR_RT_REPORT_TIMEOUT = 507012; // report timeout | |||
| static const int32_t ACL_ERROR_RT_SYS_DMA = 507013; // sys dma error | |||
| static const int32_t ACL_ERROR_RT_AICORE_TIMEOUT = 507014; // aicore timeout | |||
| static const int32_t ACL_ERROR_RT_AICORE_EXCEPTION = 507015; // aicore exception | |||
| static const int32_t ACL_ERROR_RT_AICORE_TRAP_EXCEPTION = 507016; // aicore trap exception | |||
| static const int32_t ACL_ERROR_RT_AICPU_TIMEOUT = 507017; // aicpu timeout | |||
| static const int32_t ACL_ERROR_RT_AICPU_EXCEPTION = 507018; // aicpu exception | |||
| static const int32_t ACL_ERROR_RT_AICPU_DATADUMP_RSP_ERR = 507019; // aicpu datadump response error | |||
| static const int32_t ACL_ERROR_RT_AICPU_MODEL_RSP_ERR = 507020; // aicpu model operate response error | |||
| static const int32_t ACL_ERROR_RT_PROFILING_ERROR = 507021; // profiling error | |||
| static const int32_t ACL_ERROR_RT_IPC_ERROR = 507022; // ipc error | |||
| static const int32_t ACL_ERROR_RT_MODEL_ABORT_NORMAL = 507023; // model abort normal | |||
| static const int32_t ACL_ERROR_RT_KERNEL_UNREGISTERING = 507024; // kernel unregistering | |||
| static const int32_t ACL_ERROR_RT_RINGBUFFER_NOT_INIT = 507025; // ringbuffer not init | |||
| static const int32_t ACL_ERROR_RT_RINGBUFFER_NO_DATA = 507026; // ringbuffer no data | |||
| static const int32_t ACL_ERROR_RT_KERNEL_LOOKUP = 507027; // kernel lookup error | |||
| static const int32_t ACL_ERROR_RT_KERNEL_DUPLICATE = 507028; // kernel register duplicate | |||
| static const int32_t ACL_ERROR_RT_DEBUG_REGISTER_FAIL = 507029; // debug register failed | |||
| static const int32_t ACL_ERROR_RT_DEBUG_UNREGISTER_FAIL = 507030; // debug unregister failed | |||
| static const int32_t ACL_ERROR_RT_LABEL_CONTEXT = 507031; // label not in current context | |||
| static const int32_t ACL_ERROR_RT_PROGRAM_USE_OUT = 507032; // program register num use out | |||
| static const int32_t ACL_ERROR_RT_DEV_SETUP_ERROR = 507033; // device setup error | |||
| static const int32_t ACL_ERROR_RT_DRV_INTERNEL_ERROR = 507899; // drv internel error | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif // __INC_EXTERNEL_RT_ERROR_CODES_H__ | |||
| @@ -18,24 +18,39 @@ | |||
| #define INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_ | |||
| #include <cstdint> | |||
| #include <unistd.h> | |||
| #include <sys/syscall.h> | |||
| #include "framework/common/ge_inner_error_codes.h" | |||
| #include "toolchain/slog.h" | |||
| #ifdef __GNUC__ | |||
| #include <unistd.h> | |||
| #include <sys/syscall.h> | |||
| #else | |||
| #include "mmpa/mmpa_api.h" | |||
| #endif | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #define GE_MODULE_NAME static_cast<int>(GE) | |||
| // trace status of log | |||
| enum TraceStatus { TRACE_INIT = 0, TRACE_RUNNING, TRACE_WAITING, TRACE_STOP }; | |||
| #define GELOGE(ERROR_CODE, ...) GE_LOG_ERROR(GE_MODULE_NAME, ERROR_CODE, __VA_ARGS__) | |||
| #define GELOGW(...) GE_LOG_WARN(GE_MODULE_NAME, __VA_ARGS__) | |||
| #define GELOGI(...) GE_LOG_INFO(GE_MODULE_NAME, __VA_ARGS__) | |||
| #define GELOGD(...) GE_LOG_DEBUG(GE_MODULE_NAME, __VA_ARGS__) | |||
| #define GEEVENT(...) GE_LOG_EVENT(GE_MODULE_NAME, __VA_ARGS__) | |||
| #define GELOGO(...) GE_LOG_OPLOG(GE_MODULE_NAME, __VA_ARGS__) | |||
| #define GELOGT(VALUE, ...) GE_LOG_TRACE(GE_MODULE_NAME, VALUE, __VA_ARGS__) | |||
| class GeLog { | |||
| public: | |||
| #ifdef __GNUC__ | |||
| static pid_t GetTid() { | |||
| thread_local static pid_t tid = syscall(__NR_gettid); | |||
| return tid; | |||
| } | |||
| #else | |||
| static int GetTid() { | |||
| thread_local static int tid = static_cast<int>(GetCurrentThreadId()); | |||
| return tid; | |||
| } | |||
| #endif | |||
| }; | |||
| inline bool IsLogEnable(int module_name, int log_level) { | |||
| int32_t enable = CheckLogLevel(module_name, log_level); | |||
| @@ -46,33 +61,57 @@ inline bool IsLogEnable(int module_name, int log_level) { | |||
| return false; | |||
| } | |||
| inline pid_t GetTid() { | |||
| thread_local static pid_t tid = syscall(__NR_gettid); | |||
| return tid; | |||
| } | |||
| #define GELOGE(ERROR_CODE, fmt, ...) \ | |||
| dlog_error(GE_MODULE_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \ | |||
| ((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ##__VA_ARGS__) | |||
| #define GELOGW(fmt, ...) \ | |||
| if (IsLogEnable(GE_MODULE_NAME, DLOG_WARN)) \ | |||
| dlog_warn(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| #define GELOGI(fmt, ...) \ | |||
| if (IsLogEnable(GE_MODULE_NAME, DLOG_INFO)) \ | |||
| dlog_info(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| #define GELOGD(fmt, ...) \ | |||
| if (IsLogEnable(GE_MODULE_NAME, DLOG_DEBUG)) \ | |||
| dlog_debug(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| #define GEEVENT(fmt, ...) dlog_event(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| #define GELOGO(fmt, ...) Dlog(GE_MODULE_NAME, DLOG_OPLOG, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| #define GELOGT(VALUE, fmt, ...) \ | |||
| do { \ | |||
| TraceStatus stat = VALUE; \ | |||
| const char *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \ | |||
| int idx = static_cast<int>(stat); \ | |||
| char *k = const_cast<char *>("status"); \ | |||
| char *v = const_cast<char *>(TraceStatStr[idx]); \ | |||
| KeyValue kv = {k, v}; \ | |||
| DlogWithKV(static_cast<int>(GE_MODULE_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, \ | |||
| ##__VA_ARGS__); \ | |||
| } while (0) | |||
| #define GE_LOG_ERROR(MOD_NAME, ERROR_CODE, fmt, ...) \ | |||
| dlog_error(MOD_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GetTid(), __FUNCTION__, ERROR_CODE, \ | |||
| #define GE_LOG_ERROR(MOD_NAME, ERROR_CODE, fmt, ...) \ | |||
| dlog_error(MOD_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \ | |||
| ((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ##__VA_ARGS__) | |||
| #define GE_LOG_WARN(MOD_NAME, fmt, ...) \ | |||
| if (IsLogEnable(MOD_NAME, DLOG_WARN)) dlog_warn(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| if (IsLogEnable(MOD_NAME, DLOG_WARN)) dlog_warn(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| #define GE_LOG_INFO(MOD_NAME, fmt, ...) \ | |||
| if (IsLogEnable(MOD_NAME, DLOG_INFO)) dlog_info(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| if (IsLogEnable(MOD_NAME, DLOG_INFO)) dlog_info(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| #define GE_LOG_DEBUG(MOD_NAME, fmt, ...) \ | |||
| if (IsLogEnable(MOD_NAME, DLOG_DEBUG)) dlog_debug(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| #define GE_LOG_EVENT(MOD_NAME, fmt, ...) dlog_event(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| if (IsLogEnable(MOD_NAME, DLOG_DEBUG)) \ | |||
| dlog_debug(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| #define GE_LOG_EVENT(MOD_NAME, fmt, ...) \ | |||
| dlog_event(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| #define GE_LOG_OPLOG(MOD_NAME, fmt, ...) \ | |||
| Dlog(MOD_NAME, DLOG_OPLOG, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| Dlog(MOD_NAME, DLOG_OPLOG, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| #define GE_LOG_TRACE(MOD_NAME, value, fmt, ...) \ | |||
| do { \ | |||
| TraceStatus stat = value; \ | |||
| const char *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \ | |||
| int idx = static_cast<int>(stat); \ | |||
| char *k = const_cast<char *>("status"); \ | |||
| char *v = const_cast<char *>(TraceStatStr[idx]); \ | |||
| KeyValue kv = {k, v}; \ | |||
| DlogWithKV(static_cast<int>(MOD_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__); \ | |||
| #define GE_LOG_TRACE(MOD_NAME, value, fmt, ...) \ | |||
| do { \ | |||
| TraceStatus stat = value; \ | |||
| const char *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \ | |||
| int idx = static_cast<int>(stat); \ | |||
| char *k = const_cast<char *>("status"); \ | |||
| char *v = const_cast<char *>(TraceStatStr[idx]); \ | |||
| KeyValue kv = {k, v}; \ | |||
| DlogWithKV(static_cast<int>(MOD_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, \ | |||
| ##__VA_ARGS__); \ | |||
| } while (0) | |||
| // print memory when it is greater than 1KB. | |||
| @@ -82,4 +121,7 @@ inline pid_t GetTid() { | |||
| GELOGI("MallocMemory, func=%s, size=%zu, purpose=%s", (#FUNC), static_cast<size_t>(SIZE), (PURPOSE)); \ | |||
| } \ | |||
| } while (0); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif // INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_ | |||
| @@ -18,10 +18,12 @@ | |||
| #define INC_FRAMEWORK_COMMON_DEBUG_LOG_H_ | |||
| #include <string> | |||
| #include <sstream> | |||
| #include "runtime/rt.h" | |||
| #include "common/string_util.h" | |||
| #include "common/util.h" | |||
| #include "common/util/error_manager/error_manager.h" | |||
| #include "framework/common/debug/ge_log.h" | |||
| #include "ge/ge_api_error_codes.h" | |||
| @@ -253,4 +255,29 @@ | |||
| exec_expr1; \ | |||
| } | |||
| #define GE_ERRORLOG_AND_ERRORMSG(_status, errormsg) \ | |||
| { \ | |||
| GELOGE(_status, "%s", errormsg); \ | |||
| ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {errormsg}); \ | |||
| } | |||
| #define GE_CHK_LOG_AND_ERRORMSG(expr, _status, errormsg) \ | |||
| do { \ | |||
| bool b = (expr); \ | |||
| if (!b) { \ | |||
| GELOGE(_status, "%s", errormsg); \ | |||
| ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {errormsg}); \ | |||
| return _status; \ | |||
| } \ | |||
| } while (0) | |||
| template <typename T> | |||
| std::string FmtToStr(const T &t) { | |||
| std::string fmt; | |||
| std::stringstream st; | |||
| st << "[" << t << "]"; | |||
| fmt = st.str(); | |||
| return fmt; | |||
| } | |||
| #endif // INC_FRAMEWORK_COMMON_DEBUG_LOG_H_ | |||
| @@ -0,0 +1,32 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_FRAMEWORK_COMMON_GE_COMPILER_OPTIONS_H_ | |||
| #define INC_FRAMEWORK_COMMON_GE_COMPILER_OPTIONS_H_ | |||
| namespace ge { | |||
| #ifdef __GNUC__ | |||
| #define GE_ATTRIBUTE_UNUSED __attribute__((unused)) | |||
| #define GE_FUNCTION_IDENTIFIER __PRETTY_FUNCTION__ | |||
| #define GE_BUILTIN_PREFETCH(args_addr) __builtin_prefetch(args_addr) | |||
| #else | |||
| #define GE_ATTRIBUTE_UNUSED | |||
| #define GE_FUNCTION_IDENTIFIER __FUNCSIG__ | |||
| #define GE_BUILTIN_PREFETCH(args_addr) | |||
| #endif | |||
| } // namespace ge | |||
| #endif // INC_FRAMEWORK_COMMON_GE_COMPILER_OPTIONS_H_ | |||
| @@ -14,7 +14,6 @@ | |||
| * limitations under the License. | |||
| */ | |||
| /*lint -e* */ | |||
| #ifndef INC_FRAMEWORK_COMMON_GE_INNER_ERROR_CODES_H_ | |||
| #define INC_FRAMEWORK_COMMON_GE_INNER_ERROR_CODES_H_ | |||
| @@ -304,6 +303,7 @@ GE_ERRORNO_EXECUTOR(GE_EXEC_ALLOC_WEIGHT_MEM_FAILED, 16, "Failed to allocate wei | |||
| GE_ERRORNO_EXECUTOR(GE_EXEC_ALLOC_VAR_MEM_FAILED, 17, "Failed to allocate variable memory."); | |||
| GE_ERRORNO_EXECUTOR(GE_AIPP_NOT_EXIST, 18, "GE AIPP is not exist."); | |||
| GE_ERRORNO_EXECUTOR(GE_DYNAMIC_AIPP_NOT_SUPPORT_QUERY, 19, "GE Dynamic AIPP is not support to query temporarily."); | |||
| GE_ERRORNO_EXECUTOR(GE_EXEC_ALLOC_P2P_MEM_FAILED, 20, "Failed to allocate P2P memory"); | |||
| // Generator module error code definition | |||
| GE_ERRORNO_GENERATOR(GE_GENERATOR_GRAPH_MANAGER_INIT_FAILED, 1, "Graph manager initialize failed."); | |||
| @@ -48,6 +48,8 @@ enum OpEngineType { | |||
| ENGINE_AIVECTOR = 4 // not support | |||
| }; | |||
| enum InputAippType { DATA_WITHOUT_AIPP = 0, DATA_WITH_STATIC_AIPP, DATA_WITH_DYNAMIC_AIPP, DYNAMIC_AIPP_NODE }; | |||
| const char *const GE_ENGINE_ATTR_MEM_TYPE_HBM = "HBM"; | |||
| const char *const GE_OPTION_EXEC_PLACEMENT = "ge.exec.placement"; | |||
| @@ -103,6 +105,7 @@ struct ShapeDescription { | |||
| int64_t height = 0; | |||
| int64_t width = 0; | |||
| std::vector<int64_t> dims; | |||
| std::vector<std::pair<int64_t, int64_t>> shape_ranges; | |||
| }; | |||
| // Definition of input and output description information | |||
| @@ -21,7 +21,6 @@ | |||
| #include <unordered_map> | |||
| #include <string> | |||
| #include "common/types.h" | |||
| #include "graph/debug/ge_attr_define.h" | |||
| #include "proto/om.pb.h" | |||
| @@ -22,7 +22,8 @@ | |||
| #include <vector> | |||
| #include "common/op/attr_value_util.h" | |||
| #include "common/types.h" | |||
| #include "register/register_types.h" | |||
| #include "register/register_error_codes.h" | |||
| #include "common/util.h" | |||
| #include "graph/attr_value.h" | |||
| #include "graph/ge_tensor.h" | |||
| @@ -17,6 +17,7 @@ | |||
| #ifndef INC_FRAMEWORK_COMMON_STRING_UTIL_H_ | |||
| #define INC_FRAMEWORK_COMMON_STRING_UTIL_H_ | |||
| #include <cctype> | |||
| #include <securec.h> | |||
| #include <algorithm> | |||
| @@ -36,8 +37,8 @@ class StringUtils { | |||
| #endif | |||
| return s; | |||
| } | |||
| // lint -esym(551,*) | |||
| static std::string &Rtrim(std::string &s) { /*lint !e618*/ | |||
| static std::string &Rtrim(std::string &s) { | |||
| #if __cplusplus >= 201103L | |||
| (void)s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int c) { return !std::isspace(c); })); | |||
| #else | |||
| @@ -45,7 +46,7 @@ class StringUtils { | |||
| #endif | |||
| return s; | |||
| } | |||
| // lint -esym(551,*) | |||
| /// | |||
| /// @ingroup domi_common | |||
| /// @brief delete spaces at the beginning and end of a string | |||
| @@ -18,7 +18,6 @@ | |||
| #define INC_FRAMEWORK_COMMON_TYPES_H_ | |||
| #include <limits.h> | |||
| #include <linux/limits.h> | |||
| #include <stdint.h> | |||
| #include <algorithm> | |||
| #include <map> | |||
| @@ -70,6 +69,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFIL | |||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILE_STOP_VALUE; | |||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::map<std::string, std::string> PROFILE_COMPONENT_MAP; | |||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILE_CONFIG; | |||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILE_MODEL_ID; | |||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_ATTR_TASKS; | |||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_ATTR_TASK_GEN_BASE_ADDR; | |||
| @@ -434,6 +434,7 @@ REGISTER_OPTYPE_DECLARE(HCOMREDUCESCATTER, "HcomReduceScatter"); | |||
| REGISTER_OPTYPE_DECLARE(HCOMSEND, "HcomSend"); | |||
| REGISTER_OPTYPE_DECLARE(HCOMRECEIVE, "HcomReceive"); | |||
| REGISTER_OPTYPE_DECLARE(HCOMREMOTEREAD, "HcomRemoteRead"); | |||
| REGISTER_OPTYPE_DECLARE(HCOMREMOTEREFREAD, "HcomRemoteRefRead"); | |||
| REGISTER_OPTYPE_DECLARE(HCOMREMOTEWRITE, "HcomRemoteWrite"); | |||
| REGISTER_OPTYPE_DECLARE(VARASSIGN, "VarAssign"); | |||
| @@ -448,6 +449,7 @@ REGISTER_OPTYPE_DECLARE(MEMCPYASYNC, "MemcpyAsync"); | |||
| REGISTER_OPTYPE_DECLARE(MEMCPYADDRASYNC, "MemcpyAddrAsync"); | |||
| REGISTER_OPTYPE_DECLARE(STREAMMERGE, "StreamMerge"); | |||
| REGISTER_OPTYPE_DECLARE(ENDGRAPH, "EndGraph"); | |||
| REGISTER_OPTYPE_DECLARE(MODELEXIT, "ModelExit"); | |||
| REGISTER_OPTYPE_DECLARE(SEND, "Send"); | |||
| REGISTER_OPTYPE_DECLARE(RECV, "Recv"); | |||
| REGISTER_OPTYPE_DECLARE(ENDOFSEQUENCE, "EndOfSequence"); | |||
| @@ -523,7 +525,10 @@ REGISTER_OPTYPE_DECLARE(HVDCALLBACKALLGATHER, "HorovodAllgather"); | |||
| REGISTER_OPTYPE_DECLARE(HVDCALLBACKBROADCAST, "HorovodBroadcast"); | |||
| REGISTER_OPTYPE_DECLARE(HVDWAIT, "HorovodWait"); | |||
| enum InputMode { INPUT = 0, CONST }; | |||
| // aicpu op for online_infer dynamic_dims | |||
| REGISTER_OPTYPE_DECLARE(GETDYNAMICDIMS, "GetDynamicDims"); | |||
| enum InputMode { INPUT = 0, CONST_INPUT }; | |||
| // Definition of the processing status enum of the process module | |||
| enum ModelProcessState { | |||
| @@ -345,7 +345,7 @@ std::string ToString(const google::protobuf::RepeatedField<T> &rpd_field) { | |||
| /// @return Timestamp, in microseconds (US) | |||
| /// | |||
| /// | |||
| uint64_t GetCurrentTimestap(); | |||
| uint64_t GetCurrentTimestamp(); | |||
| /// | |||
| /// @ingroup domi_common | |||
| @@ -30,6 +30,7 @@ enum PriorityEnum { | |||
| COST_0 = 0, | |||
| COST_1, | |||
| COST_2, | |||
| COST_3, | |||
| COST_9 = 9, | |||
| COST_10 = 10, | |||
| }; | |||
| @@ -163,6 +163,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeExecutor { | |||
| ge::Status GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigInfo &aipp_info); | |||
| ge::Status GetModelAttr(uint32_t model_id, std::vector<std::string> &dynamic_output_shape_info); | |||
| ge::Status GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index); | |||
| ge::Status GetModelDescInfoForZeroCopy(uint32_t model_id, std::vector<ge::TensorDesc> &input_desc, | |||
| std::vector<ge::TensorDesc> &output_desc); | |||
| @@ -268,6 +270,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeExecutor { | |||
| static ge::Status ReleaseSingleOpResource(void *stream); | |||
| static ge::Status GetDeviceIdByModelId(uint32_t model_id, uint32_t &device_id); | |||
| ge::Status GetBatchInfoSize(uint32_t model_id, size_t &shape_count); | |||
| ge::Status GetOrigInputInfo(uint32_t model_id, uint32_t index, OriginInputInfo &orig_input_info); | |||
| ge::Status GetAllAippInputOutputDims(uint32_t model_id, uint32_t index, std::vector<InputOutputDims> &input_dims, | |||
| @@ -18,7 +18,6 @@ | |||
| #define INC_FRAMEWORK_GE_RUNTIME_TASK_INFO_H_ | |||
| #include <stdint.h> | |||
| #include <functional> | |||
| #include <memory> | |||
| #include <string> | |||
| #include <utility> | |||
| @@ -219,9 +218,9 @@ class LabelSwitchTaskInfo : public TaskInfo { | |||
| label_list_(label_list), | |||
| cond_(cond) {} | |||
| ~LabelSwitchTaskInfo() override {} | |||
| uint32_t label_size() { return label_size_; }; | |||
| const std::vector<uint32_t> &label_list() { return label_list_; }; | |||
| void *cond() { return cond_; }; | |||
| uint32_t label_size() const { return label_size_; } | |||
| const std::vector<uint32_t> &label_list() const { return label_list_; } | |||
| void *cond() const { return cond_; } | |||
| private: | |||
| uint32_t label_size_; | |||
| @@ -236,7 +235,7 @@ class EventTaskInfo : public TaskInfo { | |||
| protected: | |||
| EventTaskInfo(const std::string &op_name, uint32_t stream_id, TaskInfoType type, uint32_t event_id) | |||
| : TaskInfo(op_name, stream_id, type, false), event_id_(event_id) {} | |||
| virtual ~EventTaskInfo() override {} | |||
| ~EventTaskInfo() override {} | |||
| uint32_t event_id_; | |||
| }; | |||
| @@ -272,16 +271,13 @@ class FusionEndTaskInfo : public TaskInfo { | |||
| class HcclTaskInfo : public TaskInfo { | |||
| public: | |||
| HcclTaskInfo(const std::string &op_name, uint32_t stream_id, const std::string hccl_type, void *input_data_addr, | |||
| void *output_data_addr, void *workspace_addr, int64_t workspace_size, int64_t hccl_stream_num, | |||
| void *output_data_addr, int64_t workspace_size, int64_t hccl_stream_num, | |||
| const std::vector<uint8_t> &private_def, void *ops_kernel_store, int32_t count, int64_t root_id, | |||
| int64_t op_type, int64_t data_type, const std::string &group, | |||
| std::function<bool(void *, void *)> hcom_bind_model, std::function<bool(void *)> hcom_unbind_model, | |||
| std::function<bool(std::shared_ptr<HcclTaskInfo>, void *)> hcom_distribute_task, bool dump_flag) | |||
| int64_t op_type, int64_t data_type, const std::string &group, bool dump_flag) | |||
| : TaskInfo(op_name, stream_id, TaskInfoType::HCCL, dump_flag), | |||
| hccl_type_(hccl_type), | |||
| input_data_addr_(input_data_addr), | |||
| output_data_addr_(output_data_addr), | |||
| workspace_addr_(workspace_addr), | |||
| workspace_size_(workspace_size), | |||
| hccl_stream_num_(hccl_stream_num), | |||
| private_def_(private_def), | |||
| @@ -290,16 +286,12 @@ class HcclTaskInfo : public TaskInfo { | |||
| root_id_(root_id), | |||
| op_type_(op_type), | |||
| data_type_(data_type), | |||
| group_(group), | |||
| hcom_bind_model_(hcom_bind_model), | |||
| hcom_unbind_model_(hcom_unbind_model), | |||
| hcom_distribute_task_(hcom_distribute_task) {} | |||
| group_(group) {} | |||
| ~HcclTaskInfo() override {} | |||
| const std::string &hccl_type() const { return hccl_type_; } | |||
| void *input_data_addr() const { return input_data_addr_; } | |||
| void *output_data_addr() const { return output_data_addr_; } | |||
| void *workspace_addr() const { return workspace_addr_; } | |||
| int64_t workspace_size() const { return workspace_size_; } | |||
| int64_t hccl_stream_num() const { return hccl_stream_num_; } | |||
| const std::vector<uint8_t> &private_def() const { return private_def_; } | |||
| @@ -309,17 +301,11 @@ class HcclTaskInfo : public TaskInfo { | |||
| int64_t op_type() const { return op_type_; } | |||
| int64_t data_type() const { return data_type_; } | |||
| const std::string &group() const { return group_; } | |||
| std::function<bool(void *, void *)> hcom_bind_model() const { return hcom_bind_model_; } | |||
| std::function<bool(void *)> hcom_unbind_model() const { return hcom_unbind_model_; } | |||
| std::function<bool(std::shared_ptr<HcclTaskInfo>, void *)> hcom_distribute_task() const { | |||
| return hcom_distribute_task_; | |||
| } | |||
| private: | |||
| std::string hccl_type_; | |||
| void *input_data_addr_; | |||
| void *output_data_addr_; | |||
| void *workspace_addr_; | |||
| int64_t workspace_size_; | |||
| int64_t hccl_stream_num_; | |||
| std::vector<uint8_t> private_def_; | |||
| @@ -329,9 +315,6 @@ class HcclTaskInfo : public TaskInfo { | |||
| int64_t op_type_; | |||
| int64_t data_type_; | |||
| std::string group_; | |||
| std::function<bool(void *, void *)> hcom_bind_model_; | |||
| std::function<bool(void *)> hcom_unbind_model_; | |||
| std::function<bool(std::shared_ptr<HcclTaskInfo>, void *)> hcom_distribute_task_; | |||
| }; | |||
| class ProfilerTraceTaskInfo : public TaskInfo { | |||
| @@ -86,6 +86,7 @@ class GeGenerator { | |||
| Status BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &inputs, const vector<GeTensor> &outputs, | |||
| const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, | |||
| bool is_offline = true); | |||
| Status CheckForSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &inputs, const vector<GeTensor> &outputs); | |||
| class Impl; | |||
| @@ -21,6 +21,7 @@ | |||
| #include <vector> | |||
| #include "ge/ge_api_error_codes.h" | |||
| #include "graph//types.h" | |||
| #include "runtime/mem.h" | |||
| namespace ge { | |||
| @@ -35,6 +36,12 @@ struct HostVarInfo { | |||
| uint64_t var_size; | |||
| }; | |||
| struct TensorInfo { | |||
| std::string var_name; | |||
| std::vector<int64_t> dims; | |||
| DataType data_type; | |||
| }; | |||
| /// | |||
| /// \param size [in] rdma pool memory size to be allocated. | |||
| /// \param mem_type [in] memory type for rdma pool. | |||
| @@ -47,6 +54,13 @@ Status InitRdmaPool(size_t size, rtMemType_t mem_type = RT_MEMORY_HBM); | |||
| /// \return Status result of function | |||
| Status RdmaRemoteRegister(const std::vector<HostVarInfo> &var_info, rtMemType_t mem_type = RT_MEMORY_HBM); | |||
| /// | |||
| /// \param tensor_info [in] description for tensor stored shared memory. | |||
| /// \param dev_addr [out] malloced shared memory addr. | |||
| /// \param memory_size [out] malloced shared memory size. | |||
| /// \return Status result of function | |||
| Status MallocSharedMemory(const TensorInfo &tensor_info, uint64_t &dev_addr, uint64_t &memory_size); | |||
| /// | |||
| /// \param var_name [in] var_name name of host variable. | |||
| /// \param base_addr [out] base_addr vase addr of host variable. | |||
| @@ -33,7 +33,7 @@ class MemoryAssigner { | |||
| MemoryAssigner &operator=(const MemoryAssigner &) = delete; | |||
| Status AssignMemory(bool is_loop_graph, size_t &mem_offset, size_t &zero_copy_mem_size); | |||
| Status AssignMemory(bool is_loop_graph, map<int64_t, size_t> &mem_offset, size_t &zero_copy_mem_size); | |||
| private: | |||
| ge::ComputeGraphPtr compute_graph_; | |||
| @@ -21,7 +21,6 @@ | |||
| #include <string> | |||
| #include <unordered_map> | |||
| #include <vector> | |||
| #include "framework/common/types.h" | |||
| #include "framework/omg/omg_inner_types.h" | |||
| #include "framework/omg/parser/parser_inner_ctx.h" | |||
| #include "proto/ge_ir.pb.h" | |||
| @@ -92,8 +91,6 @@ void GetGroupName(ge::proto::ModelDef &model); | |||
| void FindParserSo(const string &path, vector<string> &fileList, string &caffe_parser_path); | |||
| Status CheckCustomAiCpuOpLib(); | |||
| Status DumpInfershapeJson(const ge::Graph &graph, const char *json_file); | |||
| Status SetOutputNodeInfo(ge::Graph &graph, const std::string &output_type, const std::string &output_format); | |||
| @@ -25,7 +25,6 @@ | |||
| #include <utility> | |||
| #include <vector> | |||
| #include "framework/common/fmk_error_codes.h" | |||
| #include "framework/common/types.h" | |||
| #include "register/register_fmk_types.h" | |||
| using domi::DOMI_TENSOR_ND; | |||
| @@ -92,12 +91,17 @@ struct OmgContext { | |||
| std::map<std::string, std::vector<int32_t>> out_nodes_map; | |||
| // user-designate out nodes (this is used for determing the orders) | |||
| std::vector<std::pair<std::string, int32_t>> user_out_nodes; | |||
| // default out nodes (this is used for determing the orders) | |||
| std::vector<std::pair<std::string, int32_t>> default_out_nodes; | |||
| // save the output node of the network, value = topName, | |||
| // topName indicates the output name of the operator. | |||
| std::vector<std::string> user_out_nodes_top_vec; | |||
| // net out nodes (where user_out_nodes or leaf nodes) | |||
| std::vector<std::string> net_out_nodes; | |||
| // net out nodes top names(only caffe has top) | |||
| std::vector<std::string> out_top_names; | |||
| // path for the aicpu custom operator so_file | |||
| std::vector<std::string> aicpu_op_run_paths; | |||
| // net data nodes top names(only caffe has top) | |||
| std::vector<std::string> data_top_names; | |||
| // preferential format used by the entire network | |||
| domiTensorFormat_t net_format = DOMI_TENSOR_RESERVED; | |||
| domi::FrameworkType type = domi::FRAMEWORK_RESERVED; | |||
| @@ -111,6 +115,10 @@ struct OmgContext { | |||
| std::string dynamic_batch_size; | |||
| std::string dynamic_image_size; | |||
| std::string dynamic_dims; | |||
| std::string dynamic_node_type; | |||
| std::vector<std::vector<int64_t>> user_real_input_dims; | |||
| std::vector<int64_t> cur_dynamic_dims; | |||
| bool need_multi_batch = false; | |||
| }; | |||
| } // namespace ge | |||
| @@ -17,6 +17,8 @@ | |||
| #ifndef INC_GRAPH_ANCHOR_H_ | |||
| #define INC_GRAPH_ANCHOR_H_ | |||
| #include "graph/compiler_options.h" | |||
| #include <memory> | |||
| #include <string> | |||
| #include <vector> | |||
| @@ -128,7 +130,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Anchor : public std::enable | |||
| template <class T> | |||
| static Anchor::TYPE TypeOf() { | |||
| static_assert(std::is_base_of<Anchor, T>::value, "T must be a Anchor!"); | |||
| return __PRETTY_FUNCTION__; | |||
| return METADEF_FUNCTION_IDENTIFIER; | |||
| } | |||
| public: | |||
| @@ -20,6 +20,7 @@ | |||
| #include <string> | |||
| #include <vector> | |||
| #include "graph/ge_attr_value.h" | |||
| #include "graph/compiler_options.h" | |||
| namespace ge { | |||
| @@ -92,7 +93,7 @@ class _GeSerializable { | |||
| SaveItem(namedAttrs, args...); | |||
| } | |||
| static void SaveItem(GeAttrValue::NAMED_ATTRS &namedAttrs __attribute__((__unused__))) {} | |||
| static void SaveItem(GeAttrValue::NAMED_ATTRS &namedAttrs METADEF_ATTRIBUTE_UNUSED) {} | |||
| template <class T, class... Args> | |||
| static graphStatus LoadItem(GeAttrValue::NAMED_ATTRS &namedAttrs, string itemName, T &item, Args &... args) { | |||
| @@ -104,9 +105,7 @@ class _GeSerializable { | |||
| return LoadItem(namedAttrs, args...); | |||
| } | |||
| static graphStatus LoadItem(GeAttrValue::NAMED_ATTRS &namedAttrs __attribute__((__unused__))) { | |||
| return GRAPH_SUCCESS; | |||
| } | |||
| static graphStatus LoadItem(GeAttrValue::NAMED_ATTRS &namedAttrs METADEF_ATTRIBUTE_UNUSED) { return GRAPH_SUCCESS; } | |||
| }; | |||
| #define _GE_FI(a) #a, a | |||
| @@ -57,11 +57,11 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Buffer { | |||
| // For compatibility | |||
| inline const std::uint8_t *data() const { return GetData(); } | |||
| inline std::uint8_t *data() { return GetData(); } // lint !e659 | |||
| inline std::uint8_t *data() { return GetData(); } | |||
| inline std::size_t size() const { return GetSize(); } | |||
| inline void clear() { return ClearBuffer(); } | |||
| uint8_t operator[](size_t index) const { // lint !e1022 !e1042 | |||
| if (buffer_ != nullptr && index < buffer_->size()) { // lint !e574 | |||
| uint8_t operator[](size_t index) const { | |||
| if (buffer_ != nullptr && index < buffer_->size()) { | |||
| return (uint8_t)(*buffer_)[index]; | |||
| } | |||
| return 0xff; | |||
| @@ -14,20 +14,15 @@ | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef AICORE_PARAM_CALCULATOR | |||
| #define AICORE_PARAM_CALCULATOR | |||
| #ifndef INC_GRAPH_COMMON_ERROR_CODES_H_ | |||
| #define INC_GRAPH_COMMON_ERROR_CODES_H_ | |||
| #include "graph/node.h" | |||
| #include "graph_optimizer/graph_optimize_register_error_codes.h" | |||
| #include "external/graph/ge_error_codes.h" | |||
| namespace fe { | |||
| class AICoreParamCalculator { | |||
| public: | |||
| AICoreParamCalculator(); | |||
| namespace ge { | |||
| const graphStatus NO_DEPENDENCE_FUNC = 50331647; | |||
| const graphStatus NO_OVERLAP_DIM = 50331646; | |||
| const graphStatus NOT_SUPPORT_SLICE = 50331645; | |||
| } // namespace ge | |||
| ~AICoreParamCalculator(); | |||
| Status CalcOpRunningParam(ge::Node &node); | |||
| }; | |||
| } // namespace fe | |||
| #endif // AICORE_PARAM_CALCULATOR | |||
| #endif // INC_GRAPH_COMMON_ERROR_CODES_H_ | |||
| @@ -0,0 +1,32 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_GRAPH_COMPILER_OPTIONS_H_ | |||
| #define INC_GRAPH_COMPILER_OPTIONS_H_ | |||
| namespace ge { | |||
| #ifdef __GNUC__ | |||
| #define METADEF_ATTRIBUTE_UNUSED __attribute__((unused)) | |||
| #define METADEF_FUNCTION_IDENTIFIER __PRETTY_FUNCTION__ | |||
| #define METADEF_BUILTIN_PREFETCH(args_addr) __builtin_prefetch(args_addr) | |||
| #else | |||
| #define METADEF_ATTRIBUTE_UNUSED | |||
| #define METADEF_FUNCTION_IDENTIFIER __FUNCSIG__ | |||
| #define METADEF_BUILTIN_PREFETCH(args_addr) | |||
| #endif | |||
| } // namespace ge | |||
| #endif // INC_GRAPH_COMPILER_OPTIONS_H_ | |||
| @@ -84,7 +84,6 @@ class ComputeGraph : public std::enable_shared_from_this<ComputeGraph>, public A | |||
| NodePtr FindNode(const std::string &name) const; | |||
| NodePtr FindFirstNodeMatchType(const std::string &name) const; | |||
| /*lint -e504*/ | |||
| // AddNode with NodePtr | |||
| NodePtr AddNode(NodePtr node); | |||
| NodePtr AddNode(OpDescPtr op); | |||
| @@ -152,7 +151,6 @@ class ComputeGraph : public std::enable_shared_from_this<ComputeGraph>, public A | |||
| graphStatus InsertEventNodes(); | |||
| bool operator==(const ComputeGraph &r_compute_graph) const; | |||
| /*lint +e504*/ | |||
| const std::map<std::vector<std::string>, std::vector<std::string>> &GetShareParamLayer() const { | |||
| return params_share_map_; | |||
| } | |||
| @@ -249,12 +247,16 @@ class ComputeGraph : public std::enable_shared_from_this<ComputeGraph>, public A | |||
| private: | |||
| graphStatus DFSTopologicalSorting(std::vector<NodePtr> &node_vec, std::map<NodePtr, uint32_t> &map_in_edge_num, | |||
| std::vector<NodePtr> &stack); | |||
| std::vector<NodePtr> &stack, bool reverse); | |||
| graphStatus BFSTopologicalSorting(std::vector<NodePtr> &node_vec, std::map<NodePtr, uint32_t> &map_in_edge_num, | |||
| std::deque<NodePtr> &stack); | |||
| graphStatus CollectBreadthOutNode(const NodePtr &node, std::map<NodePtr, uint32_t> &map_in_edge_num, | |||
| std::map<string, NodePtr> &breadth_node_map); | |||
| graphStatus TopologicalSortingGraph(); | |||
| /// nodes like : (a) <--- (c) ---> (b) | |||
| /// node a and b have only one parent node c, and a is connected to c firstly | |||
| /// topo order of DFS is `c, b, a` with `dfs_reverse=false` as default | |||
| /// in same case, user could get `c, a, b` with `dfs_reverse=true` | |||
| graphStatus TopologicalSortingGraph(bool dfs_reverse = false); | |||
| graphStatus SortNodes(std::vector<NodePtr> &stack, std::map<NodePtr, uint32_t> &mapInEdgeNum); | |||
| Vistor<NodePtr> AllGraphNodes(std::vector<std::shared_ptr<ComputeGraph>> &subgraphs) const; | |||
| size_t GetInEdgeSize(const NodePtr &node); | |||
| @@ -14,7 +14,6 @@ | |||
| * limitations under the License. | |||
| */ | |||
| /*lint -e618*/ | |||
| #ifndef INC_GRAPH_DEBUG_GE_ATTR_DEFINE_H_ | |||
| #define INC_GRAPH_DEBUG_GE_ATTR_DEFINE_H_ | |||
| @@ -33,6 +32,8 @@ namespace ge { | |||
| #define GE_FUNC_DEV_VISIBILITY | |||
| #endif | |||
| // Public attribute | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FORCE_UNKNOWN_SHAPE; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IS_UNKNOWN_SHAPE; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED; | |||
| @@ -141,8 +142,12 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAM | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AIPP_OUTPUTS; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_INPUT_DIMS; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_DYNAMIC_AIPP_INPUT_DIMS; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_DATA_RELATED_AIPP_MODE; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_DATA_AIPP_DATA_NAME_MAP; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_GRAPH_HAS_BEEN_ADDED; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SESSION_GRAPH_ID; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PARENT_GRAPH_NAME; | |||
| @@ -182,6 +187,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MOD | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AUTOMIC_ADD_START; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AUTOMIC_ADD_MEM_SIZE; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STREAM_LABEL; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_RTS_LABEL_NODE; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STREAM_CYCLE_EVENT_FLAG; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DYNAMIC_OUTPUT_DIMS; | |||
| @@ -773,8 +779,6 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAM | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_TASK_GEN_VAR_ADDR; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STREAM_LABEL; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_CONTINUOUS_STREAM_LABEL; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_VAR_SIZE; | |||
| @@ -1017,8 +1021,6 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAM | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FUSION_GROUP_KEY; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FUSION_VIRTUAL_OP; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FUSION_GROUP_TYPE; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_INPUT_MEM_TYPE_LIST; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_MEM_TYPE_LIST; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_L1_FUSION_EXTEND_PTR; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_GET_TENSOR_ACTUAL_SIZE; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_OFFSET_FOR_L1_FUSION; | |||
| @@ -1039,6 +1041,14 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAM | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OP_COMPILE_STRATEGY; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_TBE_KERNEL_NAME; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_TBE_KERNEL_BUFFER; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DATA_SLICE; | |||
| // used for memory allocate | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_INPUT_MEM_TYPE_LIST; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_MEM_TYPE_LIST; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_WORKSPACE_TYPE_LIST; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_TENSOR_MEM_TYPE; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_P2P_MEMORY_SIZE; | |||
| // for unregistered op | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_UNREGST_OPPATH; | |||
| @@ -1048,6 +1058,10 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAM | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_OP_DEBUG_FLAG; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_OP_DEBUG_MODE; | |||
| // op dynamic input | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DYNAMIC_INPUT_START; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DYNAMIC_INPUT_END; | |||
| // functional ops attr | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IF_THEN_BRANCH; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IF_ELSE_BRANCH; | |||
| @@ -1101,6 +1115,9 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_DYN | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ATC_USER_DEFINE_DATATYPE; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ATC_USER_DEFINE_FORMAT; | |||
| // atc user def dtype&format | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ATC_USER_DEFINE_OUTPUT_NODES; | |||
| // for fusion op plugin | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FUSIONOP_ORIGINAL_TYPE; | |||
| @@ -1113,10 +1130,22 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_VAR | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_INPUT_MEMORY_TYPE; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_OUTPUT_MEMORY_TYPE; | |||
| // stage | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_STAGE_LEVEL; | |||
| // input_output_offset | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ZERO_COPY_BASIC_OFFSET; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ZERO_COPY_RELATIVE_OFFSET; | |||
| // The processing mode of INF and NAN during floating-point number calculation. | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_FP_CEILING_MODE; | |||
| // count of data from getnext_sink | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_GETNEXT_SINK_DATA_COUNT; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_GETNEXT_SINK_SHAPE_INFO; | |||
| // getnext_sink marked on NetOutput | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_GETNEXT_SINK_DYNMAIC; | |||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ALL_GEARS_INFO; | |||
| } // namespace ge | |||
| #endif // INC_GRAPH_DEBUG_GE_ATTR_DEFINE_H_ | |||
| /*lint +e618*/ | |||
| @@ -22,6 +22,8 @@ | |||
| #include <string> | |||
| #include <utility> | |||
| #include "graph/compiler_options.h" | |||
| namespace ge { | |||
| using std::shared_ptr; | |||
| using std::string; | |||
| @@ -30,7 +32,7 @@ class TypeID { | |||
| public: | |||
| template <class T> | |||
| static TypeID Of() { | |||
| return TypeID(__PRETTY_FUNCTION__); | |||
| return TypeID(METADEF_FUNCTION_IDENTIFIER); | |||
| } | |||
| ~TypeID() = default; | |||
| @@ -38,7 +40,7 @@ class TypeID { | |||
| bool operator==(const TypeID &__arg) const { return type_ == __arg.type_; } | |||
| private: | |||
| explicit TypeID(string type) : type_(std::move(type)) {} // lint !e30 !e32 | |||
| explicit TypeID(string type) : type_(std::move(type)) {} | |||
| string type_; | |||
| }; | |||
| @@ -50,7 +50,7 @@ class OpDef; | |||
| class GraphDef; | |||
| } // namespace proto | |||
| using ProtoAttrMap = ::google::protobuf::Map<::std::string, ::ge::proto::AttrDef>; // lint !e1073 | |||
| using ProtoAttrMap = ::google::protobuf::Map<::std::string, ::ge::proto::AttrDef>; | |||
| using ProtoMsgOwner = std::shared_ptr<::google::protobuf::Message>; | |||
| template <class ProtoType> | |||
| @@ -147,7 +147,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrHolder { | |||
| protected: | |||
| graphStatus AddRequiredAttr(const std::string &name); | |||
| const std::unordered_set<string> GetAllAttrNames() const; | |||
| const std::map<string, GeAttrValue> GetAllAttrs() const; // lint !e1073 | |||
| const std::map<string, GeAttrValue> GetAllAttrs() const; | |||
| virtual ProtoAttrMapHelper MutableAttrMap() = 0; | |||
| virtual ConstProtoAttrMapHelper GetAttrMap() const = 0; | |||
| @@ -310,7 +310,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeAttrValue { | |||
| VALUE_SET_GET_DEC(GeAttrValue::GRAPH) | |||
| VALUE_SET_GET_DEC(BYTES) | |||
| VALUE_SET_GET_DEC(NamedAttrs) | |||
| VALUE_SET_GET_DEC(ge::DataType) // lint !e665 | |||
| VALUE_SET_GET_DEC(ge::DataType) | |||
| VALUE_SET_GET_DEC(vector<GeAttrValue::STR>) | |||
| VALUE_SET_GET_DEC(vector<GeAttrValue::INT>) | |||
| VALUE_SET_GET_DEC(vector<GeAttrValue::FLOAT>) | |||
| @@ -320,8 +320,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeAttrValue { | |||
| VALUE_SET_GET_DEC(vector<GeAttrValue::GRAPH>) | |||
| VALUE_SET_GET_DEC(vector<GeAttrValue::BYTES>) | |||
| VALUE_SET_GET_DEC(vector<NamedAttrs>) | |||
| VALUE_SET_GET_DEC(vector<vector<int64_t>>) // lint !e665 | |||
| VALUE_SET_GET_DEC(vector<ge::DataType>) // lint !e665 | |||
| VALUE_SET_GET_DEC(vector<vector<int64_t>>) | |||
| VALUE_SET_GET_DEC(vector<ge::DataType>) | |||
| #undef VALUE_SET_GET_DEC | |||
| GeIrProtoHelper<proto::AttrDef> value_; | |||
| @@ -33,7 +33,7 @@ class GEContext { | |||
| void SetCtxDeviceId(uint32_t device_id); | |||
| private: | |||
| uint64_t session_id_ = 0; | |||
| thread_local static uint64_t session_id_; | |||
| uint32_t device_id_ = 0; | |||
| uint64_t trace_id_ = 0; | |||
| }; // class GEContext | |||
| @@ -33,6 +33,11 @@ class GEThreadLocalContext { | |||
| void SetSessionOption(map<std::string, string> options_map); | |||
| void SetGlobalOption(map<std::string, string> options_map); | |||
| map<string, string> GetAllGraphOptions() const; | |||
| map<string, string> GetAllSessionOptions() const; | |||
| map<string, string> GetAllGlobalOptions() const; | |||
| map<string, string> GetAllOptions() const; | |||
| private: | |||
| map<string, string> graph_options_; | |||
| map<string, string> session_options_; | |||
| @@ -95,6 +95,7 @@ class Node : public std::enable_shared_from_this<Node> { | |||
| ComputeGraphPtr GetOwnerComputeGraph() const; | |||
| graphStatus SetOwnerComputeGraph(const ComputeGraphPtr &graph); | |||
| graphStatus SetAnyOwnerComputeGraph(const ComputeGraphPtr &graph); | |||
| Vistor<InDataAnchorPtr> GetAllInDataAnchors() const; | |||
| Vistor<OutDataAnchorPtr> GetAllOutDataAnchors() const; | |||
| @@ -193,7 +194,7 @@ class Node : public std::enable_shared_from_this<Node> { | |||
| vector<OutDataAnchorPtr> out_data_anchors_; | |||
| InControlAnchorPtr in_control_anchor_; | |||
| OutControlAnchorPtr out_control_anchor_; | |||
| map<string, GeAttrValue> attrs_; // lint !e1073 | |||
| map<string, GeAttrValue> attrs_; | |||
| bool has_init_{false}; | |||
| bool host_node_{false}; | |||
| bool anchor_status_updated_{false}; | |||
| @@ -164,6 +164,10 @@ class OpDesc : public std::enable_shared_from_this<OpDesc>, public AttrHolder { | |||
| std::map<string, uint32_t> GetAllOutputName(); | |||
| std::map<string, uint32_t> &MutableAllInputName(); | |||
| std::map<string, uint32_t> &MutableAllOutputName(); | |||
| bool UpdateInputName(std::map<string, uint32_t> inputNameIdx); | |||
| bool UpdateOutputName(std::map<string, uint32_t> outputNameIdx); | |||
| @@ -235,7 +239,8 @@ class OpDesc : public std::enable_shared_from_this<OpDesc>, public AttrHolder { | |||
| vector<string> GetOpInferDepends() const; | |||
| string GetInputNameByIndex(uint32_t index) const; | |||
| string GetValidInputNameByIndex(uint32_t index) const; | |||
| int GetValidInputIndexByName(const string &name) const; | |||
| int GetInputIndexByName(const string &name) const; | |||
| string GetOutputNameByIndex(uint32_t index) const; | |||
| @@ -277,6 +282,8 @@ class OpDesc : public std::enable_shared_from_this<OpDesc>, public AttrHolder { | |||
| graphStatus GetSubgraphNameByInstanceName(const std::string &instance_name, std::string &subgraph_name) const; | |||
| graphStatus InferDataSlice(); | |||
| protected: | |||
| ProtoAttrMapHelper MutableAttrMap() override; | |||
| ConstProtoAttrMapHelper GetAttrMap() const override; | |||
| @@ -316,6 +323,7 @@ class OpDesc : public std::enable_shared_from_this<OpDesc>, public AttrHolder { | |||
| std::function<graphStatus(Operator &)> infer_func_ = nullptr; | |||
| std::function<graphStatus(Operator &)> infer_format_func_ = nullptr; | |||
| std::function<graphStatus(Operator &)> verifier_func_ = nullptr; | |||
| std::function<graphStatus(Operator &)> infer_data_slice_func_ = nullptr; | |||
| string op_kernel_lib_name_; | |||
| string engine_name_; | |||
| friend class OpDescUtils; | |||
| @@ -22,6 +22,7 @@ | |||
| #include <string> | |||
| #include <vector> | |||
| #include "graph/operator_factory.h" | |||
| #include "register/infer_data_slice_registry.h" | |||
| namespace ge { | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorFactoryImpl { | |||
| @@ -38,18 +39,27 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorFactoryImpl { | |||
| static VerifyFunc GetVerifyFunc(const std::string &operator_type); | |||
| static InferDataSliceFunc GetInferDataSliceFunc(const std::string &operator_type); | |||
| static graphStatus RegisterOperatorCreator(const std::string &operator_type, OpCreator const &op_creator); | |||
| static graphStatus RegisterOperatorCreator(const std::string &operator_type, OpCreatorV2 const &op_creator); | |||
| static graphStatus RegisterInferShapeFunc(const std::string &operator_type, InferShapeFunc const infer_shape_func); | |||
| static graphStatus RegisterInferFormatFunc(const std::string &operator_type, InferFormatFunc const infer_format_func); | |||
| static graphStatus RegisterVerifyFunc(const std::string &operator_type, VerifyFunc const verify_func); | |||
| static graphStatus RegisterInferDataSliceFunc(const std::string &operator_type, | |||
| InferDataSliceFunc const infer_data_slice_func); | |||
| static shared_ptr<std::map<string, OpCreator>> operator_creators_; | |||
| static shared_ptr<std::map<string, OpCreatorV2>> operator_creators_v2_; | |||
| static shared_ptr<std::map<string, InferShapeFunc>> operator_infershape_funcs_; | |||
| static shared_ptr<std::map<string, InferFormatFunc>> operator_inferformat_funcs_; | |||
| static shared_ptr<std::map<string, VerifyFunc>> operator_verify_funcs_; | |||
| static shared_ptr<std::map<string, InferDataSliceFunc>> operator_infer_data_slice_funcs_; | |||
| }; | |||
| } // namespace ge | |||
| @@ -17,8 +17,6 @@ | |||
| #ifndef INC_GRAPH_OPSPROTO_MANAGER_H_ | |||
| #define INC_GRAPH_OPSPROTO_MANAGER_H_ | |||
| #include <dirent.h> | |||
| #include <dlfcn.h> | |||
| #include <string.h> | |||
| #include <map> | |||
| #include <string> | |||
| @@ -55,7 +55,7 @@ struct RefCell { | |||
| struct RefCellHash { | |||
| size_t operator()(const RefCell &c) const { | |||
| unsigned long number = reinterpret_cast<unsigned long>(reinterpret_cast<uintptr_t>(c.node.get())); | |||
| unsigned long number = static_cast<unsigned long>(reinterpret_cast<uintptr_t>(c.node.get())); | |||
| string tmp = c.node_name + std::to_string(c.in_out) + std::to_string(c.in_out_idx) + std::to_string(number); | |||
| return std::hash<string>()(tmp); | |||
| } | |||
| @@ -23,6 +23,7 @@ | |||
| #include <vector> | |||
| #include "external/graph/ge_error_codes.h" | |||
| #include "external/graph/tensor.h" | |||
| #include "ge_attr_value.h" | |||
| namespace ge { | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY RuntimeInferenceContext { | |||
| @@ -32,10 +33,12 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY RuntimeInferenceContext { | |||
| static void DestroyContext(const std::string &context_id); | |||
| graphStatus SetTensor(int64_t node_id, int output_id, Tensor &&tensor); | |||
| graphStatus GetTensor(int64_t node_id, int output_id, GeTensorPtr &tensor); | |||
| graphStatus GetTensor(int64_t node_id, int output_id, Tensor &tensor); | |||
| private: | |||
| std::map<int64_t, std::vector<Tensor>> tensors_; | |||
| std::map<int64_t, std::vector<GeTensorPtr>> ge_tensors_; | |||
| std::mutex mu_; | |||
| static std::map<std::string, std::unique_ptr<RuntimeInferenceContext>> contexts_; | |||
| @@ -31,6 +31,8 @@ class ShapeRefiner { | |||
| static graphStatus InferShapeAndType(const NodePtr &node, bool before_subgraph); | |||
| static graphStatus InferShapeAndType(const NodePtr &node); | |||
| static graphStatus InferShapeAndType(const ConstNodePtr &node, Operator &op); | |||
| static graphStatus InferShapeAndTypeForRunning(const ConstNodePtr &node, Operator &op, bool before_subgraph); | |||
| static graphStatus InferShapeAndTypeForRunning(const NodePtr &node, bool before_subgraph); | |||
| static void ClearContextMap(); | |||
| private: | |||
| @@ -71,7 +71,7 @@ const std::set<std::string> build_step_options = {BUILD_STEP_BEFORE_UB_MATCH, BU | |||
| using SubgraphCreateOutNode = std::unordered_map<ComputeGraphPtr, NodePtr>; | |||
| using NodetoNodeMap = std::unordered_map<NodePtr, NodePtr>; | |||
| using NodeSet = std::set<NodePtr>; | |||
| using NodeVec = std::vector<NodePtr>; | |||
| using NodeNametoNodeNameMap = std::unordered_map<std::string, std::string>; | |||
| using NodetoNodeNameMap = std::unordered_map<NodePtr, std::string>; | |||
| class TuningUtils { | |||
| @@ -119,8 +119,8 @@ class TuningUtils { | |||
| static NodeNametoNodeNameMap data_2_netoutput_; | |||
| static NodetoNodeNameMap data_node_2_netoutput_; | |||
| static NodetoNodeMap data_node_2_netoutput_node_; | |||
| static NodeSet netoutput_nodes_; | |||
| static NodeSet merged_graph_nodes_; | |||
| static NodeVec netoutput_nodes_; | |||
| static NodeVec merged_graph_nodes_; | |||
| static std::mutex mutex_; | |||
| // for debug | |||
| static std::string PrintCheckLog(); | |||
| @@ -19,18 +19,18 @@ | |||
| #include <fstream> | |||
| #include <iostream> | |||
| #include <list> | |||
| #include <map> | |||
| #include <string> | |||
| #include <vector> | |||
| #include <list> | |||
| #include <unordered_map> | |||
| #include <vector> | |||
| #include "graph/anchor.h" | |||
| #include "graph/node.h" | |||
| #include "graph/compute_graph.h" | |||
| #include "graph/utils/anchor_utils.h" | |||
| #include "graph/graph.h" | |||
| #include "graph/model.h" | |||
| #include "graph/node.h" | |||
| #include "graph/utils/anchor_utils.h" | |||
| #define GE_DUMP(compute_graph, name) \ | |||
| do { \ | |||
| @@ -141,6 +141,8 @@ class GraphUtils { | |||
| static Graph CreateGraphFromComputeGraph(const ComputeGraphPtr compute_graph); | |||
| static GraphPtr CreateGraphPtrFromComputeGraph(const ComputeGraphPtr compute_graph); | |||
| static graphStatus RecoverGraphOperators(const Graph &graph); | |||
| static ComputeGraphPtr CreateGraphFromOperator(const string &name, const std::vector<Operator> &inputs); | |||
| @@ -206,6 +208,8 @@ class GraphUtils { | |||
| static void DumpGEGraph(const ge::ComputeGraphPtr &graph, const std::string &suffix, bool is_always_dump = false, | |||
| const std::string &user_graph_name = ""); | |||
| static void DumpGEGrph(const ge::ComputeGraphPtr &graph, const std::string &path, const std::string &suffix); | |||
| static bool LoadGEGraph(const char *file, ge::ComputeGraph &compute_graph); | |||
| static bool LoadGEGraph(const char *file, ge::ComputeGraphPtr &compute_graph); | |||
| @@ -214,6 +218,8 @@ class GraphUtils { | |||
| static void DumpGEGraphToOnnx(const ge::ComputeGraph &compute_graph, const std::string &suffix); | |||
| static void DumpGrphToOnnx(const ge::ComputeGraph &compute_graph, const std::string &path, const std::string &suffix); | |||
| static bool LoadGEGraphFromOnnx(const char *file, ge::ComputeGraph &compute_graph); | |||
| static bool ReadProtoFromTextFile(const char *file, google::protobuf::Message *message); | |||
| @@ -559,7 +565,8 @@ class ComputeGraphBuilder { | |||
| class CompleteGraphBuilder : public ComputeGraphBuilder { | |||
| public: | |||
| explicit CompleteGraphBuilder(std::string name) : name_(std::move(name)), parent_node_(nullptr) {} | |||
| explicit CompleteGraphBuilder(std::string name, bool retval_flag = true) | |||
| : name_(std::move(name)), parent_node_(nullptr), retval_flag_(retval_flag) {} | |||
| CompleteGraphBuilder(const CompleteGraphBuilder &) = delete; | |||
| CompleteGraphBuilder &operator=(const CompleteGraphBuilder &) = delete; | |||
| CompleteGraphBuilder(const CompleteGraphBuilder &&) = delete; | |||
| @@ -687,8 +694,37 @@ class CompleteGraphBuilder : public ComputeGraphBuilder { | |||
| /// | |||
| void BuildGraphTargets(graphStatus &error_code, std::string &error_msg); | |||
| /// | |||
| /// @brief Add NetOutput node | |||
| /// @param [out] error_code | |||
| /// @param [out] error_msg | |||
| /// @return void | |||
| /// | |||
| void AddNetOutputNode(graphStatus &error_code, std::string &error_msg); | |||
| /// | |||
| /// @brief Build NetOutput nodes with data & ctrl edges | |||
| /// @param [in] net_output_desc | |||
| /// @param [in] peer_out_anchors | |||
| /// @param [out] error_code | |||
| /// @param [out] error_msg | |||
| /// @return void | |||
| /// | |||
| void BuildNetOutputNodeWithLink(const OpDescPtr &net_output_desc, | |||
| const std::vector<OutDataAnchorPtr> &peer_out_anchors, graphStatus &error_code, | |||
| std::string &error_msg); | |||
| /// | |||
| /// @brief process after build | |||
| /// @param [out] error_code | |||
| /// @param [out] error_msg | |||
| /// @return void | |||
| /// | |||
| void PostProcess(graphStatus &error_code, std::string &error_msg); | |||
| std::string name_; | |||
| NodePtr parent_node_; | |||
| bool retval_flag_; | |||
| std::map<uint32_t, std::pair<std::vector<std::string>, std::vector<uint32_t>>> graph_inputs_; | |||
| std::vector<std::pair<std::string, uint32_t>> graph_outputs_; | |||
| std::vector<std::string> graph_targets_; | |||
| @@ -0,0 +1,32 @@ | |||
| /** | |||
| * 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. | |||
| */ | |||
| #ifndef INC_GRAPH_UTILS_NODE_ADAPTER_H_ | |||
| #define INC_GRAPH_UTILS_NODE_ADAPTER_H_ | |||
| #include "graph/gnode.h" | |||
| #include "graph/node.h" | |||
| namespace ge { | |||
| using NodePtr = std::shared_ptr<Node>; | |||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY NodeAdapter { | |||
| public: | |||
| static GNode Node2GNode(const NodePtr &node); | |||
| static NodePtr GNode2Node(const GNode &node); | |||
| static GNodePtr Node2GNodePtr(const NodePtr &node); | |||
| }; | |||
| } // namespace ge | |||
| #endif // INC_GRAPH_UTILS_NODE_ADAPTER_H_ | |||
| @@ -83,6 +83,7 @@ class NodeUtils { | |||
| static std::string GetNodeType(const Node &node); | |||
| static std::string GetNodeType(const NodePtr &node); | |||
| static std::vector<ComputeGraphPtr> GetAllSubgraphs(const Node &node); | |||
| static ComputeGraphPtr GetSubgraph(const Node &node, uint32_t index); | |||
| static graphStatus SetSubgraph(Node &node, uint32_t index, const ComputeGraphPtr &subgraph); | |||
| @@ -162,6 +163,13 @@ class NodeUtils { | |||
| static graphStatus GetInputConstData(const Node &node, const string &dst_name, GeTensorPtr &ge_tensor); | |||
| /// | |||
| /// @brief Get node type in cross subgragh. | |||
| /// @param [in] node | |||
| /// @return type | |||
| /// | |||
| static std::string GetInConstNodeTypeCrossSubgraph(const ge::NodePtr &node); | |||
| private: | |||
| static std::map<NodePtr, std::vector<uint32_t>> map_send_info_; | |||
| static std::map<NodePtr, std::vector<uint32_t>> map_recv_info_; | |||
| @@ -53,6 +53,7 @@ class OpDescUtils { | |||
| static vector<GeTensorPtr> MutableWeights(const ge::NodePtr node); | |||
| static graphStatus SetWeights(ge::Node& node, const vector<ge::GeTensorPtr>& weights); | |||
| static graphStatus SetWeights(ge::NodePtr node, const vector<ge::GeTensorPtr>& weights); | |||
| static graphStatus SetWeights(ge::Node& node, const map<int, ge::GeTensorPtr>& weights_map); | |||
| static graphStatus ClearWeights(ge::NodePtr node); | |||
| static bool ClearInputDesc(ge::OpDescPtr op_desc, uint32_t index); | |||