From 5aab9d2e660c4d565693e43e06e87fee287e06b1 Mon Sep 17 00:00:00 2001 From: Zhang Qinghua Date: Wed, 19 Jan 2022 14:10:51 +0800 Subject: [PATCH] Always set tuple/list elements as used if it's the arguements of VirtualAbstractClosure, likely J's bprop func. --- mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc b/mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc index ad9bb2e395d..7dc08fdbf2f 100644 --- a/mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc +++ b/mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc @@ -569,9 +569,17 @@ EvalResultPtr VirtualEvaluator::Eval(AnalysisEnginePtr, const AbstractBasePtrLis MS_LOG(EXCEPTION) << "Arguments mismatch, parameters no: " << args_spec_list_.size() << ", arguments no: " << args_spec_list.size(); } + static const auto eliminate_unused_element = common::GetEnv("MS_DEV_ENABLE_DDE"); + static const auto enable_eliminate_unused_element = (eliminate_unused_element != "0"); // Check each parameter and argument match; for (std::size_t i = 0; i < args_spec_list.size(); i++) { MS_EXCEPTION_IF_NULL(args_spec_list[i]); + // For VirtualAbstractClosure, likely J's bprop, we just set its tuple arguments as used before really grad. + if (enable_eliminate_unused_element && args_spec_list[i]->isa()) { + MS_LOG(INFO) << "Notice: For VirtualAbstractClosure, update all use flags as true for arguments[" << i + << "]: " << args_spec_list[i]->ToString(); + SetSequenceElementsUseFlagsRecursively(args_spec_list[i], true); + } (void)args_spec_list[i]->Join(args_spec_list_[i]); } return std::make_shared(output_, std::make_shared());