• 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_LITE_INCLUDE_KERNEL_H
18 #define MINDSPORE_LITE_INCLUDE_KERNEL_H
19 #include <vector>
20 #include <string>
21 #include <utility>
22 #include <map>
23 #include "schema/model_generated.h"
24 #include "include/api/types.h"
25 #include "include/api/context.h"
26 #include "include/api/kernel_api.h"
27 
28 namespace mindspore::kernel {
29 class MS_API Kernel : public IKernel<schema::Primitive> {
30  public:
31   Kernel() = default;
Kernel(const std::vector<mindspore::MSTensor> & inputs,const std::vector<mindspore::MSTensor> & outputs,const schema::Primitive * primitive,const mindspore::Context * ctx)32   Kernel(const std::vector<mindspore::MSTensor> &inputs, const std::vector<mindspore::MSTensor> &outputs,
33          const schema::Primitive *primitive, const mindspore::Context *ctx)
34       : IKernel<schema::Primitive>(inputs, outputs, primitive, ctx) {
35     Initialize();
36   }
37   virtual ~Kernel() = default;
38 
39   int InferShape() override;
40   /// \brief obtain kernel's type.
41   ///
42   /// \return kernel's type.
type()43   virtual schema::PrimitiveType type() const { return type_; }
44   /// \brief obtain kernel's quant type.
45   ///
46   /// \return kernel's quant type.
quant_type()47   virtual schema::QuantType quant_type() const { return quant_type_; }
48   /// \brief obtain the primitive of kernel generated by flatbuffers.
49  protected:
50   void Initialize();
51 
52  protected:
53   schema::PrimitiveType type_ = schema::PrimitiveType_NONE;
54   schema::QuantType quant_type_ = schema::QuantType_QUANT_NONE;
55 };
56 }  // namespace mindspore::kernel
57 
58 #endif  // MINDSPORE_LITE_INCLUDE_KERNEL_H
59