diff --git a/inc/external/ge/ge_api.h b/inc/external/ge/ge_api.h new file mode 100644 index 0000000000000000000000000000000000000000..b4b9bb2afc26fc61b3ab00d1808ad54cc848bd74 --- /dev/null +++ b/inc/external/ge/ge_api.h @@ -0,0 +1,128 @@ +/** + * 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_API_H_ +#define INC_EXTERNAL_GE_GE_API_H_ + +#include +#include +#include + +#include "ge/ge_api_error_codes.h" +#include "ge/ge_api_types.h" +#include "graph/graph.h" +#include "graph/tensor.h" + +namespace ge { +typedef uint32_t (*pCallBackFunc)(uint32_t graph_id, const std::map ¶ms_list); + +// Initialize GE +Status GEInitialize(const std::map &options); + +// Finalize GE, release all resources +Status GEFinalize(); + +class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { + public: + explicit Session(const std::map &options); + + ~Session(); + + /// + /// @ingroup client + /// @brief add a graph with a specific graphId + /// @param [in] graphId graph id + /// @return Status result of function + /// + Status AddGraph(uint32_t graphId, const Graph &graph); + + /// + /// @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 &options); + + /// + /// @ingroup ge_graph + /// @brief remove a graph of the session with specific session id + /// @param [in] graphId graph id + /// @return Status result of function + /// + Status RemoveGraph(uint32_t graphId); + + /// + /// @ingroup ge_graph + /// @brief run a graph of the session with specific session id + /// @param [in] graphId graph id + /// @param [in] inputs input data + /// @param [out] outputs output data + /// @return Status result of function + /// + Status RunGraph(uint32_t graphId, const std::vector &inputs, std::vector &outputs); + + /// + /// @ingroup ge_graph + /// @brief build graph in the session with specific session id + /// @param [in] graphId: graph id + /// @param [in] inputs: input data + /// @return Status result of function + /// + Status BuildGraph(uint32_t graphId, const std::vector &inputs); + + /// + /// @ingroup ge_graph + /// @brief run graph in the session with specific session id asynchronously + /// @param [in] graphId: graph id + /// @param [in] inputs: input data + /// @param [out] callback: callback while runing graph has been finished. + /// The callback function will not be checked. + /// Please ensure that the implementation of the function is trusted. + /// @return Status result of function + /// + Status RunGraphAsync(uint32_t graphId, const std::vector &inputs, RunAsyncCallback callback); + + /// + /// @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 &var_names, std::vector &var_values); + + /// + /// @ingroup ge_graph + /// @brief register callback func with specific summary or checkpoint by users + /// @param [in] key: func key + /// @param [in] callback: callback specific summary or checkpoint. + /// The callback function will not be checked. + /// Please ensure that the implementation of the function is trusted. + /// @return Status result of function + /// + Status RegisterCallBackFunc(const std::string &key, const pCallBackFunc &callback); + + bool IsGraphNeedRebuild(uint32_t graphId); + + private: + uint64_t sessionId_; +}; +} // namespace ge + +#endif // INC_EXTERNAL_GE_GE_API_H_ diff --git a/inc/external/ge/ge_api_error_codes.h b/inc/external/ge/ge_api_error_codes.h new file mode 100644 index 0000000000000000000000000000000000000000..e7f52724c679a14814083b8931c39f04af76fcb3 --- /dev/null +++ b/inc/external/ge/ge_api_error_codes.h @@ -0,0 +1,76 @@ +/** + * Copyright 2019-2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INC_EXTERNAL_GE_GE_API_ERROR_CODES_H_ +#define INC_EXTERNAL_GE_GE_API_ERROR_CODES_H_ + +#include +#include + +namespace ge { +class StatusFactory { + public: + static StatusFactory *Instance() { + static StatusFactory instance; + return &instance; + } + + void RegisterErrorNo(uint32_t err, const std::string &desc) { + // Avoid repeated addition + if (err_desc_.find(err) != err_desc_.end()) { + return; + } + err_desc_[err] = desc; + } + + std::string GetErrDesc(uint32_t err) { + auto iter_find = err_desc_.find(err); + if (iter_find == err_desc_.end()) { + return ""; + } + return iter_find->second; + } + + protected: + StatusFactory() {} + ~StatusFactory() {} + + private: + std::map err_desc_; +}; + +class ErrorNoRegisterar { + public: + ErrorNoRegisterar(uint32_t err, const std::string &desc) { StatusFactory::Instance()->RegisterErrorNo(err, desc); } + ~ErrorNoRegisterar() {} +}; + +// Code compose(4 byte), runtime: 2 bit, type: 2 bit, level: 3 bit, sysid: 8 bit, modid: 5 bit, value: 12 bit +#define GE_ERRORNO(runtime, type, level, sysid, modid, name, value, desc) \ + constexpr ge::Status name = \ + ((0xFF & (static_cast(runtime))) << 30) | ((0xFF & (static_cast(type))) << 28) | \ + ((0xFF & (static_cast(level))) << 25) | ((0xFF & (static_cast(sysid))) << 17) | \ + ((0xFF & (static_cast(modid))) << 12) | (0x0FFF & (static_cast(value))); \ + 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"); +} // namespace ge + +#endif // INC_EXTERNAL_GE_GE_API_ERROR_CODES_H_ diff --git a/inc/external/ge/ge_api_types.h b/inc/external/ge/ge_api_types.h new file mode 100644 index 0000000000000000000000000000000000000000..1c6b7a3ef7dbabcd8a85999ec990671cc5852d8e --- /dev/null +++ b/inc/external/ge/ge_api_types.h @@ -0,0 +1,339 @@ +/** + * 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_API_TYPES_H_ +#define INC_EXTERNAL_GE_GE_API_TYPES_H_ + +#include +#include +#include +#include +#include +#include + +namespace ge { +// Option key: graph run mode +const char *const OPTION_GRAPH_RUN_MODE = "ge.graphRunMode"; + +// Option key: ome init +const char *const OPTION_EXEC_SESSION_ID = "ge.exec.sessionId"; +const char *const OPTION_EXEC_DEVICE_ID = "ge.exec.deviceId"; +const char *const OPTION_EXEC_JOB_ID = "ge.exec.jobId"; +const char *const OPTION_EXEC_IS_USEHCOM = "ge.exec.isUseHcom"; +const char *const OPTION_EXEC_IS_USEHVD = "ge.exec.isUseHvd"; +const char *const OPTION_EXEC_RANK_ID = "ge.exec.rankId"; +const char *const OPTION_EXEC_POD_NAME = "ge.exec.podName"; +const char *const OPTION_EXEC_DEPLOY_MODE = "ge.exec.deployMode"; +const char *const OPTION_EXEC_RANK_TABLE_FILE = "ge.exec.rankTableFile"; +const char *const GE_AICPU_FLAG = "ge.aicpuFlag"; +const char *const OPTION_EXEC_EXTERN_PLUGIN_PATH = "ge.soLoadPath"; +// Dump flag and para +const char *const OPTION_EXEC_ENABLE_DUMP = "ge.exec.enableDump"; +const char *const OPTION_EXEC_DUMP_PATH = "ge.exec.dumpPath"; +const char *const OPTION_EXEC_DUMP_STEP = "ge.exec.dumpStep"; +const char *const OPTION_EXEC_DUMP_MODE = "ge.exec.dumpMode"; +const char *const OPTION_EXEC_ENABLE_DUMP_DEBUG = "ge.exec.enableDumpDebug"; +const char *const OPTION_EXEC_DUMP_DEBUG_MODE = "ge.exec.dumpDebugMode"; +const char *const OPTION_EXEC_ENABLE_INCRE_BUILD = "ge.exec.enableIncreBuild"; +const char *const OPTION_EXEC_INCRE_BUILD_CACHE_PATH = "ge.exec.increBuildCachePath"; +const char *const OPTION_EXEC_ENABLE_EXCEPTION_DUMP = "ge.exec.enable_exception_dump"; +const char *const OPTION_EXEC_ENABLE_SCOPE_FUSION_PASSES = "ge.exec.enableScopeFusionPasses"; +const char *const OPTION_EXEC_PROFILING_FPPONIT_OPTIONS = "ge.exec.profilingFpPointOptions"; +const char *const OPTION_EXEC_PROFILING_BPPONIT_OPTIONS = "ge.exec.profilingBpPointOptions"; +// profiling flag +const char *const OPTION_EXEC_PROFILING_MODE = "ge.exec.profilingMode"; +const char *const OPTION_EXEC_PROFILING_OPTIONS = "ge.exec.profilingOptions"; +// Hccl flag, if ge.exec.hcclFlag =1, it means load plugin for opskernel, else:ge.exec.hcclFlag =0 +const char *const OPTION_EXEC_HCCL_FLAG = "ge.exec.hcclFlag"; +const char *const OPTION_EXEC_ATOMIC_FLAG = "ge.exec.enable_atomic"; +const char *const OPTION_EXEC_DISABLE_REUSED_MEMORY = "ge.exec.disableReuseMemory"; +const char *const OPTION_EXEC_ENABLE_TAILING_OPTIMIZATION = "ge.exec.isTailingOptimization"; + +// Option key: memory init +const char *const GRAPH_MEMORY_MAX_SIZE = "ge.graphMemoryMaxSize"; +const char *const VARIABLE_MEMORY_MAX_SIZE = "ge.variableMemoryMaxSize"; + +// 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"; + +// Configure add head stream to model. +// its value should be "0" or "1", default value is "0" +const std::string HEAD_STREAM = "ge.headStream"; + +// Configure perf level by Session constructor options param, +// its value please see enum PerfLevel, default value is "4" +const std::string PERF_LEVEL = "ge.perfLevel"; + +// Configure encrypt mode by Session constructor options param, +// its value should be int32_t type, default value is "-1" +const std::string ENCRYPT_MODE = "ge.encryptMode"; + +// configure ek file by Session constructor options param, +// its value should be file path, default value is "" +const std::string EK_FILE = "ge.ekFile"; + +// Configure cert file by Session constructor options param, +// its value should be file path, default value is "" +const std::string CERT_FILE = "ge.certFile"; + +// Configure hw key file by Session constructor options param, +// its value should be file path, default value is "" +const std::string HW_KEY_FILE = "ge.hwKeyFile"; + +// Configure private file by Session constructor options param, +// its value should be file path, default value is "" +const std::string PRIVATE_KEY_FILE = "ge.privateKeyFile"; + +// Configure framework type by Session constructor options param, +// its value please see enum FrameworkType, default value is "3" +const std::string FRAMEWORK_TYPE = "ge.frameworkType"; + +// Configure calibration info file by Session constructor options param, +// its value should be file path, default value is "" +const std::string CALIBRATION_CONF_FILE = "ge.calibrationConfFile"; + +// Configure insert op info file by Session constructor options param, +// its value should be file path, default value is "" +const std::string INSERT_OP_FILE = "ge.insertOpFile"; + +// Configure output node name by Session constructor options param, +// its value should be std::string type, default value is "" +const std::string OUTPUT_NODE_NAME = "ge.outputNodeName"; + +// Configure weight compress flag by Session constructor options param, +// its value should be "0" or "1", default value is "0" +const std::string COMPRESS_FLAG = "ge.compressFlag"; + +const std::string PRECISION_MODE = "ge.exec.precision_mode"; + +// Configure single op flag for FE +// its value should be "0" or "1", default value is "0" +const std::string SINGLE_OP_FLAG = "ge.exec.single_op"; + +// Configure train flag by Session constructor options param, +// its value should be "0" or "1", default value is "0" +const std::string TRAIN_FLAG = "ge.trainFlag"; + +// Configure run flag by Session constructor options param, +// its value should be "0" or "1", default value is "0" +const std::string RUN_FLAG = "ge.runFlag"; + +// Configure run flag by Session constructor options param, +// its value should be "0" or "1", default value is "0" +// this option is to enable local framework op feature +const std::string LOCAL_FMKOP_FLAG = "ge.enabledLocalFmkop"; + +// Configure run flag by Session constructor options param, +// its value should be a path +// this option is to obtain the TBE op plugin path +const std::string TBE_PLUGIN_PATH_FLAG = "ge.TBE_plugin_path"; + +// Configure run flag by Session constructor options param, +// its value should be a path +// this option is to obtain the DDK Version info +const std::string DDK_VERSION_FLAG = "ge.DDK_version"; + +// Configure run flag by Session constructor options param, +// its value should be a path +// this option is to obtain fe flag +const std::string GE_FE_FLAG = "ge.feFlag"; + +// Configure stream max parallel num only by Session constructor options param, +// its value should be stream:int, such as "DNN_V100:2,DNN_HCCL:3", +// default value is "1", such as "DNN_V100:1,DNN_HCCL:1" +// this option is to obtain stream max parallel num +const std::string STREAM_MAX_PARALLEL_NUM = "ge.streamMaxParallelNum"; + +// congigure outputDatatype to setting net output type +const std::string OUTPUT_DATATYPE = "ge.outputDatatype"; + +// congigure opSelectImplmode to setting op select implmode +const std::string OP_SELECT_IMPL_MODE = "ge.opSelectImplmode"; + +// congigure optypelist_for_implmode to setting which op use implmode +const std::string OPTYPELIST_FOR_IMPLMODE = "ge.optypelistForImplmode"; + +// configure whether to enable hcom parallel by session constructor options param, +// its value should be "0" or "1", default value is "0" +const std::string HCOM_PARALLEL = "ge.hcomParallel"; + +// configure whether to use dynamic batch size +const char *const kDynamicBatchSize = "ge.dynamicBatchSize"; + +// configure whether to use dynamic image size +const char *const kDynamicImageSize = "ge.dynamicImageSize"; + +// Configure whether to use dynamic dims +const char *const kDynamicDims = "ge.dynamicDims"; + +// Configure auto tune mode, this option only take effect while AUTO_TUNE_FLAG is Y, +// example: GA|RL, support configure multiple, split by | +const std::string AUTO_TUNE_MODE = "ge.autoTuneMode"; + +// Configure soc version , example: "Ascend310" +const std::string SOC_VERSION = "ge.socVersion"; + +// Configure core type "VectorEngine", default value is "AIcoreEngine" +const std::string CORE_TYPE = "ge.engineType"; + +// Configure AICORE NUM +const std::string AICORE_NUM = "ge.aicoreNum"; + +// Configure L1FUSION +const std::string L1_FUSION = "ge.l1Fusion"; + +// Configure l1,l2,and others optimize option +const std::string BUFFER_OPTIMIZE = "ge.bufferOptimize"; + +// Configure Small Channel flag +const std::string ENABLE_SMALL_CHANNEL = "ge.enableSmallChannel"; + +// Configure Compress Weight flag +const std::string ENABLE_COMPRESS_WEIGHT = "ge.enableCompressWeight"; + +// Configure fusion switch file path +const std::string FUSION_SWITCH_FILE = "ge.fusionSwitchFile"; + +// Save original model +const std::string SAVE_ORIGINAL_MODEL = "ge.saveOriginalModel"; + +// Save original model file name +const std::string ORIGINAL_MODEL_FILE = "ge.originalModelFile"; + +const char *const OPTION_GE_MAX_DUMP_FILE_NUM = "ge.maxDumpFileNum"; +const char *const OPTION_GE_MAX_DUMP_FILE_SIZE = "ge.maxDumpFileSize"; +const char *const OPTION_GE_MAX_DUMP_OP_NUM = "ge.maxDumpOpNum"; + +// Configure for print op pass +// Its value should be "0" or "1", default value is "1" +const char *const ENABLE_PRINT_OP_PASS = "ge.enablePrintOpPass"; + +// 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"; + +// Configure input fp16 nodes +const std::string INPUT_FP16_NODES = "ge.INPUT_NODES_SET_FP16"; + +// Configure debug level, its value should be 0(default), 1 or 2. +// 0: close debug; 1: open TBE compiler; 2: open ccec compiler +const std::string OP_DEBUG_LEVEL = "ge.opDebugLevel"; + +// Graph run mode +enum GraphRunMode { PREDICTION = 0, TRAIN }; + +// Input/Output tensor info +struct InputTensorInfo { + uint32_t data_type; // data type + std::vector dims; // shape description + void *data; // tensor data + int64_t length; // tensor length +}; + +struct OutputTensorInfo { + uint32_t data_type; // data type + std::vector dims; // shape description + std::unique_ptr data; // tensor data + int64_t length; // tensor length + OutputTensorInfo() : data_type(0), dims({}), data(nullptr), length(0) {} + OutputTensorInfo(OutputTensorInfo &&out) : + data_type(out.data_type), + dims(out.dims), + data(std::move(out.data)), + length(out.length) {} + + OutputTensorInfo &operator=(OutputTensorInfo &&out) { + if (this != &out) { + data_type = out.data_type; + dims = out.dims; + data = std::move(out.data); + length = out.length; + } + return *this; + } + OutputTensorInfo(const OutputTensorInfo &) = delete; + OutputTensorInfo &operator=(const OutputTensorInfo &) = delete; +}; + +using Status = uint32_t; +using RunAsyncCallback = std::function &)>; +// for ir build +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 DYNAMIC_BATCH_SIZE = kDynamicBatchSize; + static const char *const DYNAMIC_IMAGE_SIZE = kDynamicImageSize; + static const char *const DYNAMIC_DIMS = kDynamicDims; + static const char *const INSERT_OP_FILE = ge::INSERT_OP_FILE.c_str(); + static const char *const PRECISION_MODE = ge::PRECISION_MODE.c_str(); + static const char *const EXEC_DISABLE_REUSED_MEMORY = ge::OPTION_EXEC_DISABLE_REUSED_MEMORY; + static const char *const AUTO_TUNE_MODE = ge::AUTO_TUNE_MODE.c_str(); + static const char *const CORE_TYPE = ge::CORE_TYPE.c_str(); + static const char *const SOC_VERSION = ge::SOC_VERSION.c_str(); + static const char *const ENABLE_SINGLE_STREAM = ge::ENABLE_SINGLE_STREAM; + static const char *const AICORE_NUM = ge::AICORE_NUM.c_str(); + static const char *const FUSION_SWITCH_FILE = ge::FUSION_SWITCH_FILE.c_str(); + static const char *const ENABLE_SMALL_CHANNEL = ge::ENABLE_SMALL_CHANNEL.c_str(); + static const char *const OP_SELECT_IMPL_MODE = ge::OP_SELECT_IMPL_MODE.c_str(); + static const char *const OUTPUT_TYPE = ge::OUTPUT_DATATYPE.c_str(); + static const char *const BUFFER_OPTIMIZE = ge::BUFFER_OPTIMIZE.c_str(); + static const char *const ENABLE_COMPRESS_WEIGHT = ge::ENABLE_COMPRESS_WEIGHT.c_str(); + static const char *const COMPRESS_WEIGHT_CONF = "compress_weight_conf"; + 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(); + + // for interface: aclgrphBuildModel + const std::set 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 + }; + // for interface: aclgrphBuildInitialize + const std::set global_options = { + CORE_TYPE, + SOC_VERSION, + BUFFER_OPTIMIZE, + ENABLE_COMPRESS_WEIGHT, + COMPRESS_WEIGHT_CONF, + PRECISION_MODE, + EXEC_DISABLE_REUSED_MEMORY, + AUTO_TUNE_MODE, + ENABLE_SINGLE_STREAM, + AICORE_NUM, + FUSION_SWITCH_FILE, + ENABLE_SMALL_CHANNEL, + OP_SELECT_IMPL_MODE, + OPTYPELIST_FOR_IMPLMODE + }; +} +} // namespace ge + +#endif // INC_EXTERNAL_GE_GE_API_TYPES_H_ diff --git a/inc/external/ge/ge_ir_build.h b/inc/external/ge/ge_ir_build.h new file mode 100644 index 0000000000000000000000000000000000000000..cbe7f6d34781725df4bf48e90cbb08dee7c4af83 --- /dev/null +++ b/inc/external/ge/ge_ir_build.h @@ -0,0 +1,114 @@ +/** + * 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_IR_BUILD_H_ +#define INC_EXTERNAL_GE_IR_BUILD_H_ + +#include +#include +#include +#include "graph/graph.h" +#include "graph/ge_error_codes.h" + +namespace { +#define IR_MAJOR_VERSION (int(1)) +#define IR_MINOR_VERSION (int(0)) +#define IR_PATCH_VERSION (int(0)) +} + +namespace ge{ + +struct ModelBufferData +{ + std::shared_ptr data = nullptr; + uint64_t length; +}; + +/** + * @ingroup AscendCL + * @brief build model.Notice the model is stored in buffer + * + * @param global_options[IN] global init params for build + * @retval GRAPH_SUCCESS The function is successfully executed. + * @retval OtherValues Failure + */ +graphStatus aclgrphBuildInitialize(std::map global_options); + +/** + * @ingroup AscendCL + * @brief build model.Notice the model is stored in buffer + * + */ +void aclgrphBuildFinalize(); + +/** + * @ingroup AscendCL + * @brief build model.Notice the model is stored in buffer + * + * @param graph[IN] the graph ready to build + * @param options[IN] options used for build + * @param model[OUT] builded model + * @retval GRAPH_SUCCESS The function is successfully executed. + * @retval OtherValues Failure + */ +graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map &build_options, ModelBufferData& model); + +/** + * @ingroup AscendCL + * @brief save model buffer to file + * + * @param output_file[IN] the file path to be saved + * @param model[IN] model buffer data + * @retval GRAPH_SUCCESS The function is successfully executed. + * @retval OtherValues Failure + */ +graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData& model); + +/** + * @ingroup AscendCL + * @brief query IR interface version + * + * @param major_version[OUT] IR interface major version + * @param minor_version[OUT] IR interface minor version + * @param patch_version[OUT] IR interface patch version + * @retval GRAPH_SUCCESS The function is successfully executed. + * @retval OtherValues Failure + */ +graphStatus aclgrphGetIRVersion(int *major_version, int *minor_version, int *patch_version); + +/** + * @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); +}; // INC_EXTERNAL_GE_IR_BUILD_H_ +#endif diff --git a/inc/external/ge/ge_prof.h b/inc/external/ge/ge_prof.h new file mode 100644 index 0000000000000000000000000000000000000000..658cea76b5b5f64da6f24b114499f12e72b6fde0 --- /dev/null +++ b/inc/external/ge/ge_prof.h @@ -0,0 +1,102 @@ +/** + * 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_PROF_H_ +#define INC_EXTERNAL_GE_GE_PROF_H_ + +#include +#include +#include + +#include "ge/ge_api_error_codes.h" + +namespace ge { +enum ProfDataTypeConfig { + kProfTaskTime = 0x0002, + kProfAiCoreMetrics = 0x0004, + kProfAicpuTrace = 0x0008, + kProfTrainingTrace = 0x0800, + kProfHcclTrace = 0x1000 +}; + +enum ProfilingAicoreMetrics { + kAicoreArithmaticThroughput = 0, + kAicorePipeline = 1, + kAicoreSynchronization = 2, + kAicoreMemory = 3, + kAicoreInternalMemory = 4, + 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 + +#endif // INC_EXTERNAL_GE_GE_PROF_H_ diff --git a/inc/external/hccl/hccl_types.h b/inc/external/hccl/hccl_types.h new file mode 100644 index 0000000000000000000000000000000000000000..d67af11e65c24034167ed488eae6af5e701faf68 --- /dev/null +++ b/inc/external/hccl/hccl_types.h @@ -0,0 +1,39 @@ +/** + * Copyright 2019-2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HCCL_TYPES_H_ +#define HCCL_TYPES_H_ + +#include + +#ifdef _cplusplus +extern "C" { +#endif + +typedef enum { +} HcclResult; + +typedef enum { +} HcclReduceOp; + +typedef enum { +} HcclDataType; + +#ifdef _cplusplus +} +#endif +#endif + diff --git a/inc/tdt/index_transform.h b/inc/tdt/index_transform.h new file mode 100644 index 0000000000000000000000000000000000000000..a5af2c83fab05028310c5ea65dd0ed99c7781c15 --- /dev/null +++ b/inc/tdt/index_transform.h @@ -0,0 +1,29 @@ +/** +* @file index_transform.h +* +* Copyright (C) Huawei Technologies Co., Ltd. 2018-2019. All Rights Reserved. +* +* This program is used to get logical device id by phy device id. +*/ + +#ifndef INC_TDT_INDEX_TRANSFORM_H +#define INC_TDT_INDEX_TRANSFORM_H + +#include "stdint.h" +/** +* @ingroup IndexTransform +* @brief get logical device id by phy device id. +* +* @par Function get logical device id by phy device id. +* +* @param phyId [IN] physical device id +* @param logicalId [OUT] logical device id +* @retval 0 Success +* @retval OtherValues Fail +* +* @par Dependency +* @li libruntime.so: Library to which the interface belongs. +*/ + +int32_t IndexTransform(const uint32_t phyId, uint32_t &logicId); +#endif diff --git a/inc/toolchain/tuning_tool/tune_api.h b/inc/toolchain/tuning_tool/tune_api.h new file mode 100644 index 0000000000000000000000000000000000000000..dc5a08f599a72ea188f73c572c89fbbee2b5973c --- /dev/null +++ b/inc/toolchain/tuning_tool/tune_api.h @@ -0,0 +1,67 @@ +/** + * @file tune_api.h + * + * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.\n + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n + * 描述:mstune调优接口头文件 + */ +/** @defgroup mstune mstune调优接口 */ +#ifndef TUNE_API_H +#define TUNE_API_H +#include +#include +#include +#include "graph/graph.h" +#include "ge/ge_api.h" + +/** + * @ingroup mstune + * + * mstune status + */ +enum MsTuneStatus { + MSTUNE_SUCCESS, /** tune success */ + MSTUNE_FAILED, /** tune failed */ +}; + +/** + * @ingroup mstune + * @par 描述: 命令行调优 + * + * @attention 无 + * @param option [IN] 调优参数 + * @param msg [OUT] 调优异常下返回信息 + * @retval #MSTUNE_SUCCESS 执行成功 + * @retval #MSTUNE_FAILED 执行失败 + * @par 依赖: + * @li tune_api.cpp:该接口所属的开发包。 + * @li tune_api.h:该接口声明所在的头文件。 + * @see 无 + * @since + */ +MsTuneStatus MsTuning(const std::map &option, std::string &msg); + +/** + * @ingroup mstune + * @par 描述: 梯度调优 + * + * @attention 无 + * @param tuningGraph [IN] 调优图 + * @param dependGraph [IN] 调优依赖图 + * @param session [IN] ge连接会话 + * @param option [IN] 调优参数 + * @retval #MSTUNE_SUCCESS 执行成功 + * @retval #MSTUNE_FAILED 执行失败 + * @par 依赖: + * @li tune_api.cpp:该接口所属的开发包。 + * @li tune_api.h:该接口声明所在的头文件。 + * @see 无 + * @since + */ +extern "C" MsTuneStatus MsGradientTuning(ge::Graph &tuningGraph, std::vector &dependGraph, + ge::Session *session, const std::map &option); + +#endif