Browse Source

回退 'Pull Request !886 : remove interface aclgrphInfershapeAndType'

tags/v1.2.0
王涛 Gitee 3 years ago
parent
commit
b3bd33546f
2 changed files with 51 additions and 0 deletions
  1. +41
    -0
      ge/ir_build/ge_ir_build.cc
  2. +10
    -0
      inc/external/ge/ge_ir_build.h

+ 41
- 0
ge/ir_build/ge_ir_build.cc View File

@@ -601,6 +601,47 @@ graphStatus aclgrphGetIRVersion(int *major_version, int *minor_version, int *pat
return GRAPH_SUCCESS;
}

graphStatus aclgrphInferShapeAndType(ge::Graph &graph) {
auto compute_graph = GraphUtils::GetComputeGraph(graph);
GE_CHECK_NOTNULL(compute_graph);

auto root_graph = compute_graph->GetParentGraph();
if (root_graph != nullptr) {
GELOGE(GRAPH_PARAM_INVALID, "Input param should not be subgraph");
return GRAPH_PARAM_INVALID;
}

auto ret = Impl::InferShapePrepare(compute_graph);
if (ret != GRAPH_SUCCESS) {
return ret;
}

ret = compute_graph->TopologicalSorting();
if (ret != GRAPH_SUCCESS) {
GELOGE(ret, "Acl topo logical sort failed.");
return ret;
}

ret = compute_graph->InferOriginFormat();
if (ret != GRAPH_SUCCESS) {
GELOGE(ret, "Acl InferOriginFormat failed.");
return ret;
}

for (auto &node: compute_graph->GetAllNodes()) {
graphStatus ret = ShapeRefiner::InferShapeAndType(node);
if (ret == GRAPH_PARAM_INVALID) {
GELOGW("Can not find infershape func.");
continue;
} else if (ret != GRAPH_SUCCESS) {
GELOGE(ret, "Acl infershape failed.");
return ret;
}
}

return GRAPH_SUCCESS;
}

graphStatus aclgrphDumpGraph(const ge::Graph &graph, const char *file, const size_t len) {
GE_CHECK_NOTNULL(file);



+ 10
- 0
inc/external/ge/ge_ir_build.h View File

@@ -100,6 +100,16 @@ graphStatus aclgrphSaveModel(const char *output_file, const ModelBufferData &mod
*/
graphStatus aclgrphGetIRVersion(int *major_version, int *minor_version, int *patch_version);

/**
* @ingroup AscendCL
* @brief infer shape and data type
*
* @param graph[IN] the graph ready to build
* @retval GRAPH_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
graphStatus aclgrphInferShapeAndType(ge::Graph &graph);

/**
* @ingroup AscendCL
* @brief dump graph


Loading…
Cancel
Save