class ov::frontend::FrontEnd

Overview

An interface for identifying a frontend for a particular framework. Provides an ability to load and convert of input model. More…

#include <frontend.hpp>

class FrontEnd
{
public:
    // typedefs

    typedef std::shared_ptr<FrontEnd> Ptr;

    // construction

    FrontEnd();
    FrontEnd(const FrontEnd&);
    FrontEnd(FrontEnd&&);

    // methods

    FrontEnd& operator = (const FrontEnd&);
    FrontEnd& operator = (FrontEnd&&);

    template <typename... Types>
    bool supported(const Types&... vars) const;

    bool supported(const ov::AnyVector& vars) const;

    template <typename... Types>
    InputModel::Ptr load(const Types&... vars) const;

    InputModel::Ptr load(const ov::AnyVector& vars) const;
    virtual std::shared_ptr<ov::Model> convert(const InputModel::Ptr& model) const;
    virtual void convert(const std::shared_ptr<ov::Model>& partially_converted) const;
    virtual std::shared_ptr<ov::Model> convert_partially(const InputModel::Ptr& model) const;
    virtual std::shared_ptr<ov::Model> decode(const InputModel::Ptr& model) const;
    virtual void normalize(const std::shared_ptr<ov::Model>& model) const;
    virtual std::string get_name() const;
    virtual void add_extension(const std::shared_ptr<ov::Extension>& extension);
    void add_extension(const std::vector<std::shared_ptr<ov::Extension>>& extensions);
    void add_extension(const std::string& library_path);

    template <
        class T,
        typename std::enable_if<std::is_base_of<ov::Extension, T>::value, bool>::type = true
        >
    void add_extension(const T& extension);

    template <
        class T,
        class... Targs,
        typename std::enable_if<std::is_base_of<ov::Extension, T>::value, bool>::type = true
        >
    void add_extension(
        const T& extension,
        Targs... args
        );

    bool supported(const std::vector<ov::Any>& variants) const;
};

Detailed Documentation

An interface for identifying a frontend for a particular framework. Provides an ability to load and convert of input model.

Construction

FrontEnd()

Default constructor.

Methods

template <typename... Types>
bool supported(const Types&... vars) const

Validates if FrontEnd can recognize model with parameters specified. Same parameters should be used to load model.

Parameters:

vars

Any number of parameters of any type. What kind of parameters are accepted is determined by each FrontEnd individually, typically it is std::string containing path to the model file. For more information please refer to specific FrontEnd documentation.

Returns:

true if model recognized, false - otherwise.

template <typename... Types>
InputModel::Ptr load(const Types&... vars) const

Loads an input model by any specified arguments. Each FrontEnd separately defines what arguments it can accept.

Parameters:

vars

Any number of parameters of any type. What kind of parameters are accepted is determined by each FrontEnd individually, typically it is std::string containing path to the model file. For more information please refer to specific FrontEnd documentation.

Returns:

Loaded input model.

virtual std::shared_ptr<ov::Model> convert(const InputModel::Ptr& model) const

Completely convert and normalize entire Model, throws if it is not possible.

Parameters:

model

Input model

Returns:

fully converted OV Model

virtual void convert(const std::shared_ptr<ov::Model>& partially_converted) const

Completely convert the remaining, not converted part of a Model.

Parameters:

partiallyConverted

partially converted OV Model

virtual std::shared_ptr<ov::Model> convert_partially(const InputModel::Ptr& model) const

Convert only those parts of the model that can be converted leaving others as-is wrapped by FrameworkNode. Converted parts are normalized by additional transformations like it is done in convert method. If part of the graph cannot be converted, it is not guaranteed that the converted regions are completely normalized. Normalize should be called for each completely converted parts individually in this case.

Parameters:

model

Input model

Returns:

partially converted OV Model

virtual std::shared_ptr<ov::Model> decode(const InputModel::Ptr& model) const

Convert operations with one-to-one mapping with decoding nodes. Each decoding node is an OV node representing a single FW operation node with all attributes represented in FW-independent way.

Parameters:

model

Input model

Returns:

OV Model after decoding

virtual void normalize(const std::shared_ptr<ov::Model>& model) const

Runs normalization passes on Model that was loaded with partial conversion.

Parameters:

Model

partially converted OV Model

virtual std::string get_name() const

Gets name of this FrontEnd. Can be used by clients if frontend is selected automatically by FrontEndManager::load_by_model.

Returns:

Current frontend name. Empty string if not implemented

virtual void add_extension(const std::shared_ptr<ov::Extension>& extension)

Register base extension in the FrontEnd.

Parameters:

extension

base extension

void add_extension(const std::vector<std::shared_ptr<ov::Extension>>& extensions)

Register base extensions in the FrontEnd.

Parameters:

extensions

vector of extensions

void add_extension(const std::string& library_path)

Registers extension.

Parameters:

library_path

path to library with ov::Extension

template <
    class T,
    typename std::enable_if<std::is_base_of<ov::Extension, T>::value, bool>::type = true
    >
void add_extension(const T& extension)

Registers extension.

Parameters:

extension

Extension class which is inherited from ov::BaseOpExtension class

template <
    class T,
    class... Targs,
    typename std::enable_if<std::is_base_of<ov::Extension, T>::value, bool>::type = true
    >
void add_extension(
    const T& extension,
    Targs... args
    )

Registers extensions.

Parameters:

extension

Extension class which is inherited from ov::Extension class