• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "runtime/framework/actor/actor_common.h"
23 #include "runtime/framework/device_tensor_store.h"
24 #include "runtime/hardware/device_context.h"
25 #include "profiler/device/profiling.h"
26 
27 namespace mindspore {
28 namespace runtime {
29 using mindspore::device::DeviceContext;
30 using mindspore::kernel::KernelLaunchInfo;
31 
32 // The recorder actor is used to record kernel info.
33 class RecorderActor : public ActorBase {
34  public:
RecorderActor()35   RecorderActor() : ActorBase("RecorderActor") {}
36   ~RecorderActor() override = default;
37 
38   // The memory recorder of each node.
39   void RecordInfo(const std::string op_name, const KernelLaunchInfo *launch_info_, const DeviceContext *device_context,
40                   OpContext<DeviceTensor> *const op_context);
41 
42   // Clear memory recorder at the step end.
43   // Record fp_start and iter_end op name and timestamp at the step end. (GPU)
44   void RecordOnStepEnd(OpContext<DeviceTensor> *const op_context);
45 };
46 }  // namespace runtime
47 }  // namespace mindspore
48 
49 #endif  // MINDSPORE_CCSRC_RUNTIME_FRAMEWORK_ACTOR_RECORDER_ACTOR_H_
50