1 /** 2 * Copyright 2021 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_CCSRC_RUNTIME_FRAMEWORK_ACTOR_RECORDER_ACTOR_H_ 18 #define MINDSPORE_CCSRC_RUNTIME_FRAMEWORK_ACTOR_RECORDER_ACTOR_H_ 19 20 #include <memory> 21 #include <string> 22 #include <vector> 23 #include "runtime/graph_scheduler/actor/actor_common.h" 24 #include "runtime/graph_scheduler/device_tensor_store.h" 25 #include "runtime/hardware/device_context.h" 26 #include "include/backend/debug/profiler/profiling.h" 27 #include "kernel/kernel.h" 28 29 namespace mindspore { 30 namespace runtime { 31 using mindspore::device::DeviceContext; 32 using mindspore::kernel::KernelLaunchAddr; 33 using mindspore::kernel::KernelTensor; 34 35 // The recorder actor is used to record kernel info. 36 class RecorderActor : public ActorBase { 37 public: RecorderActor()38 RecorderActor() : ActorBase("RecorderActor") {} 39 ~RecorderActor() override = default; 40 41 // The memory recorder of each node. 42 void RecordInfo(const std::string op_name, const KernelLaunchAddr *launch_info, const DeviceContext *device_context, 43 OpContext<DeviceTensor> *const op_context); 44 45 // Clear memory recorder at the step end. 46 // Record fp_start and iter_end op name and timestamp at the step end. (GPU) 47 void RecordOnStepEnd(OpContext<DeviceTensor> *const op_context); 48 }; 49 } // namespace runtime 50 } // namespace mindspore 51 52 #endif // MINDSPORE_CCSRC_RUNTIME_FRAMEWORK_ACTOR_RECORDER_ACTOR_H_ 53