• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 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_MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_EXECUTOR_AI_CPU_DYNAMIC_KERNEL_H_
18 #define MINDSPORE_MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_EXECUTOR_AI_CPU_DYNAMIC_KERNEL_H_
19 
20 #include <string>
21 #include <memory>
22 #include "runtime/device/executor/dynamic_kernel.h"
23 #include "ir/anf.h"
24 #include "runtime/device/ascend/executor/aicpu_ext_info_handle.h"
25 
26 namespace mindspore {
27 namespace device {
28 namespace ascend {
29 class AiCpuDynamicKernel : public DynamicKernel {
30  public:
AiCpuDynamicKernel(void * stream,const CNodePtr & cnode_ptr,const std::string & args,const std::string & ext_info_data,const std::string & so_name,const std::string & kernel_name)31   AiCpuDynamicKernel(void *stream, const CNodePtr &cnode_ptr, const std::string &args, const std::string &ext_info_data,
32                      const std::string &so_name, const std::string &kernel_name)
33       : DynamicKernel(stream, cnode_ptr),
34         args_(args),
35         ext_info_data_(ext_info_data),
36         so_name_(so_name),
37         kernel_name_(kernel_name),
38         ext_info_handler_(nullptr),
39         ext_info_addr_dev_(nullptr),
40         ext_info_size_(0),
41         input_num_(0),
42         output_num_(0),
43         unknow_type_(DEPEND_IN_SHAPE) {}
44 
45   ~AiCpuDynamicKernel() override;
46 
47   void UpdateArgs() override;
48   void Execute() override;
49   void Initialize() override;
50   void PostExecute() override;
51 
52   // Get Compute Shape from ExtInfo
53   bool UpdateOutputShapeFromExtInfo();
54 
55  private:
56   std::string args_;
57   std::string ext_info_data_;
58   std::string so_name_;
59   std::string kernel_name_;
60 
61   std::shared_ptr<AicpuExtInfoHandler> ext_info_handler_;
62   void *ext_info_addr_dev_;
63   size_t ext_info_size_;
64 
65   size_t input_num_;
66   size_t output_num_;
67 
68   UnknowShapeOpType unknow_type_;
69 
70   bool UpdateInputOutputAddr();
71   bool UpdateExtInfo();
72 };
73 }  // namespace ascend
74 }  // namespace device
75 }  // namespace mindspore
76 #endif  // MINDSPORE_MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_EXECUTOR_AI_CPU_DYNAMIC_KERNEL_H_
77