From 861c917011aeb5702a418540b794cf7890e1938f Mon Sep 17 00:00:00 2001 From: lvliang Date: Tue, 28 Jul 2020 21:24:43 +0800 Subject: [PATCH] pynative-add-attr-info-into-cache-key --- mindspore/ccsrc/pipeline/jit/pipeline.cc | 1 + mindspore/ccsrc/pipeline/pynative/pynative_execute.cc | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mindspore/ccsrc/pipeline/jit/pipeline.cc b/mindspore/ccsrc/pipeline/jit/pipeline.cc index dee864d085e..42539f27edb 100644 --- a/mindspore/ccsrc/pipeline/jit/pipeline.cc +++ b/mindspore/ccsrc/pipeline/jit/pipeline.cc @@ -262,6 +262,7 @@ void ExecutorPy::DelNetRes(const std::string &id) { for (auto &item : tmp_info) { if (item.first.find(id) != string::npos) { MS_LOG(DEBUG) << "Delete network res:" << item.first; + item.second = nullptr; (void)info_.erase(item.first); flag = true; } diff --git a/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc b/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc index 092e0e1b596..34e637cef26 100644 --- a/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc +++ b/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc @@ -347,6 +347,11 @@ std::string GetSingleOpGraphInfo(const OpExecInfoPtr &op_exec_info, MS_EXCEPTION_IF_NULL(op_exec_info->abstract); (void)graph_info.append(std::to_string((uintptr_t)(op_exec_info->py_primitive.get())) + "_" + op_exec_info->abstract->ToString()); + // get attr info + auto attr_map = op_exec_info->py_primitive->evaluate_added_attrs(); + for (const auto &element : attr_map) { + (void)graph_info.append(element.second->ToString() + " "); + } return graph_info; } @@ -407,7 +412,9 @@ bool RunOpConvertConstInputToAttr(const py::object &input_object, size_t input_i ValuePtr value = parse::data_converter::PyDataToValue(input_object); MS_EXCEPTION_IF_NULL(value); auto input_name = input_names_vec[input_index]; - op_prim->set_attr(input_name, value); + op_prim->BeginRecordAddAttr(); + op_prim->AddAttr(input_name, value); + op_prim->EndRecordAddAttr(); return true; } return false;