class ov::pass::Manager

Overview

Manager class allows to manage transformation passes. More…

#include <manager.hpp>

class Manager
{
public:
    // construction

    Manager();
    Manager(std::shared_ptr<PassConfig> pass_config);

    // methods

    template <typename T, bool Enable = true, class... Args>
    std::shared_ptr<T> register_pass(Args&&... args);

    std::shared_ptr<PassBase> register_pass_instance(std::shared_ptr<PassBase> pass);
    void run_passes(std::shared_ptr<Model>);
    void set_pass_visualization(bool new_state);
    void set_per_pass_validation(bool new_state);
    void set_callback(const param_callback& callback);
    std::shared_ptr<PassConfig> get_pass_config();
};

Detailed Documentation

Manager class allows to manage transformation passes.

Methods

template <typename T, bool Enable = true, class... Args>
std::shared_ptr<T> register_pass(Args&&... args)

Register given transformation class type to execution list Example below show the basic usage of pass::Manager.

pass::Manager manager;
manager.register_pass<MyTransformation>(/\*transformation constructor ars\*&zwj;/);
manager.run_passes(f);

For some purposes transformation can be registered and disabled by default.

manager.register_pass<MyTransformation, false>();

Returns:

shared_ptr to the transformation instance

void set_per_pass_validation(bool new_state)

Set flag to enable/disable running Validate pass after executing each registered pass.

Parameters:

new_state

Value “true” enables Validate pass run; “false”, otherwise

void set_callback(const param_callback& callback)

Callback is a lambda function that can be used by registered transformations. The main purpose of this callback is to provide a way for plugins to disable/enable transformations based on some conditions. In some cases plugins may want not to execute some transformations. For example plugin can disable unpleasant decompositions because of performance reasons for some cases. Callback example: auto callback = [](const std::shared_ptr<const ov::Node> & node) -> bool { return std::dynamic_pointer_cast<const ov::opset3::DepthToSpace>(node) != nullptr; }; This callback returns true in case of DepthToSpace operation. So when execution DepthToSpace decomposition pass will check is this decomposition needed or plugin can execute this operation directly. And of course on transformation side we need to have a response for this callback. if (transformation_callback(batch_to_space)) { return false; }.

Parameters:

callback

lamda function that returns true in case if node is supported by plugin and transformation is not needed

std::shared_ptr<PassConfig> get_pass_config()

Returns:

PassConfig shared object. This object is used for transformations pipeline configuration. This object allows to disable/enable transformations execution, set callback to particular transformation. For mo details see PassConfig class.