Extension Library

Inference Engine provides an InferenceEngine::IExtension interface, which defines the interface for Inference Engine Extension libraries. All extension libraries should be inherited from this interface.

Based on that, declaration of an extension class can look as follows:

namespace TemplateExtension {
class Extension : public InferenceEngine::IExtension {
Extension() = default;
void GetVersion(const InferenceEngine::Version*& versionInfo) const noexcept override;
void Unload() noexcept override {}
void Release() noexcept override { delete this; }
std::map<std::string, ngraph::OpSet> getOpSets() override;
std::vector<std::string> getImplTypes(const std::shared_ptr<ngraph::Node>& node) override;
InferenceEngine::ILayerImpl::Ptr getImplementation(const std::shared_ptr<ngraph::Node>& node, const std::string& implType) override;
} // namespace TemplateExtension

The extension library should contain and export the method InferenceEngine::CreateExtension, which creates an Extension class:

// Exported function
INFERENCE_EXTENSION_API(InferenceEngine::StatusCode) InferenceEngine::CreateExtension(InferenceEngine::IExtension *&ext,
InferenceEngine::ResponseDesc *resp) noexcept {
try {
ext = new Extension();
return OK;
} catch (std::exception &ex) {
if (resp) {
std::string err = ((std::string) "Couldn't create extension: ") + ex.what();
err.copy(resp->msg, 255);
return InferenceEngine::GENERAL_ERROR;

Also, an Extension object should implement the following methods:

void Extension::GetVersion(const InferenceEngine::Version *&versionInfo) const noexcept {
static InferenceEngine::Version ExtensionDescription = {
{1, 0}, // extension API version
"template_ext" // extension description message
versionInfo = &ExtensionDescription;

Implement the InferenceEngine::IExtension::getOpSets method if the extension contains custom layers. Read the guide about custom operations for more information.

To understand how integrate execution kernels to the extension library, read the guide about development of custom CPU kernels.