diff --git a/mindspore/ccsrc/runtime/graph_scheduler/graph_scheduler.cc b/mindspore/ccsrc/runtime/graph_scheduler/graph_scheduler.cc index e865d25cb70..7306de8ccdc 100644 --- a/mindspore/ccsrc/runtime/graph_scheduler/graph_scheduler.cc +++ b/mindspore/ccsrc/runtime/graph_scheduler/graph_scheduler.cc @@ -296,7 +296,9 @@ void GraphScheduler::Clear(const ActorInfo &actor_info, const std::vectorGetAID().Name()); - actor_manager->Terminate(base_actor->GetAID()); + if (base_actor->parent_fusion_actor_ == nullptr) { + actor_manager->Terminate(base_actor->GetAID()); + } } } @@ -431,11 +433,24 @@ void GraphScheduler::BuildAndScheduleGlobalActor() { (void)actor_manager->Spawn(base_actor, false); // Create and schedule recorder actor. - auto recorder_actor = std::make_shared(); - MS_EXCEPTION_IF_NULL(recorder_actor); - recorder_aid_ = &(recorder_actor->GetAID()); - auto base_recorder_actor = static_cast(recorder_actor); - (void)actor_manager->Spawn(base_recorder_actor, true); + bool recorder_actor_need = false; +#ifndef ENABLE_SECURITY + if (profiler::ProfilerManager::GetInstance()->GetProfilingEnableFlag()) { + recorder_actor_need = true; + } +#endif +#ifdef ENABLE_DUMP_IR + if (mindspore::RecorderManager::Instance().RdrEnable()) { + recorder_actor_need = true; + } +#endif + if (recorder_actor_need) { + auto recorder_actor = std::make_shared(); + MS_EXCEPTION_IF_NULL(recorder_actor); + recorder_aid_ = &(recorder_actor->GetAID()); + auto base_recorder_actor = static_cast(recorder_actor); + (void)actor_manager->Spawn(base_recorder_actor, true); + } // Create and schedule debug actor. // debugger_actor_need is true for CPU when e2e dump is enabled and for Ascend and GPU is true when debugger or dump @@ -548,6 +563,22 @@ void GraphScheduler::Run(ActorSet *const actor_set, const std::vectorGetProfilingEnableFlag() && (recorder_aid_ == nullptr)) { + auto recorder_actor = std::make_shared(); + MS_EXCEPTION_IF_NULL(recorder_actor); + recorder_aid_ = &(recorder_actor->GetAID()); + auto base_recorder_actor = static_cast(recorder_actor); + auto actor_manager = ActorMgr::GetActorMgrRef(); + MS_EXCEPTION_IF_NULL(actor_manager); + (void)actor_manager->Spawn(base_recorder_actor, true); + if (actor_set->loop_count_actor_ != nullptr) { + actor_set->loop_count_actor_->recorder_aid_ = recorder_aid_; + } + } +#endif + // Construct OpContext. OpContext op_context; std::vector> result(1); diff --git a/tests/st/runtime/nopnode/test_runtime_optimize.py b/tests/st/runtime/nopnode/test_runtime_optimize.py deleted file mode 100644 index 233bfc33ddd..00000000000 --- a/tests/st/runtime/nopnode/test_runtime_optimize.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2022 Huawei Technologies Co., Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import numpy as np -import pytest -import mindspore -from mindspore import context, ops, nn, Tensor - - -class Net(nn.Cell): - def __init__(self): - super().__init__() - self.relu = ops.ReLU() - self.add = ops.Add() - - def construct(self, input_x): - output = self.relu(input_x) - for _ in range(200): - output = self.add(output, 1) - return output - - -@pytest.mark.level1 -@pytest.mark.platform_x86_cpu -@pytest.mark.platform_x86_gpu_training -@pytest.mark.env_onecard -def test_multi_actor_fusion(): - """ - Feature: Multi actor fusion. - Description: Test the net which is non concurrent, that can trigger the function of multi actor fusion. - Expectation: The value and shape of output are the expected values. - """ - context.set_context(mode=context.GRAPH_MODE) - x = Tensor(np.ones(2), mindspore.float32) - net = Net() - expect = np.array([201, 201]) - for _ in range(20): - output = net(x) - assert (output.asnumpy() == expect).all() diff --git a/tests/st/runtime/nopnode/test_eliminate_nopnode.py b/tests/st/runtime/test_eliminate_nopnode.py similarity index 100% rename from tests/st/runtime/nopnode/test_eliminate_nopnode.py rename to tests/st/runtime/test_eliminate_nopnode.py