diff --git a/mindspore/lite/include/kernel_interface.h b/mindspore/lite/include/kernel_interface.h index c1d9e6ec25..182e482e4c 100644 --- a/mindspore/lite/include/kernel_interface.h +++ b/mindspore/lite/include/kernel_interface.h @@ -25,6 +25,7 @@ namespace mindspore { namespace kernel { +class Kernel; /// \brief KernelInterface defined customized op's interface, such as infershape, and so on. class MS_API KernelInterface { public: @@ -42,6 +43,19 @@ class MS_API KernelInterface { const schema::Primitive *primitive) { return kSuccess; } + + /// \brief Method to infer customized op's output shape. + /// + /// \param[in] inputs Define the input tensors of op. + /// \param[in] outputs Define the output tensors of op. + /// \param[in] primitive Define the attributes of op. + /// \param[in] kernel Define the kernel of a certain op. + /// + /// \return Status as a status identification of inferring. + virtual Status Infer(std::vector *inputs, std::vector *outputs, + const schema::Primitive *primitive, const Kernel *kernel) { + return Infer(inputs, outputs, primitive); + } }; } // namespace kernel } // namespace mindspore diff --git a/mindspore/lite/src/runtime/infer_manager.cc b/mindspore/lite/src/runtime/infer_manager.cc index c188f20203..959c538846 100644 --- a/mindspore/lite/src/runtime/infer_manager.cc +++ b/mindspore/lite/src/runtime/infer_manager.cc @@ -70,7 +70,8 @@ int KernelInferShape(const std::vector &inputs, const std::vecto std::vector out_tensors; std::transform(outputs.begin(), outputs.end(), std::back_inserter(out_tensors), [](lite::Tensor *tensor) { return mindspore::MSTensor(std::make_shared(tensor)); }); - auto ret = kernel_interface->Infer(&in_tensors, &out_tensors, static_cast(primitive)); + auto ret = + kernel_interface->Infer(&in_tensors, &out_tensors, static_cast(primitive), kernel); if (ret == kLiteInferInvalid) { return RET_INFER_INVALID; }