Class MSKernel
Defined in File kernel_api.h
Inheritance Relationships
Derived Types
public mindspore::kernel::IKernel< schema::Primitive >
(Template Class IKernel)public mindspore::kernel::IKernel< Primitive >
(Template Class IKernel)
Class Documentation
-
class MSKernel
The Kernel class is used to define a MindSpore Kernel.
Subclassed by mindspore::kernel::IKernel< schema::Primitive >, mindspore::kernel::IKernel< Primitive >
Public Functions
-
inline MSKernel(std::vector<mindspore::MSTensor> inputs, std::vector<mindspore::MSTensor> outputs, const mindspore::Context *ctx)
Constructor.
- Parameters
inputs – [in] define the input tensors for kernel.
outputs – [in] define the output tensors for kernel.
primitive – [in] define the primitive of kernel.
ctx – [in] define the context for kernel.
-
virtual ~MSKernel() = default
Destructor.
-
inline virtual int InferShape()
infer shape, datatype and format for output tensor of kernel.
- Returns
result code.
-
virtual int Prepare() = 0
prepare for executing kernel.
- Returns
result code.
-
virtual int Execute() = 0
execute the kernel.
- Returns
result code.
-
virtual int ReSize() = 0
resize the kernel input shape, memory need to refresh.
- Returns
result code.
-
inline virtual void set_inputs(const std::vector<mindspore::MSTensor> &in_tensors)
set kernel's input tensors.
- Parameters
in_tensors – [in] define the input tensors.
-
inline virtual void set_input(mindspore::MSTensor in_tensor, int index)
set kernel's input tensor.
- Parameters
in_tensor – [in] define the input tensor.
index – [in] define the index of the input tensor.
-
inline virtual void set_outputs(const std::vector<mindspore::MSTensor> &out_tensors)
set kernel's output tensors.
- Parameters
out_tensors – [in] define the output tensors.
-
inline virtual void set_output(mindspore::MSTensor out_tensor, int index)
set kernel's output tensor.
- Parameters
out_tensor – [in] define the output tensor.
index – [in] define the index of the output tensor.
-
inline virtual const std::vector<mindspore::MSTensor> &inputs()
obtain kernel's input tensors.
- Returns
input tensors.
-
inline virtual const std::vector<mindspore::MSTensor> &outputs()
obtain kernel's output tensors.
- Returns
output tensors.
-
inline virtual std::string name() const
obtain kernel's name.
- Returns
kernel's name.
-
inline void set_name(const std::string &name)
set kernel's name.
- Parameters
name – [in] define the kernel's name.
-
inline const mindspore::Context *context() const
obtain kernel's context.
- Returns
kernel's context.
-
inline std::string GetAttr(const std::string &key) const
get kernel's attribute.
- Parameters
key – [in] define the kernel's attribute key.
-
inline void SetConfig(const std::map<std::string, std::map<std::string, std::string>> *config)
set kernel's config.
- Parameters
config – [in] define the kernel's config.
-
inline std::map<std::string, std::string> GetConfig(const std::string §ion) const
set kernel's config.
- Parameters
section – [in] define the section of the kernel's config.
-
inline MSKernel(std::vector<mindspore::MSTensor> inputs, std::vector<mindspore::MSTensor> outputs, const mindspore::Context *ctx)