diff --git a/third_party/acl/inc/ge/ge_api.h b/third_party/acl/inc/ge/ge_api.h new file mode 100644 index 0000000000000000000000000000000000000000..5657361c18a6451ed8385b5de58a7c53719ccd25 --- /dev/null +++ b/third_party/acl/inc/ge/ge_api.h @@ -0,0 +1,199 @@ +/** + * 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); + +namespace session { +typedef uint32_t (*pCallBackFunc)(uint32_t graph_id, const std::map ¶ms_list); +} + +// Initialize GE +ATTRIBUTED_DEPRECATED(GE_FUNC_VISIBILITY Status GEInitialize(const std::map &)) +GE_FUNC_VISIBILITY Status GEInitialize(const std::map &options); + +GE_FUNC_VISIBILITY Status GEInitialize(const std::map &options); + +// Finalize GE, release all resources +GE_FUNC_VISIBILITY Status GEFinalize(); + +GE_FUNC_VISIBILITY std::string GEGetErrorMsg(); + +GE_FUNC_VISIBILITY std::string GEGetWarningMsg(); + +class GE_FUNC_VISIBILITY Session { + public: + ATTRIBUTED_DEPRECATED(Session(const std::map &)) + explicit Session(const std::map &options); + + 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 + /// + ATTRIBUTED_DEPRECATED(Status AddGraph(uint32_t, const Graph &, const std::map &)) + Status AddGraph(uint32_t graphId, const Graph &graph, const std::map &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 &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 &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 run a graph of the session with specific session id and specific stream asynchronously + /// @param [in] graph_id graph id + /// @param [in] stream specific stream + /// @param [in] inputs input data + /// @param [out] outputs output data + /// @return Status result of function + /// + Status RunGraphWithStreamAsync(uint32_t graph_id, void *stream, 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); + + Status BuildGraph(uint32_t graphId, const std::vector &inputs); /*lint !e148*/ + + /// + /// @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 + /// + ATTRIBUTED_DEPRECATED(Status GetVariables(const std::vector &, std::vector &)) + Status GetVariables(const std::vector &var_names, std::vector &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 &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 + /// + 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: + uint64_t sessionId_; +}; +} // namespace ge + +#endif // INC_EXTERNAL_GE_GE_API_H_ diff --git a/third_party/acl/inc/ge/ge_api_error_codes.h b/third_party/acl/inc/ge/ge_api_error_codes.h new file mode 100644 index 0000000000000000000000000000000000000000..e5ee3cdadfec57b2225e2babc6a494fa6d790f74 --- /dev/null +++ b/third_party/acl/inc/ge/ge_api_error_codes.h @@ -0,0 +1,135 @@ +/** + * 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 +#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 GE_FUNC_VISIBILITY 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; + } + + 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()) { + return ""; + } + return iter_find->second; + } + + protected: + StatusFactory() {} + ~StatusFactory() {} + + private: + std::map err_desc_; +}; + +class GE_FUNC_VISIBILITY 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() {} +}; + +// 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 = (static_cast(0xFFU & (static_cast(runtime))) << 30) | \ + (static_cast(0xFFU & (static_cast(type))) << 28) | \ + (static_cast(0xFFU & (static_cast(level))) << 25) | \ + (static_cast(0xFFU & (static_cast(sysid))) << 17) | \ + (static_cast(0xFFU & (static_cast(modid))) << 12) | \ + (static_cast(0x0FFFU) & (static_cast(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_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_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_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_PLGMGR_PATH_INVALID, "Plugin path is invalid."); +GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_FORMAT_INVALID, "Format is invalid."); +GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_SHAPE_INVALID, "Shape is invalid."); +GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DATATYPE_INVALID, "Datatype is invalid."); + +GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_MEMORY_ALLOCATION, "Memory allocation error."); +GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to operate memory."); + +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_ diff --git a/third_party/acl/inc/ge/ge_api_types.h b/third_party/acl/inc/ge/ge_api_types.h new file mode 100644 index 0000000000000000000000000000000000000000..9ee637973f43dd3e6e1ad36e829d460f1f35966f --- /dev/null +++ b/third_party/acl/inc/ge/ge_api_types.h @@ -0,0 +1,481 @@ +/** + * 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 +#include "graph/tensor.h" + +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"; +// Dynamic input flag. ge.exec.dynamicInput=1, means enable dynaimc input, +// ge.exec.dynamicGraphExecuteMode, dynamic_execute[default] +const char *const OPTION_EXEC_DYNAMIC_INPUT = "ge.exec.dynamicInput"; +const char *const OPTION_EXEC_DYNAMIC_EXECUTE_MODE = "ge.exec.dynamicGraphExecuteMode"; +const char *const OPTION_EXEC_DATA_INPUTS_SHAPE_RANGE = "ge.exec.dataInputsShapeRange"; +const char *const OPTION_EXEC_ENABLE_COPY_OUTPUT_ADDR = "ge.exec.enableCopyOutputAddr"; + +// 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"; +const char *const PERFORMANCE_MODE = "ge.performance_mode"; +const char *const SHAPE_GENERALIZED_BUILD_MODE = "ge.shape_generalized_build_mode"; +const char *const MODIFY_MIXLIST = "ge.exec.modify_mixlist"; +const char *const OP_PRECISION_MODE = "ge.exec.op_precision_mode"; +} // 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"; + +// 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"; + +const std::string TUNE_DEVICE_IDS = "ge.exec.tuneDeviceIds"; + +// 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 threshold of fusion data size for communication op +const std::string FUSION_TENSOR_SIZE = "ge.fusionTensorSize"; + +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"; + +// 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 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"; + +// 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"; + +// Configure model bank path +const std::string MDL_BANK_PATH_FLAG = "ge.mdl_bank_path"; + +// Configure display_model_info flag +const std::string DISPLAY_MODEL_INFO = "ge.display_model_info"; + +// Configure op bank path +const std::string OP_BANK_PATH_FLAG = "ge.op_bank_path"; +const std::string OP_BANK_UPDATE_FLAG = "ge.op_bank_update"; + +// Configure for fix hcombroadcast format. +// when config model multi, broadcast format should be fixed +// 0: data multi; 1: model multi; +const std::string HCOM_MULTI_MODE = "ge.hcomMultiMode"; + +// atc and ir option +const char *const INPUT_SHAPE_RANGE = "input_shape_range"; + +// Configure express high compile performance or high execute performance +// normal: no need to compile, used saved .o files directly +// high: need to recompile, high execute performance mode +const std::string PERFORMANCE_MODE = "ge.performance_mode"; + +// For selecting the mode of shape generalization when build graph. +// shape_generalized: Shape will be generalized during graph build. +// shape_precise: Shape will not be generalized, use precise shape. +const std::string SHAPE_GENERALIZED_BUILD_MODE = "ge.shape_generalized_build_mode"; + +const std::string MODIFY_MIXLIST = "ge.exec.modify_mixlist"; + +const std::string OP_PRECISION_MODE = "ge.exec.op_precision_mode"; + +// 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 INPUT_SHAPE_RANGE = ge::INPUT_SHAPE_RANGE; +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; +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 TUNE_DEVICE_IDS = ge::TUNE_DEVICE_IDS.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(); +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 = ge::MDL_BANK_PATH_FLAG.c_str(); +static const char *const OP_BANK_PATH = ge::OP_BANK_PATH_FLAG.c_str(); +static const char *const OP_BANK_UPDATE = ge::OP_BANK_UPDATE_FLAG.c_str(); +static const char *const OP_DEBUG_LEVEL = ge::OP_DEBUG_LEVEL.c_str(); +static const char *const PERFORMANCE_MODE = ge::PERFORMANCE_MODE.c_str(); +static const char *const SHAPE_GENERALIZED_BUILD_MODE = ge::SHAPE_GENERALIZED_BUILD_MODE.c_str(); +static const char *const MODIFY_MIXLIST = ge::MODIFY_MIXLIST.c_str(); +static const char *const OP_PRECISION_MODE = ge::OP_PRECISION_MODE.c_str(); + +// for interface: aclgrphBuildModel +#ifdef __GNUC__ +const std::set ir_builder_suppported_options = {INPUT_FORMAT, + INPUT_SHAPE, + INPUT_SHAPE_RANGE, + OP_NAME_MAP, + DYNAMIC_BATCH_SIZE, + DYNAMIC_IMAGE_SIZE, + DYNAMIC_DIMS, + INSERT_OP_FILE, + OP_PRECISION_MODE, + PRECISION_MODE, + TUNE_DEVICE_IDS, + 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, + OP_BANK_PATH, + OP_BANK_UPDATE, + PERFORMANCE_MODE, + SHAPE_GENERALIZED_BUILD_MODE, + MODIFY_MIXLIST}; + +// for interface: aclgrphParse +const std::set ir_parser_suppported_options = { + INPUT_FP16_NODES, IS_INPUT_ADJUST_HW_LAYOUT, IS_OUTPUT_ADJUST_HW_LAYOUT, OUTPUT, + OUT_NODES, ENABLE_SCOPE_FUSION_PASSES}; + +// for interface: aclgrphBuildInitialize +const std::set global_options = {CORE_TYPE, + SOC_VERSION, + BUFFER_OPTIMIZE, + ENABLE_COMPRESS_WEIGHT, + COMPRESS_WEIGHT_CONF, + PRECISION_MODE, + TUNE_DEVICE_IDS, + 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, + OP_DEBUG_LEVEL, + DEBUG_DIR, + OP_COMPILER_CACHE_DIR, + OP_COMPILER_CACHE_MODE, + MODIFY_MIXLIST}; +#endif +} // namespace ir_option +} // namespace ge + +#endif // INC_EXTERNAL_GE_GE_API_TYPES_H_ diff --git a/third_party/acl/inc/graph/operator.h b/third_party/acl/inc/graph/operator.h index 5dc04137deb35dec1136be4189dd0a842bbfd7b4..49d874f7786839da2910c6f5bb45d2e517449a7c 100644 --- a/third_party/acl/inc/graph/operator.h +++ b/third_party/acl/inc/graph/operator.h @@ -82,7 +82,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { using OpNamedAttrs = ge::NamedAttrs; using OpListInt = std::vector; using OpListFloat = std::vector; - using OpListString = std::vector; + using OpListString = std::vector; using OpListAcendString = std::vector; using OpListBool = std::vector; using OpListTensor = std::vector; @@ -93,12 +93,12 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { Operator() {} ATTRIBUTED_DEPRECATED(Operator(const char *)) - explicit Operator(const string &type); + explicit Operator(const std::string &type); explicit Operator(const char *type); ATTRIBUTED_DEPRECATED(Operator(const char *, const char *)) - Operator(const string &name, const string &type); // lint !e148 + Operator(const std::string &name, const std::string &type); Operator(const AscendString &name, const AscendString &type); @@ -109,94 +109,96 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { bool IsEmpty() const; ATTRIBUTED_DEPRECATED(graphStatus GetName(AscendString &) const) - string GetName() const; + std::string GetName() const; graphStatus GetName(AscendString &name) const; ATTRIBUTED_DEPRECATED(graphStatus GetOpType(AscendString &) const) - string GetOpType() const; + std::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 std::string &dst_name, const Operator &src_oprt); 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); // lint !e148 + Operator &SetInput(const std::string &dst_name, const Operator &src_oprt, const std::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 std::string &dst_name, const Operator &src_oprt, uint32_t index); Operator &SetInput(const char *dst_name, const Operator &src_oprt, uint32_t index); + Operator &SetInput(uint32_t dst_index, const Operator &src_oprt, uint32_t src_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 std::string &dst_name, Tensor &data) const; graphStatus GetInputConstData(const char *dst_name, Tensor &data) const; ATTRIBUTED_DEPRECATED(TensorDesc GetInputDescByName(const char *) const) - TensorDesc GetInputDesc(const string &name) const; + TensorDesc GetInputDesc(const std::string &name) const; TensorDesc GetInputDescByName(const char *name) const; TensorDesc GetInputDesc(uint32_t index) const; ATTRIBUTED_DEPRECATED(int GetDynamicOutputNum(const char *) const) - int GetDynamicOutputNum(const string &name) const; + int GetDynamicOutputNum(const std::string &name) const; int GetDynamicOutputNum(const char *name) const; ATTRIBUTED_DEPRECATED(int GetDynamicInputNum(const char *)) - int GetDynamicInputNum(const string &name) const; + int GetDynamicInputNum(const std::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 std::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 std::string &name, const TensorDesc &tensor_desc); graphStatus UpdateInputDesc(const char *name, const TensorDesc &tensor_desc); ATTRIBUTED_DEPRECATED(TensorDesc GetOutputDescByName(const char *) const) - TensorDesc GetOutputDesc(const string &name) const; + TensorDesc GetOutputDesc(const std::string &name) const; TensorDesc GetOutputDescByName(const char *name) const; TensorDesc GetOutputDesc(uint32_t index) const; ATTRIBUTED_DEPRECATED(graphStatus UpdateOutputDesc(const char *, const TensorDesc &tensor_desc)) - graphStatus UpdateOutputDesc(const string &name, const TensorDesc &tensor_desc); // lint !e148 + graphStatus UpdateOutputDesc(const std::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; + TensorDesc GetDynamicInputDesc(const std::string &name, uint32_t index) const; 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); // lint !e148 + graphStatus UpdateDynamicInputDesc(const std::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; + TensorDesc GetDynamicOutputDesc(const std::string &name, uint32_t index) const; TensorDesc GetDynamicOutputDesc(const char *name, uint32_t index) const; ATTRIBUTED_DEPRECATED(graphStatus UpdateDynamicOutputDesc(const char *, uint32_t, const TensorDesc &)) - graphStatus UpdateDynamicOutputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); // lint !e148 + graphStatus UpdateDynamicOutputDesc(const std::string &name, uint32_t index, const TensorDesc &tensor_desc); graphStatus UpdateDynamicOutputDesc(const char *name, uint32_t index, const TensorDesc &tensor_desc); @@ -217,92 +219,92 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { graphStatus GetAllAttrNamesAndTypes(std::map &attr_name_types) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, int64_t)) - Operator &SetAttr(const string &name, int64_t attr_value); + Operator &SetAttr(const std::string &name, int64_t attr_value); ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, int32_t)) - Operator &SetAttr(const string &name, int32_t attr_value); + Operator &SetAttr(const std::string &name, int32_t attr_value); ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, uint32_t)) - Operator &SetAttr(const string &name, uint32_t attr_value); + Operator &SetAttr(const std::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; + graphStatus GetAttr(const std::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; + graphStatus GetAttr(const std::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; + graphStatus GetAttr(const std::string &name, uint32_t &attr_value) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector &)) - Operator &SetAttr(const string &name, const std::vector &attr_value); + Operator &SetAttr(const std::string &name, const std::vector &attr_value); ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector &)) - Operator &SetAttr(const string &name, const std::vector &attr_value); + Operator &SetAttr(const std::string &name, const std::vector &attr_value); ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector &)) - Operator &SetAttr(const string &name, const std::vector &attr_value); + Operator &SetAttr(const std::string &name, const std::vector &attr_value); ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, std::initializer_list &&)) - Operator &SetAttr(const string &name, std::initializer_list &&attr_value); + Operator &SetAttr(const std::string &name, std::initializer_list &&attr_value); ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *name, std::vector &) const) - graphStatus GetAttr(const string &name, std::vector &attr_value) const; + graphStatus GetAttr(const std::string &name, std::vector &attr_value) const; ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *name, std::vector &) const) - graphStatus GetAttr(const string &name, std::vector &attr_value) const; - ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const string &, std::vector &) const) - graphStatus GetAttr(const string &name, std::vector &attr_value) const; + graphStatus GetAttr(const std::string &name, std::vector &attr_value) const; + ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const std::string &, std::vector &) const) + graphStatus GetAttr(const std::string &name, std::vector &attr_value) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, float attr_value)) - Operator &SetAttr(const string &name, float attr_value); + Operator &SetAttr(const std::string &name, float attr_value); ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, float &) const) - graphStatus GetAttr(const string &name, float &attr_value) const; + graphStatus GetAttr(const std::string &name, float &attr_value) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector &)) - Operator &SetAttr(const string &name, const std::vector &attr_value); + Operator &SetAttr(const std::string &name, const std::vector &attr_value); ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector &) const) - graphStatus GetAttr(const string &name, std::vector &attr_value) const; + graphStatus GetAttr(const std::string &name, std::vector &attr_value) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, AttrValue &&)) - Operator &SetAttr(const string &name, AttrValue &&attr_value); + Operator &SetAttr(const std::string &name, AttrValue &&attr_value); ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, AttrValue &) const) - graphStatus GetAttr(const string &name, AttrValue &attr_value) const; - Operator &SetAttr(const string &name, const string &attr_value); - graphStatus GetAttr(const string &name, string &attr_value) const; - Operator &SetAttr(const string &name, const std::vector &attr_value); - graphStatus GetAttr(const string &name, std::vector &attr_value) const; + graphStatus GetAttr(const std::string &name, AttrValue &attr_value) const; + Operator &SetAttr(const std::string &name, const std::string &attr_value); + graphStatus GetAttr(const std::string &name, std::string &attr_value) const; + Operator &SetAttr(const std::string &name, const std::vector &attr_value); + graphStatus GetAttr(const std::string &name, std::vector &attr_value) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, bool)) - Operator &SetAttr(const string &name, bool attr_value); + Operator &SetAttr(const std::string &name, bool attr_value); ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, bool &) const) - graphStatus GetAttr(const string &name, bool &attr_value) const; + graphStatus GetAttr(const std::string &name, bool &attr_value) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector &)) - Operator &SetAttr(const string &name, const std::vector &attr_value); + Operator &SetAttr(const std::string &name, const std::vector &attr_value); ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector &) const) - graphStatus GetAttr(const string &name, std::vector &attr_value) const; + graphStatus GetAttr(const std::string &name, std::vector &attr_value) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const Tensor &)) - Operator &SetAttr(const string &name, const Tensor &attr_value); + Operator &SetAttr(const std::string &name, const Tensor &attr_value); ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, Tensor &) const) - graphStatus GetAttr(const string &name, Tensor &attr_value) const; + graphStatus GetAttr(const std::string &name, Tensor &attr_value) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector &)) - Operator &SetAttr(const string &name, const std::vector &attr_value); + Operator &SetAttr(const std::string &name, const std::vector &attr_value); ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector &) const) - graphStatus GetAttr(const string &name, std::vector &attr_value) const; + graphStatus GetAttr(const std::string &name, std::vector &attr_value) const; // Bytes type ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const OpBytes &)) - Operator &SetAttr(const string &name, const OpBytes &attr_value); + Operator &SetAttr(const std::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; + graphStatus GetAttr(const std::string &name, OpBytes &attr_value) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector> &)) - Operator &SetAttr(const string &name, const std::vector> &attr_value); + Operator &SetAttr(const std::string &name, const std::vector> &attr_value); ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector> &) const) - graphStatus GetAttr(const string &name, std::vector> &attr_value) const; + graphStatus GetAttr(const std::string &name, std::vector> &attr_value) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector &)) - Operator &SetAttr(const string &name, const std::vector &attr_value); + Operator &SetAttr(const std::string &name, const std::vector &attr_value); ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector &) const) - graphStatus GetAttr(const string &name, std::vector &attr_value) const; + graphStatus GetAttr(const std::string &name, std::vector &attr_value) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const ge::DataType &)) - Operator &SetAttr(const string &name, const ge::DataType &attr_value); + Operator &SetAttr(const std::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; + graphStatus GetAttr(const std::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); + Operator &SetAttr(const std::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; + graphStatus GetAttr(const std::string &name, ge::NamedAttrs &attr_value) const; ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector &)) - Operator &SetAttr(const string &name, const std::vector &attr_value); + Operator &SetAttr(const std::string &name, const std::vector &attr_value); ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector &) const) - graphStatus GetAttr(const string &name, std::vector &attr_value) const; + graphStatus GetAttr(const std::string &name, std::vector &attr_value) const; Operator &SetAttr(const char *name, int64_t attr_value); Operator &SetAttr(const char *name, int32_t attr_value); @@ -368,43 +370,81 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { std::vector GetSubgraphNames() const; graphStatus GetSubgraphNames(std::vector &names) const; ATTRIBUTED_DEPRECATED(SubgraphBuilder GetSubgraphBuilder(const char *) const) - SubgraphBuilder GetSubgraphBuilder(const string &name) const; + SubgraphBuilder GetSubgraphBuilder(const std::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 std::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 std::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 std::string &name, uint32_t index) const; Graph GetDynamicSubgraph(const char *name, uint32_t index) const; protected: - void AttrRegister(const string &name, float attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, int64_t attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, const string &attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, bool attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, const Tensor &attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, const OpBytes &attr_value); - void AttrRegister(const string &name, const std::vector> &attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, const ge::DataType &attr_value); - void AttrRegister(const string &name, const ge::NamedAttrs &attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, const AscendString &attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, float)) + void AttrRegister(const std::string &name, float attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const std::vector &)) + void AttrRegister(const std::string &name, const std::vector &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, int64_t)) + void AttrRegister(const std::string &name, int64_t attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const std::vector &)) + void AttrRegister(const std::string &name, const std::vector &attr_value); + void AttrRegister(const std::string &name, const std::string &attr_value); + void AttrRegister(const std::string &name, const std::vector &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, bool)) + void AttrRegister(const std::string &name, bool attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const std::vector &)) + void AttrRegister(const std::string &name, const std::vector &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const Tensor &)) + void AttrRegister(const std::string &name, const Tensor &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const std::vector &)) + void AttrRegister(const std::string &name, const std::vector &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const OpBytes &)) + void AttrRegister(const std::string &name, const OpBytes &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const std::vector> &)) + void AttrRegister(const std::string &name, const std::vector> &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const std::vector &)) + void AttrRegister(const std::string &name, const std::vector &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const ge::DataType &)) + void AttrRegister(const std::string &name, const ge::DataType &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const ge::NamedAttrs &)) + void AttrRegister(const std::string &name, const ge::NamedAttrs &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const std::vector &)) + void AttrRegister(const std::string &name, const std::vector &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const AscendString &)) + void AttrRegister(const std::string &name, const AscendString &attr_value); + ATTRIBUTED_DEPRECATED(void AttrRegister(const char *, const std::vector &)) + void AttrRegister(const std::string &name, const std::vector &attr_value); + + void AttrRegister(const char *name, float attr_value); + void AttrRegister(const char *name, const std::vector &attr_value); + void AttrRegister(const char *name, int64_t attr_value); + void AttrRegister(const char *name, const std::vector &attr_value); + void AttrRegister(const char *name, const char *attr_value); + void AttrRegister(const char *name, bool attr_value); + void AttrRegister(const char *name, const std::vector &attr_value); + void AttrRegister(const char *name, const Tensor &attr_value); + void AttrRegister(const char *name, const std::vector &attr_value); + void AttrRegister(const char *name, const OpBytes &attr_value); + void AttrRegister(const char *name, const std::vector> &attr_value); + void AttrRegister(const char *name, const std::vector &attr_value); + void AttrRegister(const char *name, const ge::DataType &attr_value); + void AttrRegister(const char *name, const ge::NamedAttrs &attr_value); + void AttrRegister(const char *name, const std::vector &attr_value); + void AttrRegister(const char *name, const AscendString &attr_value); + void AttrRegister(const char *name, const std::vector &attr_value); explicit Operator(OperatorImplPtr &&op_impl); - void InputRegister(const string &name); + ATTRIBUTED_DEPRECATED(void InputRegister(const char *)) + void InputRegister(const std::string &name); + void InputRegister(const char *name); - void OptionalInputRegister(const string &name); + ATTRIBUTED_DEPRECATED(void OptionalInputRegister(const char *)) + void OptionalInputRegister(const std::string &name); + void OptionalInputRegister(const char *name); void InferFuncRegister(const std::function &func); @@ -412,34 +452,62 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { void InferFormatFuncRegister(const std::function &func); - void OutputRegister(const string &name); + ATTRIBUTED_DEPRECATED(void OutputRegister(const char *)) + void OutputRegister(const std::string &name); + void OutputRegister(const char *name); - void DynamicInputRegister(const string &name, const unsigned int num, bool is_push_back = true); + ATTRIBUTED_DEPRECATED(void DynamicInputRegister(const char *, const unsigned int, bool)) + void DynamicInputRegister(const std::string &name, const unsigned int num, bool is_push_back = true); + void DynamicInputRegister(const char *name, const unsigned int num, bool is_push_back = true); - void DynamicInputRegisterByIndex(const string &name, const unsigned int num, size_t index); + ATTRIBUTED_DEPRECATED(void DynamicInputRegisterByIndex(const char *, const unsigned int, size_t)) + void DynamicInputRegisterByIndex(const std::string &name, const unsigned int num, size_t index); + void DynamicInputRegisterByIndex(const char *name, const unsigned int num, size_t index); - void DynamicOutputRegister(const string &name, const unsigned int num, bool is_push_back = true); + ATTRIBUTED_DEPRECATED(void DynamicOutputRegister(const char *, const unsigned int, bool)) + void DynamicOutputRegister(const std::string &name, const unsigned int num, bool is_push_back = true); + void DynamicOutputRegister(const char *name, const unsigned int num, bool is_push_back = true); - void RequiredAttrRegister(const string &name); + ATTRIBUTED_DEPRECATED(void RequiredAttrRegister(const char *)) + void RequiredAttrRegister(const std::string &name); + void RequiredAttrRegister(const char *name); - graphStatus VerifyAll(); // lint !e148 + graphStatus VerifyAll(); // Only has one output index = 0 - Operator &SetInput(const string &dst_name, uint32_t dst_index, + ATTRIBUTED_DEPRECATED(Operator &SetInput(const char *, uint32_t, const Operator &)) + Operator &SetInput(const std::string &dst_name, uint32_t dst_index, + const Operator &src_oprt); + Operator &SetInput(const char *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 - - 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; + ATTRIBUTED_DEPRECATED(Operator &SetInput(const char *, uint32_t, const Operator &, const char *)) + Operator &SetInput(const std::string &dst_name, uint32_t dst_index, const Operator &src_oprt, + const std::string &name); + Operator &SetInput(const char *dst_name, uint32_t dst_index, const Operator &src_oprt, + const char *name); + + ATTRIBUTED_DEPRECATED(void SubgraphRegister(const char *, bool)) + void SubgraphRegister(const std::string &ir_name, bool dynamic); + void SubgraphRegister(const char *ir_name, bool dynamic); + ATTRIBUTED_DEPRECATED(void SubgraphCountRegister(const char *, uint32_t)) + void SubgraphCountRegister(const std::string &ir_name, uint32_t count); + void SubgraphCountRegister(const char *ir_name, uint32_t count); + ATTRIBUTED_DEPRECATED(void SetSubgraphBuilder(const char *, uint32_t, const SubgraphBuilder &)) + void SetSubgraphBuilder(const std::string &ir_name, uint32_t index, const SubgraphBuilder &builder); + void SetSubgraphBuilder(const char *ir_name, uint32_t index, const SubgraphBuilder &builder); + ATTRIBUTED_DEPRECATED(Graph GetSubgraphImpl(const char *) const) + Graph GetSubgraphImpl(const std::string &name) const; + Graph GetSubgraphImpl(const char *name) const; private: - Operator &SetInput(const string &dst_name, const OutHandler &out_handler); // lint !e148 + ATTRIBUTED_DEPRECATED(Operator &SetInput(const char *, const OutHandler &)) + Operator &SetInput(const std::string &dst_name, const OutHandler &out_handler); + Operator &SetInput(const char *dst_name, const OutHandler &out_handler); - OutHandler GetOutput(const string &name) const; + ATTRIBUTED_DEPRECATED(OutHandler GetOutput(const char *) const) + OutHandler GetOutput(const std::string &name) const; + OutHandler GetOutput(const char *name) const; OutHandler GetOutput(uint32_t index) const; @@ -447,7 +515,9 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { OperatorImplPtr operator_impl_{nullptr}; - graphStatus GetInputConstDataOut(const string &dst_name, Tensor &data) const; + ATTRIBUTED_DEPRECATED(graphStatus GetInputConstDataOut(const char *, Tensor &) const) + graphStatus GetInputConstDataOut(const std::string &dst_name, Tensor &data) const; + graphStatus GetInputConstDataOut(const char *dst_name, Tensor &data) const; std::shared_ptr GetNode() const; }; diff --git a/third_party/acl/libs/build_stub.sh b/third_party/acl/libs/build_stub.sh index 90cd52836e2bd7357969ede5690d1a7d86df8933..a84142e2d0ca83a0c1962d9a90c89577618af72e 100644 --- a/third_party/acl/libs/build_stub.sh +++ b/third_party/acl/libs/build_stub.sh @@ -21,6 +21,7 @@ gcc -fPIC -shared -o libascendcl.so -I../inc acl.cpp gcc -fPIC -shared -o libacl_op_compiler.so -I../inc acl_op_compiler.cpp -gcc -fPIC -shared -o libge_runner.so -I../inc ge_runner.cpp +gcc -fPIC -shared -o libge_runner.so -I../inc ge_runner.cpp ge_api.cpp + +gcc -fPIC -shared -o libgraph.so -I../inc graph.cpp operator_factory.cpp operator.cpp tensor.cpp -gcc -fPIC -shared -o libgraph.so -I../inc graph.cpp diff --git a/third_party/acl/libs/ge_api.cpp b/third_party/acl/libs/ge_api.cpp new file mode 100644 index 0000000000000000000000000000000000000000..87d7485fcdc07a9e1a566902ecd2802bc859ad1c --- /dev/null +++ b/third_party/acl/libs/ge_api.cpp @@ -0,0 +1,44 @@ +// Copyright (c) 2020 Huawei Technologies Co., Ltd +// All rights reserved. +// +// Licensed under the BSD 3-Clause License (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/BSD-3-Clause +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "ge/ge_api.h" + +namespace ge { +Status Session::RunGraphWithStreamAsync( + uint32_t graph_id, + void* stream, + const std::vector& inputs, + std::vector& outputs) { + + sessionId_ = -1; + return ge::SUCCESS; +} + +Session::Session(const std::map& options) {} + +Session::~Session() {} + +Status Session::AddGraph(uint32_t graphId, const Graph& graph) { + return ge::SUCCESS; +} + +Status GEInitialize(const std::map& options) { + return ge::SUCCESS; +} + +Status GEFinalize() { + return ge::SUCCESS; +} +} // namespace ge \ No newline at end of file diff --git a/third_party/acl/libs/graph.cpp b/third_party/acl/libs/graph.cpp index cd318fff683c7324f18423adee2f352e8cff34d5..384d86fe7ceb7a87e9d6f59b232fabad056c16b1 100644 --- a/third_party/acl/libs/graph.cpp +++ b/third_party/acl/libs/graph.cpp @@ -12,32 +12,86 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "graph/graph.h" #include "graph/ascend_string.h" #include "graph/tensor.h" -#include "graph/graph.h" namespace ge { - AscendString::AscendString(const char* name) {} - bool AscendString::operator<(const AscendString& d) const {return true;} - const char* AscendString::GetString() const {return 0;} - bool AscendString::operator==(const AscendString& d) const {return true;} - - TensorDesc::TensorDesc(const TensorDesc &desc) {} - TensorDesc::TensorDesc(TensorDesc &&desc) {} - TensorDesc::TensorDesc(Shape shape, Format format, DataType dt) {} - void TensorDesc::SetConstData(const std::shared_ptr const_data_buffer, const size_t &const_data_len) {} - Shape::Shape(const std::vector &dims) {} - - std::vector Graph::GetDirectNode () const {return {};} - - GNode::GNode() {} - graphStatus GNode::GetType(AscendString &type) const {return 0;} - graphStatus GNode::SetAttr(const AscendString &name, int64_t &attr_value) const {return 0;} - graphStatus GNode::SetAttr(const AscendString &name, int32_t &attr_value) const {return 0;} - graphStatus GNode::SetAttr(const AscendString &name, float &attr_value) const {return 0;} - graphStatus GNode::SetAttr(const AscendString &name, AscendString &attr_value) const {return 0;} - graphStatus GNode::SetAttr(const AscendString &name, bool &attr_value) const {return 0;} - graphStatus GNode::SetAttr(const AscendString &name, std::vector &attr_value) const {return 0;} - graphStatus GNode::SetAttr(const AscendString &name, std::vector &attr_value) const {return 0;} - graphStatus GNode::SetAttr(const AscendString &name, std::vector> &attr_value) const {return 0;} -} \ No newline at end of file +Graph::Graph(const char* name) {} + +Graph graph("test"); + +Graph& Graph::SetInputs(const std::vector& inputs) { + return graph; +} + +Graph& Graph::SetOutputs(const std::vector& outputs) { + return graph; +} + +Graph& Graph::SetOutputs( + const std::vector>>& + output_indexs) { + return graph; +} +AscendString::AscendString(const char* name) {} +bool AscendString::operator<(const AscendString& d) const { + return true; +} +const char* AscendString::GetString() const { + return 0; +} +bool AscendString::operator==(const AscendString& d) const { + return true; +} + +TensorDesc::TensorDesc(const TensorDesc& desc) {} +TensorDesc::TensorDesc(TensorDesc&& desc) {} +TensorDesc::TensorDesc(Shape shape, Format format, DataType dt) {} +void TensorDesc::SetConstData( + const std::shared_ptr const_data_buffer, + const size_t& const_data_len) {} +Shape::Shape(const std::vector& dims) {} + +std::vector Graph::GetDirectNode() const { + return {}; +} + +GNode::GNode() {} +graphStatus GNode::GetType(AscendString& type) const { + return 0; +} +graphStatus GNode::SetAttr(const AscendString& name, int64_t& attr_value) + const { + return 0; +} +graphStatus GNode::SetAttr(const AscendString& name, int32_t& attr_value) + const { + return 0; +} +graphStatus GNode::SetAttr(const AscendString& name, float& attr_value) const { + return 0; +} +graphStatus GNode::SetAttr(const AscendString& name, AscendString& attr_value) + const { + return 0; +} +graphStatus GNode::SetAttr(const AscendString& name, bool& attr_value) const { + return 0; +} +graphStatus GNode::SetAttr( + const AscendString& name, + std::vector& attr_value) const { + return 0; +} +graphStatus GNode::SetAttr( + const AscendString& name, + std::vector& attr_value) const { + return 0; +} +graphStatus GNode::SetAttr( + const AscendString& name, + std::vector>& attr_value) const { + return 0; +} +} // namespace ge \ No newline at end of file diff --git a/third_party/acl/libs/operator.cpp b/third_party/acl/libs/operator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7733882ab9d74a07eec0a4b4892f42de416f50cd --- /dev/null +++ b/third_party/acl/libs/operator.cpp @@ -0,0 +1,151 @@ +// Copyright (c) 2020 Huawei Technologies Co., Ltd +// All rights reserved. +// +// Licensed under the BSD 3-Clause License (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/BSD-3-Clause +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include "graph/operator.h" + +namespace ge { + +Operator op; + +Operator::Operator(const char* type){}; + +Operator::Operator(const char* name, const char* type) {} + +Operator::Operator(const AscendString& name, const AscendString& type) {} + +void Operator::AttrRegister( + const char* name, + const std::vector& attr_value) {} + +void Operator::AttrRegister(const char* name, const AscendString& attr_value) {} + +void Operator::AttrRegister(const char* name, const Tensor& attr_value) {} + +void Operator::AttrRegister(const char* name, bool attr_value) {} + +void Operator::AttrRegister(const char* name, const ge::DataType& attr_value) {} + +void Operator::AttrRegister(const char* name, float attr_value) {} + +void Operator::AttrRegister(const char* name, int64_t attr_value) {} + +void Operator::InputRegister(const char* name) {} + +void Operator::DynamicInputRegisterByIndex( + const char* name, + const unsigned int num, + size_t index) {} + +void Operator::DynamicInputRegister( + const char* name, + const unsigned int num, + bool is_push_back) {} + +void Operator::DynamicOutputRegister( + const char* name, + const unsigned int num, + bool is_push_back) {} + +void Operator::RequiredAttrRegister(const char* name) {} + +void Operator::OutputRegister(const char* name) {} + +Operator& Operator::SetAttr(const char* name, const AscendString& attr_value) {} + +graphStatus Operator::UpdateInputDesc( + const char* name, + const TensorDesc& tensor_desc) { + return GRAPH_SUCCESS; +} + +graphStatus Operator::UpdateOutputDesc( + const char* name, + const TensorDesc& tensor_desc) { + return GRAPH_SUCCESS; +} + +TensorDesc Operator::GetOutputDescByName(const char* name) const { + return TensorDesc(); +} + +Operator& Operator::SetInput( + uint32_t dst_index, + const Operator& src_oprt, + uint32_t src_index) { + return op; +} + +TensorDesc Operator::GetInputDescByName(const char* name) const { + return TensorDesc(); +} + +Operator& Operator::SetAttr(const char* name, bool attr_value) { + return op; +} + +Operator& Operator::SetAttr(const char* name, int64_t attr_value) { + return op; +} + +Operator& Operator::SetAttr(const char* name, int32_t attr_value) { + return op; +} + +Operator& Operator::SetAttr(const char* name, uint32_t attr_value) { + return op; +} + +Operator& Operator::SetAttr( + const char* name, + const std::vector& attr_value) { + return op; +} + +Operator& Operator::SetAttr( + const char* name, + const std::vector& attr_value) { + return op; +} + +Operator& Operator::SetAttr( + const char* name, + const std::vector& attr_value) { + return op; +} + +Operator& Operator::SetAttr( + const char* name, + std::initializer_list&& attr_value) { + return op; +} + +Operator& Operator::SetAttr(const char* name, float attr_value) { + return op; +} + +Operator& Operator::SetAttr( + const char* name, + const std::vector& attr_value) { + return op; +} + +Operator& Operator::SetAttr(const char* name, AttrValue&& attr_value) { + return op; +} + +Operator& Operator::SetAttr(const char* name, const Tensor& attr_value) { + return op; +} + +} // namespace ge \ No newline at end of file diff --git a/third_party/acl/libs/operator_factory.cpp b/third_party/acl/libs/operator_factory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..48731df0d5274f0776489a6ce9632a22417b32c1 --- /dev/null +++ b/third_party/acl/libs/operator_factory.cpp @@ -0,0 +1,32 @@ +// Copyright (c) 2020 Huawei Technologies Co., Ltd +// All rights reserved. +// +// Licensed under the BSD 3-Clause License (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/BSD-3-Clause +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "graph/operator_factory.h" + +namespace ge { +Operator OperatorFactory::CreateOperator( + const char* operator_name, + const char* operator_type) { + return Operator(); +} + +OperatorCreatorRegister::OperatorCreatorRegister( + const char* operator_type, + const OpCreatorV2& op_creator) {} + +bool OperatorFactory::IsExistOp(const char* operator_type) { + return true; +} +} // namespace ge \ No newline at end of file diff --git a/third_party/acl/libs/tensor.cpp b/third_party/acl/libs/tensor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e522991e338b566d7ec258fddd5e7b1f4032868f --- /dev/null +++ b/third_party/acl/libs/tensor.cpp @@ -0,0 +1,56 @@ +// Copyright (c) 2020 Huawei Technologies Co., Ltd +// All rights reserved. +// +// Licensed under the BSD 3-Clause License (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/BSD-3-Clause +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "graph/tensor.h" + +namespace ge { +Tensor::Tensor() {} + +Tensor tensor; + +Tensor::Tensor(const TensorDesc& tensorDesc) {} + +Tensor::Tensor(const TensorDesc& tensorDesc, const uint8_t* data, size_t size) {} + +graphStatus Tensor::SetData( + uint8_t* data, + size_t size, + const Tensor::DeleteFunc& deleter_func) { + return GRAPH_SUCCESS; +} + +Shape::Shape() {} + +std::vector Shape::GetDims() const { + return std::vector{}; +} + +size_t Shape::GetDimNum() const { + return 0; +} + +TensorDesc::TensorDesc() {} +void TensorDesc::SetFormat(Format format) {} +void TensorDesc::SetOriginFormat(Format originFormat) {} +void TensorDesc::SetShape(const Shape& shape) {} +void TensorDesc::SetOriginShape(const Shape& originShape) {} +void TensorDesc::SetDataType(DataType dt) {} +void TensorDesc::SetPlacement(Placement placement) {} +Format TensorDesc::GetFormat() const {return FORMAT_NCHW;} +Format TensorDesc::GetOriginFormat() const {return FORMAT_NCHW;} +Shape TensorDesc::GetShape() const {return Shape();}; +Shape TensorDesc::GetOriginShape() const {return Shape();} +DataType TensorDesc::GetDataType() const {return DT_INT64;} +} // namespace ge \ No newline at end of file