diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index dc64aac1..e59026a1 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -156,7 +156,12 @@ static Status AddInputs(const ComputeGraphPtr &graph, const NodePtr &node, GeTen } string op_type; - if (!AttrUtils::GetStr(tensor, kAttrOpType, op_type) || op_type.empty()) { + bool is_const = false; + (void)AttrUtils::GetBool(tensor, CONST_ATTR_NAME_INPUT, in_const); + if (is_const) { + GELOGD("Get input[%d] is const", index); + op_type = CONSTANTOP; + } else if (!AttrUtils::GetStr(tensor, kAttrOpType, op_type) || op_type.empty()) { op_type = DATA; } @@ -165,6 +170,18 @@ static Status AddInputs(const ComputeGraphPtr &graph, const NodePtr &node, GeTen if (data_op == nullptr) { return FAILED; } + if (is_const) { + ConstGeTensorPtr tensor_value; + if(!AttrUtils::GetTensor(tensor, ge::ATTR_NAME_WEIGHTS, tensor_value)) { + GELOGE(FAILED, "Get value failed, node name:%s.", tensor.GetName().c_str()); + return FAILED; + } + if(!AttrUtils::SetTensor(data_op, ge::ATTR_NAME_WEIGHTS, tensor_value)) { + GELOGE(FAILED, "Set attr ATTR_NAME_WEIGHTS fail."); + return FAILED; + } + } + (void)AttrUtils::SetBool(data_op, "_is_single_op", true); GE_CHK_BOOL_EXEC(data_op->AddInputDesc(tensor) == GRAPH_SUCCESS, return FAILED, "Add input desc fail."); @@ -557,6 +574,9 @@ Status GeGenerator::CheckForSingleOp(OpDescPtr &op_desc, const vector Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, bool is_offline) { + if (!is_offline) { + (void)AttrUtils::SetBool(op_desc, ATTR_DYNAMIC_SHAPE_SINGLE_AICPU, true); + } if (CheckForSingleOp(op_desc, inputs, outputs) != SUCCESS) { GELOGE(PARAM_INVALID, "input param is invalid when build single op!"); diff --git a/ge/graph/preprocess/graph_preprocess.cc b/ge/graph/preprocess/graph_preprocess.cc index 22ae62de..a1627536 100644 --- a/ge/graph/preprocess/graph_preprocess.cc +++ b/ge/graph/preprocess/graph_preprocess.cc @@ -1797,6 +1797,18 @@ Status GraphPrepare::PrepareOptimize() { } void GraphPrepare::TypeConversionOfConstant() { + bool is_acl_comlpile = false; + for (ge::NodePtr &n : compute_graph_->GetAllNodes()) { + // This can ensure that n is not a null pointer + // No Conversion when called by aclOpCompile + if (n->GetOpDesc()->GetType() == CONSTANT) { + (void)AttrUtils::GetBool(n->GetOpDesc(), ATTR_DYNAMIC_SHAPE_SINGLE_AICPU, is_acl_comlpile)); + if ( is_acl_comlpile) { + return; + } + } + } + if (options_.train_graph_flag) { GELOGD("trans CONSTANT to CONSTANTOP in train."); for (ge::NodePtr &n : compute_graph_->GetAllNodes()) { diff --git a/metadef b/metadef index bd2cfdfa..c85822cd 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit bd2cfdfa85a3d9dcbd7dc825f5759c7f8b3ffa9a +Subproject commit c85822cd5404e40cb4ff2bfc9483062648c13c57 diff --git a/parser b/parser index c78651fe..5bc8c38b 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit c78651fee671ac079c56d2c3ff0d0439ea82f2fa +Subproject commit 5bc8c38b37476e8f4b9391c96e4a2cca59e53d8e