• 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 #ifndef MINDSPORE_LITE_INCLUDE_KERNEL_INTERFACE_H_
17 #define MINDSPORE_LITE_INCLUDE_KERNEL_INTERFACE_H_
18 
19 #include <memory>
20 #include <vector>
21 #include "include/api/types.h"
22 #include "include/api/status.h"
23 #include "schema/model_generated.h"
24 
25 namespace mindspore {
26 namespace kernel {
27 class Kernel;
28 /// \brief KernelInterface defined customized op's interface, such as infershape, and so on.
29 class MS_API KernelInterface {
30  public:
31   /// \brief Destructor of KernelInterface.
32   virtual ~KernelInterface() = default;
33 
34   /// \brief Method to infer customized op's output shape.
35   ///
36   /// \param[in] inputs Define the input tensors of op.
37   /// \param[in] outputs Define the output tensors of op.
38   /// \param[in] primitive Define the attributes of op.
39   ///
40   /// \return  Status as a status identification of inferring.
Infer(std::vector<mindspore::MSTensor> * inputs,std::vector<mindspore::MSTensor> * outputs,const schema::Primitive * primitive)41   virtual Status Infer(std::vector<mindspore::MSTensor> *inputs, std::vector<mindspore::MSTensor> *outputs,
42                        const schema::Primitive *primitive) {
43     return kSuccess;
44   }
45 
46   /// \brief Method to infer customized op's output shape.
47   ///
48   /// \param[in] inputs Define the input tensors of op.
49   /// \param[in] outputs Define the output tensors of op.
50   /// \param[in] primitive Define the attributes of op.
51   /// \param[in] kernel Define the kernel of a certain op.
52   ///
53   /// \return  Status as a status identification of inferring.
Infer(std::vector<mindspore::MSTensor> * inputs,std::vector<mindspore::MSTensor> * outputs,const schema::Primitive * primitive,const Kernel * kernel)54   virtual Status Infer(std::vector<mindspore::MSTensor> *inputs, std::vector<mindspore::MSTensor> *outputs,
55                        const schema::Primitive *primitive, const Kernel *kernel) {
56     return Infer(inputs, outputs, primitive);
57   }
58 };
59 }  // namespace kernel
60 }  // namespace mindspore
61 
62 #endif  // MINDSPORE_LITE_INCLUDE_KERNEL_INTERFACE_H_
63