• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2024 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_KERNEL_ASYNC_RESIZE_ACTOR_H_
18 #define MINDSPORE_CCSRC_RUNTIME_FRAMEWORK_ACTOR_KERNEL_ASYNC_RESIZE_ACTOR_H_
19 
20 #include <vector>
21 #include <memory>
22 
23 #include "runtime/graph_scheduler/actor/actor_common.h"
24 #include "kernel/kernel.h"
25 #include "runtime/hardware/device_context.h"
26 #include "include/backend/visible.h"
27 
28 namespace mindspore {
29 namespace runtime {
30 class KernelActor;
31 
32 class BACKEND_EXPORT KernelAsyncResizeActor : public ActorBase {
33  public:
34   static std::shared_ptr<KernelAsyncResizeActor> &GetInstance();
35   ~KernelAsyncResizeActor() override = default;
36 
37   void Initialize();
38 
39   void ResizeKernelMod(OpContext<DeviceTensor> *const context, KernelActor *kernel_actor);
40 
41   void Wait();
42 
43   Future<bool> OnTaskFinish();
44 
actor_thread_id()45   const std::thread::id &actor_thread_id() const { return thread_id_; }
46 
47  private:
KernelAsyncResizeActor()48   KernelAsyncResizeActor() : ActorBase("KernelAsyncResizeActor") {}
49   DISABLE_COPY_AND_ASSIGN(KernelAsyncResizeActor);
50 
GetThreadId()51   void GetThreadId() { thread_id_ = std::this_thread::get_id(); }
52 
53   // The thread id of exclusive thread used by this actor.
54   std::thread::id thread_id_;
55 };
56 }  // namespace runtime
57 }  // namespace mindspore
58 
59 #endif  // MINDSPORE_CCSRC_RUNTIME_FRAMEWORK_ACTOR_KERNEL_ASYNC_RESIZE_ACTOR_H_
60