From 63e5be23559b6ed88889acf4935d33c8c23560fd Mon Sep 17 00:00:00 2001 From: yanqingshang Date: Sat, 3 Dec 2022 16:39:41 +0800 Subject: [PATCH] so split for lite --- tf_adapter/kernels/aicpu/dataset_function.cc | 3 ++- tf_adapter/kernels/geop_npu.cc | 7 ++++--- tf_adapter/tests/depends/ge_runner/src/ge_runner_stub.cc | 2 +- tf_adapter_2.x/npu_device/core/npu_device.cpp | 3 ++- tf_adapter_2.x/tests/stub/ge_stub.cpp | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tf_adapter/kernels/aicpu/dataset_function.cc b/tf_adapter/kernels/aicpu/dataset_function.cc index e0bf7903b..eded09096 100644 --- a/tf_adapter/kernels/aicpu/dataset_function.cc +++ b/tf_adapter/kernels/aicpu/dataset_function.cc @@ -48,6 +48,7 @@ #include "tf_adapter/util/infershape_util.h" #include "tf_adapter/util/ge_plugin.h" #include "graph/utils/graph_utils.h" +#include "graph/utils/graph_utils_ex.h" #include "graph/compute_graph.h" #include "graph/op_desc.h" #include "runtime/dev.h" @@ -545,7 +546,7 @@ Status DatasetFunction::CreateGeGraph(const std::shared_ptr & DumpGeComputeGraph(std::string("Build"), funcName_, compute_graph); - ge_graph_ = ge::GraphUtils::CreateGraphFromComputeGraph(compute_graph); + ge_graph_ = ge::GraphUtilsEx::CreateGraphFromComputeGraph(compute_graph); return Status::OK(); } diff --git a/tf_adapter/kernels/geop_npu.cc b/tf_adapter/kernels/geop_npu.cc index b87902a0b..8b40f8c09 100644 --- a/tf_adapter/kernels/geop_npu.cc +++ b/tf_adapter/kernels/geop_npu.cc @@ -69,6 +69,7 @@ #include "graph/ascend_string.h" #include "graph/utils/graph_utils.h" +#include "graph/utils/graph_utils_ex.h" #include "graph/utils/node_adapter.h" #include "graph/compute_graph.h" #include "graph/ge_attr_value.h" @@ -847,7 +848,7 @@ void GeOp::ComputeAsync(OpKernelContext *ctx, DoneCallback done) { if (graph_options_.count("input_format") != 0) { ADP_LOG(INFO) << "graph_options_[\"input_format\"] = " << graph_options_["input_format"]; } - ge::Graph ge_graph = ge::GraphUtils::CreateGraphFromComputeGraph(compute_graph); + ge::Graph ge_graph = ge::GraphUtilsEx::CreateGraphFromComputeGraph(compute_graph); if (iteration_per_loop_ > 1) { ge_graph.SetNeedIteration(this->need_iteration_); } @@ -1334,7 +1335,7 @@ Status GeOp::ParseOnnxGraphOpAttr(Node *&node) const { } ge::Model onnx_model("onnx_compute_model_" + node->name(), ""); - onnx_model.SetGraph(sub_graph); + onnx_model.SetGraph(ge::GraphUtilsEx::GetComputeGraph(sub_graph)); ge::Buffer model_buf; NPU_REQUIRES(onnx_model.Save(model_buf, false) == ge::SUCCESS, errors::Internal("[GEOP] node:", node->name(), " Onnx Model Serialized Failed.")); @@ -1547,7 +1548,7 @@ int GeOp::RunTuning(std::vector &input_vec, std::vector &inp ADP_LOG(INFO) << "[GEOP] Tensorflow graph parse to ge graph success."; // convert to ge::graph - ge::Graph ge_graph = ge::GraphUtils::CreateGraphFromComputeGraph(compute_graph); + ge::Graph ge_graph = ge::GraphUtilsEx::CreateGraphFromComputeGraph(compute_graph); if (iteration_per_loop_ > 1) { ge_graph.SetNeedIteration(this->need_iteration_); } diff --git a/tf_adapter/tests/depends/ge_runner/src/ge_runner_stub.cc b/tf_adapter/tests/depends/ge_runner/src/ge_runner_stub.cc index f18814e85..7b9863acd 100644 --- a/tf_adapter/tests/depends/ge_runner/src/ge_runner_stub.cc +++ b/tf_adapter/tests/depends/ge_runner/src/ge_runner_stub.cc @@ -360,7 +360,7 @@ size_t ComputeGraph::GetAllNodesSize() const { Graph::Graph(const std::string& grph) {} Graph::Graph(char const* name) {} -Graph GraphUtils::CreateGraphFromComputeGraph(const ComputeGraphPtr compute_graph) { return Graph("ge"); } +Graph GraphUtilsEx::CreateGraphFromComputeGraph(const ComputeGraphPtr compute_graph) { return Graph("ge"); } void GraphUtils::DumpGEGraph(const ComputeGraphPtr &graph, const std::string &suffix, diff --git a/tf_adapter_2.x/npu_device/core/npu_device.cpp b/tf_adapter_2.x/npu_device/core/npu_device.cpp index cc0173763..6aee8c77b 100644 --- a/tf_adapter_2.x/npu_device/core/npu_device.cpp +++ b/tf_adapter_2.x/npu_device/core/npu_device.cpp @@ -30,6 +30,7 @@ #include "npu_managed_buffer.h" #include "npu_tensor.h" #include "npu_utils.h" +#include "graph/utils/graph_utils_ex.h" #include "optimizers/npu_optimizer_manager.h" @@ -983,7 +984,7 @@ tensorflow::Status NpuDevice::TransTfGraph2GeGraph(TFE_Context *context, const s tensorflow::errors::Internal("NPU Parse tensorflow model failed")); if (ge_compute_graph->GetAllNodesSize() != 0) { - ge_graph = ge::GraphUtils::CreateGraphFromComputeGraph(ge_compute_graph); + ge_graph = ge::GraphUtilsEx::CreateGraphFromComputeGraph(ge_compute_graph); } return tensorflow::Status::OK(); diff --git a/tf_adapter_2.x/tests/stub/ge_stub.cpp b/tf_adapter_2.x/tests/stub/ge_stub.cpp index 32716883c..48a717cdc 100644 --- a/tf_adapter_2.x/tests/stub/ge_stub.cpp +++ b/tf_adapter_2.x/tests/stub/ge_stub.cpp @@ -16,7 +16,7 @@ limitations under the License. #include "ge/ge_api.h" namespace ge { -Graph GraphUtils::CreateGraphFromComputeGraph(const ge::ComputeGraphPtr compute_graph) { +Graph GraphUtilsEx::CreateGraphFromComputeGraph(const ge::ComputeGraphPtr compute_graph) { Graph graph; graph.graph = compute_graph->graph; return graph; -- Gitee