!40 Synchronize with latest Ascend software suite 17 Jun 2020

Merge pull request !40 from yanghaoran/master
pull/40/MERGE
mindspore-ci-bot 5 years ago committed by Gitee
commit 1c2672868f

@ -77,6 +77,15 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session {
/// ///
Status RunGraph(uint32_t graphId, const std::vector<Tensor> &inputs, std::vector<Tensor> &outputs); Status RunGraph(uint32_t graphId, const std::vector<Tensor> &inputs, std::vector<Tensor> &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<InputTensorInfo> &inputs);
/// ///
/// @ingroup ge_graph /// @ingroup ge_graph
/// @brief run graph in the session with specific session id asynchronously /// @brief run graph in the session with specific session id asynchronously

@ -157,6 +157,9 @@ const std::string OUTPUT_DATATYPE = "ge.outputDatatype";
// congigure opSelectImplmode to setting op select implmode // congigure opSelectImplmode to setting op select implmode
const std::string OP_SELECT_IMPL_MODE = "ge.opSelectImplmode"; 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, // configure whether to enable hcom parallel by session constructor options param,
// its value should be "0" or "1", default value is "0" // its value should be "0" or "1", default value is "0"
const std::string HCOM_PARALLEL = "ge.hcomParallel"; const std::string HCOM_PARALLEL = "ge.hcomParallel";
@ -258,12 +261,12 @@ using RunAsyncCallback = std::function<void(Status, std::vector<ge::OutputTensor
namespace ir_option { namespace ir_option {
static const char *const INPUT_FORMAT = "input_format"; static const char *const INPUT_FORMAT = "input_format";
static const char *const INPUT_SHAPE = "input_shape"; 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_BATCH_SIZE = kDynamicBatchSize;
static const char *const DYNAMIC_IMAGE_SIZE = kDynamicImageSize; static const char *const DYNAMIC_IMAGE_SIZE = kDynamicImageSize;
static const char *const INSERT_OP_FILE = ge::INSERT_OP_FILE.c_str(); 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 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 EXEC_DISABLE_REUSED_MEMORY = ge::OPTION_EXEC_DISABLE_REUSED_MEMORY;
static const char *const HEAD_STREAM = ge::HEAD_STREAM.c_str();
static const char *const AUTO_TUNE_MODE = ge::AUTO_TUNE_MODE.c_str(); 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 CORE_TYPE = ge::CORE_TYPE.c_str();
static const char *const SOC_VERSION = ge::SOC_VERSION.c_str(); static const char *const SOC_VERSION = ge::SOC_VERSION.c_str();
@ -280,16 +283,20 @@ 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 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 INPUT_FP16_NODES = ge::INPUT_FP16_NODES.c_str();
static const char *const LOG_LEVEL = "log"; static const char *const LOG_LEVEL = "log";
static const char *const OPTYPELIST_FOR_IMPLMODE = ge::OPTYPELIST_FOR_IMPLMODE.c_str();
// for interface: aclgrphBuildModel // for interface: aclgrphBuildModel
const std::set<std::string> ir_builder_suppported_options = { const std::set<std::string> ir_builder_suppported_options = {
INPUT_FORMAT, INPUT_SHAPE, DYNAMIC_BATCH_SIZE, DYNAMIC_IMAGE_SIZE, INPUT_FORMAT, INPUT_SHAPE, OP_NAME_MAP, DYNAMIC_BATCH_SIZE,
INSERT_OP_FILE, OUTPUT_TYPE, BUFFER_OPTIMIZE, ENABLE_COMPRESS_WEIGHT, DYNAMIC_IMAGE_SIZE, INSERT_OP_FILE, PRECISION_MODE, EXEC_DISABLE_REUSED_MEMORY,
COMPRESS_WEIGHT_CONF, OUT_NODES, INPUT_FP16_NODES, LOG_LEVEL}; AUTO_TUNE_MODE, OUTPUT_TYPE, OUT_NODES, INPUT_FP16_NODES,
LOG_LEVEL};
// for interface: aclgrphBuildInitialize // for interface: aclgrphBuildInitialize
const std::set<std::string> global_options = {HEAD_STREAM, const std::set<std::string> global_options = {CORE_TYPE,
CORE_TYPE,
SOC_VERSION, SOC_VERSION,
BUFFER_OPTIMIZE,
ENABLE_COMPRESS_WEIGHT,
COMPRESS_WEIGHT_CONF,
PRECISION_MODE, PRECISION_MODE,
EXEC_DISABLE_REUSED_MEMORY, EXEC_DISABLE_REUSED_MEMORY,
AUTO_TUNE_MODE, AUTO_TUNE_MODE,
@ -298,7 +305,8 @@ const std::set<std::string> global_options = {HEAD_STREAM,
FUSION_SWITCH_FILE, FUSION_SWITCH_FILE,
ENABLE_SMALL_CHANNEL, ENABLE_SMALL_CHANNEL,
QUANT_OPTIMIZE, QUANT_OPTIMIZE,
OP_SELECT_IMPL_MODE}; OP_SELECT_IMPL_MODE,
OPTYPELIST_FOR_IMPLMODE};
} // namespace ir_option } // namespace ir_option
} // namespace ge } // namespace ge

@ -143,6 +143,7 @@ enum Format {
FORMAT_DHWNC, FORMAT_DHWNC,
FORMAT_FRACTAL_Z_3D_TRANSPOSE, // 3D filter(transpose) input tensor format FORMAT_FRACTAL_Z_3D_TRANSPOSE, // 3D filter(transpose) input tensor format
FORMAT_FRACTAL_ZN_LSTM, FORMAT_FRACTAL_ZN_LSTM,
FORMAT_FRACTAL_Z_G,
FORMAT_RESERVED, FORMAT_RESERVED,
FORMAT_ALL FORMAT_ALL
}; };

@ -25,11 +25,12 @@ namespace domi {
/// @brief AI framework types /// @brief AI framework types
/// ///
enum FrameworkType { enum FrameworkType {
FMK_TYPE_C = 0, CAFFE = 0,
FMK_TYPE_MINDSPORE = 1, MINDSPORE = 1,
FMK_TYPE_T = 3, TENSORFLOW = 3,
FMK_TYPE_A_NN, ANDROID_NN,
FMK_TYPE_RESERVED, ONNX,
FRAMEWORK_RESERVED,
}; };
} // namespace domi } // namespace domi

@ -231,7 +231,7 @@ using cce::ccStatus_t;
DOMI_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \ DOMI_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \
exec_expr; \ exec_expr; \
} \ } \
} };
// If expr is not RT_ERROR_NONE, print the log and return // If expr is not RT_ERROR_NONE, print the log and return
#define GE_CHK_RT_RET(expr) \ #define GE_CHK_RT_RET(expr) \
@ -259,7 +259,7 @@ using cce::ccStatus_t;
if (expr) { \ if (expr) { \
exec_expr; \ exec_expr; \
} \ } \
} };
// If make_shared is abnormal, print the log and execute the statement // If make_shared is abnormal, print the log and execute the statement
#define GE_MAKE_SHARED(exec_expr0, exec_expr1) \ #define GE_MAKE_SHARED(exec_expr0, exec_expr1) \

@ -280,6 +280,8 @@ GE_ERRORNO_RUNTIME(GE_RTI_CALL_HCCL_REDUCE_SCATTER_FAILED, 47, "call hccl hcom r
// Executor module error code definition // Executor module error code definition
GE_ERRORNO_EXECUTOR(GE_EXEC_NOT_INIT, 1, "GE Executor is not yet initialized."); GE_ERRORNO_EXECUTOR(GE_EXEC_NOT_INIT, 1, "GE Executor is not yet initialized.");
GE_ERRORNO_EXECUTOR(GE_AIPP_NOT_EXIST, 2, "GE AIPP is not exist.");
GE_ERRORNO_EXECUTOR(GE_DYNAMIC_AIPP_NOT_SUPPORT_QUERY, 3, "GE Dynamic AIPP is not support to query temporarily.");
// Generator module error code definition // Generator module error code definition
GE_ERRORNO_GENERATOR(GE_GENERATOR_GRAPH_MANAGER_INIT_FAILED, 1, "Graph manager initialize failed."); GE_ERRORNO_GENERATOR(GE_GENERATOR_GRAPH_MANAGER_INIT_FAILED, 1, "Graph manager initialize failed.");

@ -33,11 +33,11 @@ enum RuntimeType { HOST = 0, DEVICE = 1 };
enum PerfLevel { GEN_TASK_WITH_FUSION = -1, GEN_TASK_WITHOUT_L2FUSION = 3, GEN_TASK_WITHOUT_FUSION = 4 }; enum PerfLevel { GEN_TASK_WITH_FUSION = -1, GEN_TASK_WITHOUT_L2FUSION = 3, GEN_TASK_WITHOUT_FUSION = 4 };
enum FrameworkType { enum FrameworkType {
FMK_TYPE_C = 0, CAFFE = 0,
FMK_TYPE_MINDSPORE = 1, MINDSPORE = 1,
FMK_TYPE_T = 3, TENSORFLOW = 3,
FMK_TYPE_A_NN, ANDROID_NN,
FMK_TYPE_RESERVED, FRAMEWORK_RESERVED,
}; };
enum OpEngineType { enum OpEngineType {
@ -111,6 +111,72 @@ struct InputOutputDescInfo {
ShapeDescription shape_info; ShapeDescription shape_info;
}; };
// Definition of model io dims
struct InputOutputDims {
std::string name;
size_t dim_num;
uint32_t size;
std::vector<int64_t> dims;
};
// Definition of model io dims
struct OriginInputInfo {
Format format;
DataType data_type;
uint32_t dim_num;
};
// The structure of AIPP info
struct AippConfigInfo {
int8_t input_format;
int32_t src_image_size_w;
int32_t src_image_size_h;
int8_t crop;
int32_t load_start_pos_w;
int32_t load_start_pos_h;
int32_t crop_size_w;
int32_t crop_size_h;
int8_t resize;
int32_t resize_output_w;
int32_t resize_output_h;
int8_t padding;
int32_t left_padding_size;
int32_t right_padding_size;
int32_t top_padding_size;
int32_t bottom_padding_size;
int8_t csc_switch;
int8_t rbuv_swap_switch;
int8_t ax_swap_switch;
int8_t single_line_mode;
int32_t matrix_r0c0;
int32_t matrix_r0c1;
int32_t matrix_r0c2;
int32_t matrix_r1c0;
int32_t matrix_r1c1;
int32_t matrix_r1c2;
int32_t matrix_r2c0;
int32_t matrix_r2c1;
int32_t matrix_r2c2;
int32_t output_bias_0;
int32_t output_bias_1;
int32_t output_bias_2;
int32_t input_bias_0;
int32_t input_bias_1;
int32_t input_bias_2;
int32_t mean_chn_0;
int32_t mean_chn_1;
int32_t mean_chn_2;
int32_t mean_chn_3;
float min_chn_0;
float min_chn_1;
float min_chn_2;
float min_chn_3;
float var_reci_chn_0;
float var_reci_chn_1;
float var_reci_chn_2;
float var_reci_chn_3;
};
// The structure of offline Modeldata // The structure of offline Modeldata
struct ModelData { struct ModelData {
void *model_data = nullptr; // Model binary data start addr void *model_data = nullptr; // Model binary data start addr

@ -59,15 +59,14 @@ class OmFileLoadHelper {
Status GetModelPartition(ModelPartitionType type, ModelPartition &partition); Status GetModelPartition(ModelPartitionType type, ModelPartition &partition);
OmFileContext context_;
private: private:
Status CheckModelValid(const ge::ModelData &model) const; Status CheckModelValid(const ge::ModelData &model) const;
Status LoadModelPartitionTable(uint8_t *model_data, const uint32_t model_data_size); Status LoadModelPartitionTable(uint8_t *model_data, const uint32_t model_data_size);
bool is_inited_{false}; bool is_inited_{false};
public:
OmFileContext context_;
}; };
class OmFileSaveHelper { class OmFileSaveHelper {

@ -160,6 +160,7 @@ REGISTER_OPTYPE_DECLARE(SLICE, "Slice");
REGISTER_OPTYPE_DECLARE(SLICED, "SliceD"); REGISTER_OPTYPE_DECLARE(SLICED, "SliceD");
REGISTER_OPTYPE_DECLARE(FLOORDIV, "FloorDiv"); REGISTER_OPTYPE_DECLARE(FLOORDIV, "FloorDiv");
REGISTER_OPTYPE_DECLARE(SQUEEZE, "Squeeze"); REGISTER_OPTYPE_DECLARE(SQUEEZE, "Squeeze");
REGISTER_OPTYPE_DECLARE(UNSQUEEZE, "Unsqueeze");
REGISTER_OPTYPE_DECLARE(STRIDEDSLICE, "StridedSlice"); REGISTER_OPTYPE_DECLARE(STRIDEDSLICE, "StridedSlice");
REGISTER_OPTYPE_DECLARE(RANGE, "Range"); REGISTER_OPTYPE_DECLARE(RANGE, "Range");
REGISTER_OPTYPE_DECLARE(RPNPROPOSALS, "GenerateRpnProposals"); REGISTER_OPTYPE_DECLARE(RPNPROPOSALS, "GenerateRpnProposals");

@ -96,6 +96,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeExecutor {
/// ///
ge::Status GetDynamicBatchInfo(uint32_t model_id, std::vector<std::vector<int64_t>> &batch_info); ge::Status GetDynamicBatchInfo(uint32_t model_id, std::vector<std::vector<int64_t>> &batch_info);
ge::Status GetCurShape(const uint32_t model_id, std::vector<int64_t> &batch_info);
/// ///
/// @ingroup ge /// @ingroup ge
/// @brief Set dynamic image info /// @brief Set dynamic image info
@ -110,6 +112,9 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeExecutor {
const std::vector<kAippDynamicBatchPara> &aippBatchPara, const std::vector<kAippDynamicBatchPara> &aippBatchPara,
const kAippDynamicPara &aippParms); const kAippDynamicPara &aippParms);
ge::Status GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigInfo &aipp_info);
ge::Status GetModelAttr(uint32_t model_id, std::vector<std::string> &dynamic_output_shape_info);
ge::Status GetModelDescInfoForZeroCopy(uint32_t model_id, std::vector<ge::TensorDesc> &input_desc, ge::Status GetModelDescInfoForZeroCopy(uint32_t model_id, std::vector<ge::TensorDesc> &input_desc,
std::vector<ge::TensorDesc> &output_desc); std::vector<ge::TensorDesc> &output_desc);
@ -206,6 +211,11 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeExecutor {
static ge::Status ReleaseSingleOpResource(void *stream); static ge::Status ReleaseSingleOpResource(void *stream);
ge::Status GetBatchInfoSize(uint32_t model_id, size_t &shape_count);
ge::Status GetOrigInputInfo(uint32_t model_id, uint32_t index, OriginInputInfo &orig_input_info);
ge::Status GetAllAippInputOutputDims(uint32_t model_id, uint32_t index, std::vector<InputOutputDims> &input_dims,
std::vector<InputOutputDims> &output_dims);
private: private:
static bool isInit_; static bool isInit_;
}; };

@ -1,113 +0,0 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef INC_FRAMEWORK_GE_RUNTIME_DAVINCI_MODEL_H_
#define INC_FRAMEWORK_GE_RUNTIME_DAVINCI_MODEL_H_
#include <memory>
#include <vector>
#include "ge_runtime/op_info.h"
#include "ge_runtime/task_info.h"
namespace ge {
namespace model_runner {
class DavinciModel {
public:
DavinciModel(const std::vector<std::shared_ptr<TaskInfo>> &task_info_list,
const std::vector<std::shared_ptr<OpInfo>> &data_info_list,
const std::vector<std::shared_ptr<OpInfo>> &output_info_list,
const std::vector<std::shared_ptr<OpInfo>> &constant_info_list,
const std::vector<model_runner::OpInfoPtr> &variable_info_list,
const std::vector<uint32_t> &wait_active_stream_list,
const std::vector<uint32_t> &force_copy_stream_list, uint64_t mem_size = 0, uint64_t weight_size = 0,
uint64_t var_size = 0, uintptr_t logic_mem_base = 0, uintptr_t logic_weight_base = 0,
uintptr_t logic_var_base = 0, uint32_t stream_num = 0, uint32_t batch_num = 0, uint32_t event_num = 0,
int32_t priority = 0)
: task_info_list_(task_info_list),
data_info_list_(data_info_list),
output_info_list_(output_info_list),
constant_info_list_(constant_info_list),
variable_info_list_(variable_info_list),
wait_active_stream_list_(wait_active_stream_list),
force_copy_stream_list_(force_copy_stream_list),
mem_size_(mem_size),
weight_size_(weight_size),
var_size_(var_size),
logic_mem_base_(logic_mem_base),
logic_weight_base_(logic_weight_base),
logic_var_base_(logic_var_base),
stream_num_(stream_num),
batch_num_(batch_num),
event_num_(event_num),
priority_(priority) {}
~DavinciModel() {}
uint64_t GetMemSize() const { return mem_size_; }
uint64_t GetWeightSize() const { return weight_size_; }
uint64_t GetVarSize() const { return var_size_; }
uintptr_t GetLogicMemBase() const { return logic_mem_base_; }
uintptr_t GetLogicWeightBase() const { return logic_weight_base_; }
uintptr_t GetLogicVarBase() const { return logic_var_base_; }
uint32_t GetStreamNum() const { return stream_num_; }
uint32_t GetBatchNum() const { return batch_num_; }
uint32_t GetEventNum() const { return event_num_; }
const std::vector<uint32_t> &GetWaitActiveStreams() const { return wait_active_stream_list_; }
const std::vector<uint32_t> &GetForceCopyStreams() const { return force_copy_stream_list_; }
int32_t GetPriority() const { return priority_; }
const std::vector<std::shared_ptr<TaskInfo>> &GetTaskInfoList() const { return task_info_list_; }
const std::vector<std::shared_ptr<OpInfo>> &GetDataInfoList() const { return data_info_list_; }
const std::vector<std::shared_ptr<OpInfo>> &GetOutputInfoList() const { return output_info_list_; }
const std::vector<std::shared_ptr<OpInfo>> &GetConstantInfoList() const { return output_info_list_; }
const std::vector<model_runner::OpInfoPtr> &GetVariableInfoList() const { return variable_info_list_; }
private:
std::vector<std::shared_ptr<TaskInfo>> task_info_list_;
std::vector<std::shared_ptr<OpInfo>> data_info_list_;
std::vector<std::shared_ptr<OpInfo>> output_info_list_;
std::vector<std::shared_ptr<OpInfo>> constant_info_list_;
std::vector<model_runner::OpInfoPtr> variable_info_list_;
std::vector<uint32_t> wait_active_stream_list_;
std::vector<uint32_t> force_copy_stream_list_;
uint64_t mem_size_;
uint64_t weight_size_;
uint64_t var_size_;
uintptr_t logic_mem_base_;
uintptr_t logic_weight_base_;
uintptr_t logic_var_base_;
uint32_t stream_num_;
uint32_t batch_num_;
uint32_t event_num_;
int32_t priority_;
// Disable to copy constructor and assignment operator
DavinciModel &operator=(const DavinciModel &) = delete;
DavinciModel(const DavinciModel &) = delete;
};
} // namespace model_runner
} // namespace ge
#endif // INC_FRAMEWORK_GE_RUNTIME_DAVINCI_MODEL_H_

@ -1,58 +0,0 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef INC_FRAMEWORK_GE_RUNTIME_MODEL_RUNNER_H_
#define INC_FRAMEWORK_GE_RUNTIME_MODEL_RUNNER_H_
#include <memory>
#include <unordered_map>
#include <vector>
#include "common/ge_inner_error_codes.h"
#include "common/ge_types.h"
#include "ge_runtime/davinci_model.h"
namespace ge {
namespace model_runner {
class RuntimeModel;
class ModelRunner {
public:
static ModelRunner &Instance();
bool LoadDavinciModel(uint32_t device_id, uint64_t session_id, uint32_t model_id,
std::shared_ptr<DavinciModel> davinci_model, std::shared_ptr<ModelListener> listener);
const std::vector<uint32_t> &GetTaskIdList(uint32_t model_id) const;
bool UnloadModel(uint32_t model_id);
bool RunModel(uint32_t model_id, const InputData &input_data, OutputData *output_data);
bool GetInputOutputDescInfo(uint32_t model_id, bool zero_copy, std::vector<InputOutputDescInfo> *input_desc,
std::vector<InputOutputDescInfo> *output_desc, std::vector<uint32_t> *input_format,
std::vector<uint32_t> *output_format);
private:
ModelRunner() = default;
~ModelRunner() = default;
std::unordered_map<uint32_t, std::shared_ptr<RuntimeModel>> runtime_models_;
};
} // namespace model_runner
} // namespace ge
#endif // INC_FRAMEWORK_GE_RUNTIME_MODEL_RUNNER_H_

@ -1,72 +0,0 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef INC_FRAMEWORK_GE_RUNTIME_OP_INFO_H_
#define INC_FRAMEWORK_GE_RUNTIME_OP_INFO_H_
#include <memory>
#include <string>
#include <vector>
namespace ge {
namespace model_runner {
struct TensorInfo {
int64_t GetShapeSize() const {
int64_t res = 1;
if (dims.empty()) {
return 0;
}
for (auto dim : dims) {
res *= dim;
}
return res;
}
int64_t GetDim(uint32_t index) {
if (index >= dims.size()) {
return 0;
}
return dims[index];
}
std::vector<int64_t> dims;
uint32_t datatype;
uint32_t format;
uint32_t real_dim_cnt;
uint32_t size;
bool is_output;
};
struct OpInfo {
uint32_t index;
std::string name;
std::string type;
bool var_is_broadcast;
std::vector<uintptr_t> input_addrs;
std::vector<uintptr_t> output_addrs;
std::vector<TensorInfo> input_tensors;
std::vector<TensorInfo> output_tensors;
std::vector<TensorInfo> weight_tensors;
std::vector<std::string> src_name;
std::vector<int64_t> src_index;
std::string weight_data;
};
using TensorInfoPtr = std::shared_ptr<TensorInfo>;
using OpInfoPtr = std::shared_ptr<OpInfo>;
} // namespace model_runner
} // namespace ge
#endif // INC_FRAMEWORK_GE_RUNTIME_OP_INFO_H_

File diff suppressed because it is too large Load Diff

@ -23,6 +23,7 @@
#include <vector> #include <vector>
#include "framework/common/types.h" #include "framework/common/types.h"
#include "framework/omg/omg_inner_types.h" #include "framework/omg/omg_inner_types.h"
#include "framework/omg/parser/parser_inner_ctx.h"
#include "proto/ge_ir.pb.h" #include "proto/ge_ir.pb.h"
#include "proto/om.pb.h" #include "proto/om.pb.h"
@ -99,6 +100,11 @@ Status SetOutputNodeInfo(ge::Graph &graph, const std::string &output_type, const
Status GetOutputLeaf(ge::NodePtr node, std::vector<std::pair<ge::NodePtr, int32_t>> &output_nodes_info, Status GetOutputLeaf(ge::NodePtr node, std::vector<std::pair<ge::NodePtr, int32_t>> &output_nodes_info,
std::vector<std::string> &output_nodes_name); std::vector<std::string> &output_nodes_name);
void UpdateOmgCtxWithParserCtx();
void UpdateParserCtxWithOmgCtx();
} // namespace ge } // namespace ge
namespace domi { namespace domi {

@ -31,7 +31,7 @@
using domi::DOMI_TENSOR_ND; using domi::DOMI_TENSOR_ND;
using domi::DOMI_TENSOR_RESERVED; using domi::DOMI_TENSOR_RESERVED;
using domi::domiTensorFormat_t; using domi::domiTensorFormat_t;
using domi::FMK_TYPE_RESERVED; using domi::FRAMEWORK_RESERVED;
using domi::FrameworkType; using domi::FrameworkType;
using std::map; using std::map;
using std::string; using std::string;
@ -100,7 +100,7 @@ struct OmgContext {
std::string ddk_version; std::string ddk_version;
// preferential format used by the entire network // preferential format used by the entire network
domiTensorFormat_t net_format = DOMI_TENSOR_RESERVED; domiTensorFormat_t net_format = DOMI_TENSOR_RESERVED;
domi::FrameworkType type = domi::FMK_TYPE_RESERVED; domi::FrameworkType type = domi::FRAMEWORK_RESERVED;
RunMode run_mode = ONLY_PRE_CHECK; RunMode run_mode = ONLY_PRE_CHECK;
bool train_flag = false; bool train_flag = false;
// whether to use FP16 high precision // whether to use FP16 high precision

@ -80,6 +80,7 @@ class ComputeGraph : public std::enable_shared_from_this<ComputeGraph>, public A
Vistor<NodePtr> GetOutputNodes() const; Vistor<NodePtr> GetOutputNodes() const;
NodePtr FindNode(const std::string &name) const; NodePtr FindNode(const std::string &name) const;
NodePtr FindFirstNodeMatchType(const std::string &name) const;
// AddNode with NodePtr // AddNode with NodePtr
NodePtr AddNode(NodePtr node); NodePtr AddNode(NodePtr node);
NodePtr AddNode(OpDescPtr op); NodePtr AddNode(OpDescPtr op);
@ -235,8 +236,6 @@ class ComputeGraph : public std::enable_shared_from_this<ComputeGraph>, public A
std::vector<NodePtr> &stack); std::vector<NodePtr> &stack);
graphStatus BFSTopologicalSorting(std::vector<NodePtr> &node_vec, std::map<NodePtr, uint32_t> &map_in_edge_num, graphStatus BFSTopologicalSorting(std::vector<NodePtr> &node_vec, std::map<NodePtr, uint32_t> &map_in_edge_num,
std::deque<NodePtr> &stack); std::deque<NodePtr> &stack);
graphStatus BFSTopologicalSortingWithGroup(std::vector<NodePtr> &node_vec,
std::map<NodePtr, uint32_t> &map_in_edge_num, std::deque<NodePtr> &stack);
graphStatus CollectBreadthOutNode(const NodePtr &node, std::map<NodePtr, uint32_t> &map_in_edge_num, graphStatus CollectBreadthOutNode(const NodePtr &node, std::map<NodePtr, uint32_t> &map_in_edge_num,
std::map<string, NodePtr> &breadth_node_map); std::map<string, NodePtr> &breadth_node_map);
graphStatus TopologicalSortingGraph(); graphStatus TopologicalSortingGraph();

@ -136,6 +136,9 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAM
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AIPP; GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AIPP;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string NEW_AIPP_CONV_OP; GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string NEW_AIPP_CONV_OP;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AIPP_INPUTS;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AIPP_OUTPUTS;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SESSION_GRAPH_ID; GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SESSION_GRAPH_ID;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PARENT_GRAPH_NAME; GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PARENT_GRAPH_NAME;
@ -176,6 +179,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAM
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AUTOMIC_ADD_MEM_SIZE; GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AUTOMIC_ADD_MEM_SIZE;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STREAM_LABEL; GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STREAM_LABEL;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STREAM_CYCLE_EVENT_FLAG; GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STREAM_CYCLE_EVENT_FLAG;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DYNAMIC_OUTPUT_DIMS;
// to be deleted // to be deleted
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_TO_BE_DELETED; GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_TO_BE_DELETED;

@ -102,6 +102,9 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeTensorDesc : public AttrH
Format GetOriginFormat() const; Format GetOriginFormat() const;
void SetOriginFormat(Format originFormat); void SetOriginFormat(Format originFormat);
void SetName(const std::string &name);
const std::string GetName() const;
DataType GetDataType() const; DataType GetDataType() const;
void SetDataType(DataType dt); void SetDataType(DataType dt);

@ -22,6 +22,7 @@
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include <list>
#include "graph/anchor.h" #include "graph/anchor.h"
#include "graph/node.h" #include "graph/node.h"
#include "graph/compute_graph.h" #include "graph/compute_graph.h"
@ -111,21 +112,25 @@ enum IOType { kIn, kOut };
struct NodeIndexIO { struct NodeIndexIO {
NodeIndexIO(ge::NodePtr node, uint32_t index, IOType io_type) NodeIndexIO(ge::NodePtr node, uint32_t index, IOType io_type)
: node(std::move(node)), index(index), io_type(io_type) {} : node_(std::move(node)), index_(index), io_type_(io_type) {
if (node_ != nullptr) {
value_ = node_->GetName() + (io_type_ == kOut ? "_out_" : "_in_") + std::to_string(index_);
}
}
NodeIndexIO(ge::NodePtr node, int index, IOType io_type) NodeIndexIO(ge::NodePtr node, int index, IOType io_type)
: node(std::move(node)), index(static_cast<uint32_t>(index)), io_type(io_type) {} : node_(std::move(node)), index_(static_cast<uint32_t>(index)), io_type_(io_type) {
if (node_ != nullptr) {
value_ = node_->GetName() + (io_type_ == kOut ? "_out_" : "_in_") + std::to_string(index_);
}
}
~NodeIndexIO() {} ~NodeIndexIO() {}
NodePtr node = nullptr; NodePtr node_ = nullptr;
uint32_t index = 0; uint32_t index_ = 0;
IOType io_type = kOut; IOType io_type_ = kOut;
std::string value_;
std::string ToString() const { std::string ToString() const { return value_; }
if ((node == nullptr) || (node->GetOwnerComputeGraph() == nullptr)) {
return "";
}
return node->GetName() + (io_type == kOut ? "_out_" : "_in_") + std::to_string(index);
}
}; };
class GraphUtils { class GraphUtils {
@ -310,7 +315,7 @@ class GraphUtils {
/// @return success: GRAPH_SUCESS /// @return success: GRAPH_SUCESS
/// ///
static graphStatus GetRefMapping(const ComputeGraphPtr &graph, static graphStatus GetRefMapping(const ComputeGraphPtr &graph,
std::map<std::string, std::vector<NodeIndexIO>> &symbol_to_anchors, std::map<std::string, std::list<NodeIndexIO>> &symbol_to_anchors,
std::map<std::string, std::string> &anchor_to_symbol); std::map<std::string, std::string> &anchor_to_symbol);
/// ///
@ -340,7 +345,7 @@ class GraphUtils {
/// @return success: GRAPH_SUCESS /// @return success: GRAPH_SUCESS
/// ///
static graphStatus HandleInAnchorMapping(const NodePtr &node, static graphStatus HandleInAnchorMapping(const NodePtr &node,
std::map<std::string, std::vector<NodeIndexIO>> &symbol_to_anchors, std::map<std::string, std::list<NodeIndexIO>> &symbol_to_anchors,
std::map<std::string, std::string> &anchor_to_symbol); std::map<std::string, std::string> &anchor_to_symbol);
/// ///
@ -351,7 +356,7 @@ class GraphUtils {
/// @return success: GRAPH_SUCESS /// @return success: GRAPH_SUCESS
/// ///
static graphStatus HandleOutAnchorMapping(const NodePtr &node, static graphStatus HandleOutAnchorMapping(const NodePtr &node,
std::map<std::string, std::vector<NodeIndexIO>> &symbol_to_anchors, std::map<std::string, std::list<NodeIndexIO>> &symbol_to_anchors,
std::map<std::string, std::string> &anchor_to_symbol); std::map<std::string, std::string> &anchor_to_symbol);
/// ///
@ -362,7 +367,7 @@ class GraphUtils {
/// @return success: GRAPH_SUCESS /// @return success: GRAPH_SUCESS
/// ///
static graphStatus HandleSubgraphInput(const NodePtr &node, static graphStatus HandleSubgraphInput(const NodePtr &node,
std::map<std::string, std::vector<NodeIndexIO>> &symbol_to_anchors, std::map<std::string, std::list<NodeIndexIO>> &symbol_to_anchors,
std::map<std::string, std::string> &anchor_to_symbol); std::map<std::string, std::string> &anchor_to_symbol);
/// ///
@ -373,7 +378,7 @@ class GraphUtils {
/// @return success: GRAPH_SUCESS /// @return success: GRAPH_SUCESS
/// ///
static graphStatus HandleMergeInput(const NodePtr &node, static graphStatus HandleMergeInput(const NodePtr &node,
std::map<std::string, std::vector<NodeIndexIO>> &symbol_to_anchors, std::map<std::string, std::list<NodeIndexIO>> &symbol_to_anchors,
std::map<std::string, std::string> &anchor_to_symbol); std::map<std::string, std::string> &anchor_to_symbol);
/// ///
@ -384,7 +389,7 @@ class GraphUtils {
/// @return success: GRAPH_SUCESS /// @return success: GRAPH_SUCESS
/// ///
static graphStatus HandleSubgraphOutput(const NodePtr &node, static graphStatus HandleSubgraphOutput(const NodePtr &node,
std::map<std::string, std::vector<NodeIndexIO>> &symbol_to_anchors, std::map<std::string, std::list<NodeIndexIO>> &symbol_to_anchors,
std::map<std::string, std::string> &anchor_to_symbol); std::map<std::string, std::string> &anchor_to_symbol);
/// ///
@ -397,7 +402,7 @@ class GraphUtils {
/// @return success: GRAPH_SUCESS /// @return success: GRAPH_SUCESS
/// ///
static graphStatus UnionSymbolMapping(const NodeIndexIO &exist_node_info1, const NodeIndexIO &exist_node_info2, static graphStatus UnionSymbolMapping(const NodeIndexIO &exist_node_info1, const NodeIndexIO &exist_node_info2,
std::map<std::string, std::vector<NodeIndexIO>> &symbol_to_anchors, std::map<std::string, std::list<NodeIndexIO>> &symbol_to_anchors,
std::map<std::string, std::string> &anchor_to_symbol, std::string &symbol); std::map<std::string, std::string> &anchor_to_symbol, std::string &symbol);
/// ///
@ -409,7 +414,7 @@ class GraphUtils {
/// @return success: GRAPH_SUCESS /// @return success: GRAPH_SUCESS
/// ///
static graphStatus UpdateRefMapping(const NodeIndexIO &cur_node_info, const NodeIndexIO &exist_node_info, static graphStatus UpdateRefMapping(const NodeIndexIO &cur_node_info, const NodeIndexIO &exist_node_info,
std::map<std::string, std::vector<NodeIndexIO>> &symbol_to_anchors, std::map<std::string, std::list<NodeIndexIO>> &symbol_to_anchors,
std::map<std::string, std::string> &anchor_to_symbol); std::map<std::string, std::string> &anchor_to_symbol);
/// ///

@ -25,6 +25,7 @@
#include "graph/types.h" #include "graph/types.h"
#include "graph/usr_types.h" #include "graph/usr_types.h"
#include "register/register_types.h" #include "register/register_types.h"
#include "external/register/register_fmk_types.h"
namespace ge { namespace ge {
class TypeUtils { class TypeUtils {
@ -39,6 +40,7 @@ class TypeUtils {
static Format SerialStringToFormat(const std::string &str); static Format SerialStringToFormat(const std::string &str);
static Format DataFormatToFormat(const std::string &str); static Format DataFormatToFormat(const std::string &str);
static Format DomiFormatToFormat(domi::domiTensorFormat_t domi_format); static Format DomiFormatToFormat(domi::domiTensorFormat_t domi_format);
static std::string FmkTypeToSerialString(domi::FrameworkType fmk_type);
static graphStatus Usr2DefQuantizeFactorParams(const UsrQuantizeFactorParams &usr, QuantizeFactorParams &def); static graphStatus Usr2DefQuantizeFactorParams(const UsrQuantizeFactorParams &usr, QuantizeFactorParams &def);
static graphStatus Def2UsrQuantizeFactorParams(const QuantizeFactorParams &def, UsrQuantizeFactorParams &usr); static graphStatus Def2UsrQuantizeFactorParams(const QuantizeFactorParams &def, UsrQuantizeFactorParams &usr);

@ -48,63 +48,6 @@ bool IsUseBFS() {
} }
return false; return false;
} }
bool IsTailingOptimization() {
string is_tailing_optimization_option;
auto ret = GetContext().GetOption(ge::OPTION_EXEC_ENABLE_TAILING_OPTIMIZATION, is_tailing_optimization_option);
if (ret == GRAPH_SUCCESS) {
GELOGI("Option ge.exec.isTailingOptimization is %s", is_tailing_optimization_option.c_str());
// "1" means it's True from frontend option
return is_tailing_optimization_option == "1";
}
GELOGW("OPTION_EXEC_ENABLE_TAILING_OPTIMIZATION not set, use BFSTopologicalSorting by default.");
return false;
}
bool IsFusedNode(const NodePtr &node) {
bool is_fused_node = false;
AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_HCCL_FUSED_FLAG, is_fused_node);
return is_fused_node;
}
string GetGroupId(const NodePtr &node) {
string group_id;
AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_HCCL_FUSED_GROUP, group_id);
return group_id;
}
bool IsGroupEnd(const NodePtr &node) {
if (GetGroupId(node).empty()) {
return false;
}
if (node->GetOutDataNodesSize() == 0) {
return true;
}
for (const auto &out_data_node : node->GetOutDataNodes()) {
if (IsFusedNode(out_data_node)) {
return true;
}
}
return false;
}
void SplitNodeToStack(const std::map<string, NodePtr> &breadth_node_map, string current_group_id,
std::vector<NodePtr> &stack_input, std::deque<NodePtr> &group_stack, std::deque<NodePtr> &stack) {
for (const auto &name_node : breadth_node_map) {
// group first
string group_id;
if (AttrUtils::GetStr(name_node.second->GetOpDesc(), ATTR_NAME_HCCL_FUSED_GROUP, group_id)) {
GELOGI("current node %s, group id: %s , current group id %s", name_node.second->GetName().c_str(),
group_id.c_str(), current_group_id.c_str());
if (!current_group_id.empty() && group_id != current_group_id) {
GELOGI("node go to input_stack back: %s", name_node.second->GetName().c_str());
(void)stack_input.insert(stack_input.begin(), name_node.second);
} else {
current_group_id = group_id;
GELOGI("node go to group_stack: %s", name_node.second->GetName().c_str());
(void)group_stack.push_front(name_node.second);
}
continue;
}
GELOGI("node go to stack: %s ", name_node.second->GetName().c_str());
(void)stack.push_front(name_node.second);
}
}
} // namespace } // namespace
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ComputeGraph::ComputeGraph(const std::string &name) GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ComputeGraph::ComputeGraph(const std::string &name)
@ -193,6 +136,19 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY NodePtr ComputeGraph::FindNode(co
return nullptr; return nullptr;
} }
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY NodePtr
ComputeGraph::FindFirstNodeMatchType(const std::string &name) const {
for (const auto &node : nodes_) {
if (node == nullptr) {
continue;
}
if (node->GetType() == name) {
return node;
}
}
return nullptr;
}
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool ComputeGraph::GraphAttrsAreEqual( GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool ComputeGraph::GraphAttrsAreEqual(
const ComputeGraph &r_graph) const { const ComputeGraph &r_graph) const {
// ProtoMsgOwner <::google::protobuf::Message> is temporarily ignored // ProtoMsgOwner <::google::protobuf::Message> is temporarily ignored
@ -642,9 +598,9 @@ ComputeGraph::UpdateInputMapping(const std::map<uint32_t, uint32_t> &input_mappi
/// ///
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus
ComputeGraph::UpdateOutputMapping(const std::map<uint32_t, uint32_t> &output_mapping) { ComputeGraph::UpdateOutputMapping(const std::map<uint32_t, uint32_t> &output_mapping) {
NodePtr net_output = FindNode(NODE_NAME_NET_OUTPUT); NodePtr net_output = FindFirstNodeMatchType(NETOUTPUT);
if (net_output == nullptr) { if (net_output == nullptr) {
GE_LOGE("UpdateOutputMapping failed: node %s not exist in graph.", NODE_NAME_NET_OUTPUT); GE_LOGE("UpdateOutputMapping failed: node type %s not exist in graph.", NETOUTPUT);
return GRAPH_FAILED; return GRAPH_FAILED;
} }
OpDescPtr op_desc = net_output->GetOpDesc(); OpDescPtr op_desc = net_output->GetOpDesc();
@ -799,65 +755,6 @@ graphStatus ComputeGraph::BFSTopologicalSorting(std::vector<NodePtr> &node_vec,
return GRAPH_SUCCESS; return GRAPH_SUCCESS;
} }
graphStatus ComputeGraph::BFSTopologicalSortingWithGroup(std::vector<NodePtr> &node_vec,
std::map<NodePtr, uint32_t> &map_in_edge_num,
std::deque<NodePtr> &stack) {
GELOGI("Runing_Bfs_Sort_With_Group");
std::string current_group_id;
std::vector<NodePtr> stack_input;
std::deque<NodePtr> group_stack;
std::deque<NodePtr> fused_node_stack;
std::map<string, NodePtr> breadth_node_map;
// Record the number of non data nodes but no input nodes
GE_CHK_BOOL_EXEC(SortNodes(stack_input, map_in_edge_num) == GRAPH_SUCCESS, return GRAPH_FAILED, "sort nodes failed");
// Only data nodes here
while (!stack_input.empty() || !stack.empty() || !group_stack.empty()) {
NodePtr node = nullptr;
if (!group_stack.empty()) {
// Traversal node in group has priority
node = group_stack.back();
group_stack.pop_back();
} else if (!stack.empty()) {
node = stack.back();
stack.pop_back();
} else {
node = stack_input.back();
stack_input.pop_back();
}
if (IsFusedNode(node) && current_group_id.empty()) {
current_group_id = node->GetName();
}
if (GetGroupId(node).empty() || GetGroupId(node) == current_group_id) {
node_vec.push_back(node);
GE_CHECK_NOTNULL(node->GetOpDesc());
GELOGI("node_vec.push_back %s", node->GetOpDesc()->GetName().c_str());
} else {
if (current_group_id.empty()) {
current_group_id = GetGroupId(node);
node_vec.push_back(node);
GE_CHECK_NOTNULL(node->GetOpDesc());
GELOGI("node_vec.push_back %s", node->GetOpDesc()->GetName().c_str());
} else {
GELOGI("current group id is %s ,node go to input_stack back: %s", current_group_id.c_str(),
node->GetName().c_str());
(void)stack_input.insert(stack_input.begin(), node);
continue;
}
}
CollectBreadthOutNode(node, map_in_edge_num, breadth_node_map);
SplitNodeToStack(breadth_node_map, current_group_id, stack_input, group_stack, stack);
breadth_node_map.clear();
// check the end of group
if (IsGroupEnd(node)) {
GELOGI("Current node %s is end of group %s.", node->GetName().c_str(), current_group_id.c_str());
current_group_id = "";
}
}
return GRAPH_SUCCESS;
}
graphStatus ComputeGraph::CollectBreadthOutNode(const NodePtr &node, std::map<NodePtr, uint32_t> &map_in_edge_num, graphStatus ComputeGraph::CollectBreadthOutNode(const NodePtr &node, std::map<NodePtr, uint32_t> &map_in_edge_num,
std::map<string, NodePtr> &breadth_node_map) { std::map<string, NodePtr> &breadth_node_map) {
for (const auto &anchor : node->GetAllOutDataAnchors()) { for (const auto &anchor : node->GetAllOutDataAnchors()) {
@ -907,7 +804,11 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ComputeGraph::Topolog
} }
std::vector<std::shared_ptr<ComputeGraph>> subgraphs; std::vector<std::shared_ptr<ComputeGraph>> subgraphs;
(void)AllGraphNodes(subgraphs); auto nodes = AllGraphNodes(subgraphs);
for (size_t i = 0; i < nodes.size(); i++) {
NodePtr node = nodes.at(i); // [node: should not be null]
node->GetOpDesc()->SetId(i); // [node->GetOpDesc(): should not be null]
}
if (sub_graph_.size() != subgraphs.size()) { // Graph Partition use subgraph, Keep original if (sub_graph_.size() != subgraphs.size()) { // Graph Partition use subgraph, Keep original
GELOGW("Keep original subgraph for graph size %zu not equal %zu.", sub_graph_.size(), subgraphs.size()); GELOGW("Keep original subgraph for graph size %zu not equal %zu.", sub_graph_.size(), subgraphs.size());
return SUCCESS; return SUCCESS;
@ -920,17 +821,10 @@ graphStatus ComputeGraph::TopologicalSortingGraph() {
std::vector<NodePtr> node_vec; std::vector<NodePtr> node_vec;
std::map<NodePtr, uint32_t> map_in_edge_num; std::map<NodePtr, uint32_t> map_in_edge_num;
bool use_BFS = IsUseBFS(); bool use_BFS = IsUseBFS();
bool is_tailing_optimization = IsTailingOptimization();
if (use_BFS) { if (use_BFS) {
std::deque<NodePtr> stack; std::deque<NodePtr> stack;
if (is_tailing_optimization) { if (BFSTopologicalSorting(node_vec, map_in_edge_num, stack) != GRAPH_SUCCESS) {
if (BFSTopologicalSortingWithGroup(node_vec, map_in_edge_num, stack) != GRAPH_SUCCESS) { return GRAPH_FAILED;
return GRAPH_FAILED;
}
} else {
if (BFSTopologicalSorting(node_vec, map_in_edge_num, stack) != GRAPH_SUCCESS) {
return GRAPH_FAILED;
}
} }
} else { } else {
std::vector<NodePtr> stack; std::vector<NodePtr> stack;

@ -41,7 +41,7 @@ using namespace ge;
using namespace std; using namespace std;
namespace ge { namespace ge {
namespace { namespace {
static const std::unordered_set<string> kChangeDimNodes = {RESHAPE, PERMUTE, EXPANDDIMS, SQUEEZE}; static const std::unordered_set<string> kChangeDimNodes = {PERMUTE, EXPANDDIMS, SQUEEZE};
static bool net_format_is_nd = true; static bool net_format_is_nd = true;
static Format g_user_set_format = FORMAT_ND; static Format g_user_set_format = FORMAT_ND;
static bool is_first_infer = true; static bool is_first_infer = true;

@ -118,6 +118,9 @@ const std::string ATTR_NAME_NAN_OPT = "nan_opt";
const std::string ATTR_NAME_AIPP = "aipp"; const std::string ATTR_NAME_AIPP = "aipp";
const std::string NEW_AIPP_CONV_OP = "new_conv_op_for_aipp"; const std::string NEW_AIPP_CONV_OP = "new_conv_op_for_aipp";
const std::string ATTR_NAME_AIPP_INPUTS = "_aipp_inputs";
const std::string ATTR_NAME_AIPP_OUTPUTS = "_aipp_outputs";
const std::string ATTR_NAME_SESSION_GRAPH_ID = "_session_graph_id"; const std::string ATTR_NAME_SESSION_GRAPH_ID = "_session_graph_id";
const std::string ATTR_NAME_PARENT_GRAPH_NAME = "_parent_graph_name"; const std::string ATTR_NAME_PARENT_GRAPH_NAME = "_parent_graph_name";
@ -150,6 +153,7 @@ const std::string ATTR_NAME_STREAM_CYCLE_EVENT_FLAG = "need_stream_cycle_event";
const std::string ATTR_NAME_RTSWITCH_RECV_EVENT_ID = "rtswitch_event_id"; const std::string ATTR_NAME_RTSWITCH_RECV_EVENT_ID = "rtswitch_event_id";
const std::string ATTR_NAME_AUTOMIC_ADD_START = "automic_add_addr_start"; const std::string ATTR_NAME_AUTOMIC_ADD_START = "automic_add_addr_start";
const std::string ATTR_NAME_AUTOMIC_ADD_MEM_SIZE = "automic_add_mem_size"; const std::string ATTR_NAME_AUTOMIC_ADD_MEM_SIZE = "automic_add_mem_size";
const std::string ATTR_NAME_DYNAMIC_OUTPUT_DIMS = "_dynamic_output_dims";
// To be deleted // To be deleted
const std::string ATTR_TO_BE_DELETED = "to_be_deleted"; const std::string ATTR_TO_BE_DELETED = "to_be_deleted";
@ -1000,7 +1004,7 @@ const std::string ATTR_NAME_FUSION_TYPE_LIST = "_fusion_type_list";
const std::string ATTR_NAME_VALID_INPUT_SHAPE_LIST_LIST = "_valid_input_shape_list_list"; const std::string ATTR_NAME_VALID_INPUT_SHAPE_LIST_LIST = "_valid_input_shape_list_list";
const std::string ATTR_NAME_VALID_OUTPUT_SHAPE_LIST_LIST = "_valid_output_shape_list_list"; const std::string ATTR_NAME_VALID_OUTPUT_SHAPE_LIST_LIST = "_valid_output_shape_list_list";
const std::string ATTR_NAME_SLICE_INPUT_OFFSET_LIST_LIST = "_input_offset_list_list"; const std::string ATTR_NAME_SLICE_INPUT_OFFSET_LIST_LIST = "_input_offset_list_list";
const std::string ATTR_NAME_SLICE_OUTPUT_OFFSET_LIST_LIST = "_input_offset_list_list"; const std::string ATTR_NAME_SLICE_OUTPUT_OFFSET_LIST_LIST = "_output_offset_list_list";
// used for Horovod // used for Horovod
const std::string ATTR_INTER_EVENT_IDENTIFY = "event_id"; const std::string ATTR_INTER_EVENT_IDENTIFY = "event_id";

@ -1233,6 +1233,11 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescPtr AttrUtils::CloneOpDesc(
GELOGE(GRAPH_FAILED, "DelAttr _opt_input failed."); GELOGE(GRAPH_FAILED, "DelAttr _opt_input failed.");
} }
} }
if (!op_desc->output_name_idx_.empty()) {
op_desc->output_name_idx_.clear();
}
return op_desc; return op_desc;
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save