class ov::preprocess::PostProcessSteps

Overview

Postprocessing steps. Each step typically intends adding of some operation to output parameter User application can specify sequence of postprocessing steps in a builder-like manner. More…

#include <postprocess_steps.hpp>

class PostProcessSteps
{
public:
    // typedefs

    typedef std::function<ov::Output<ov::Node>(const ov::Output<ov::Node>&node)> CustomPostprocessOp;

    // methods

    PostProcessSteps& convert_element_type(const ov::element::Type& type = {});
    PostProcessSteps& convert_layout(const Layout& dst_layout = {});
    PostProcessSteps& convert_layout(const std::vector<uint64_t>& dims);
    PostProcessSteps& custom(const CustomPostprocessOp& postprocess_cb);
};

Detailed Documentation

Postprocessing steps. Each step typically intends adding of some operation to output parameter User application can specify sequence of postprocessing steps in a builder-like manner.

auto proc = PrePostProcessor(function);
proc.output().postprocess().convert_element_type(element::u8);
function = proc.build();

Typedefs

typedef std::function<ov::Output<ov::Node>(const ov::Output<ov::Node>&node)> CustomPostprocessOp

Signature for custom postprocessing operation. Custom postprocessing operation takes one output node and produces one output node. For more advanced cases, client’s code can use transformation passes over ov::Model directly.

Parameters:

node

Output node for custom post-processing operation

Returns:

New node after applying custom post-processing operation

Methods

PostProcessSteps& convert_element_type(const ov::element::Type& type = {})

Add convert element type post-process operation.

Parameters:

type

Desired type of output. If not specified, type will be obtained from ‘tensor’ output information

Returns:

Reference to ‘this’ to allow chaining with other calls in a builder-like manner

PostProcessSteps& convert_layout(const Layout& dst_layout = {})

Add ‘convert layout’ operation to specified layout.

Adds appropriate ‘transpose’ operation between model layout and user’s desired layout. Current implementation requires source and destination layout to have same number of dimensions

Example: when model data has output in ‘NCHW’ layout ([1, 3, 224, 224]) but user needs interleaved output image (‘NHWC’, [1, 224, 224, 3]). Post-processing may look like this:

auto proc = PrePostProcessor(function);
proc.output().model(OutputTensorInfo().set_layout("NCHW"); // model output is NCHW
proc.output().postprocess().convert_layout("NHWC"); // User needs output as NHWC

Parameters:

dst_layout

New layout after conversion. If not specified - destination layout is obtained from appropriate tensor output properties.

Returns:

Reference to ‘this’ to allow chaining with other calls in a builder-like manner.

PostProcessSteps& convert_layout(const std::vector<uint64_t>& dims)

Add convert layout operation by direct specification of transposed dimensions.

Example: model produces output with shape [1, 3, 480, 640] and user’s needs interleaved output image [1, 480, 640, 3]. Post-processing may look like this:

 auto proc = PrePostProcessor(function);
proc.output().postprocess().convert_layout({0, 2, 3, 1});
function = proc.build();

Parameters:

dims

Dimensions array specifying places for new axis. If not empty, array size (N) must match to input shape rank. Array values shall contain all values from 0 to N-1. If empty, no actual conversion will be added.

Returns:

Reference to ‘this’ to allow chaining with other calls in a builder-like manner.

PostProcessSteps& custom(const CustomPostprocessOp& postprocess_cb)

Add custom post-process operation. Client application can specify callback function for custom action.

Parameters:

postprocess_cb

Client’s custom postprocess operation.

Returns:

Reference to ‘this’ to allow chaining with other calls in a builder-like manner