class ov::pass::MatcherPass

Overview

MatcherPass is a basic block for pattern based transformations. It describes pattern and action that is applied if pattern is matched. More…

#include <graph_rewrite.hpp>

class MatcherPass: public ov::pass::PassBase
{
public:
    // construction

    MatcherPass();
    MatcherPass(const MatcherPass&);

    MatcherPass(
        const std::string& name,
        const std::shared_ptr<pattern::Matcher>& m,
        const handler_callback& handler,
        const PassPropertyMask& property = PassProperty::CHANGE_DYNAMIC_STATE
        );

    MatcherPass(
        const std::shared_ptr<pattern::Matcher>& m,
        const matcher_pass_callback& callback
        );

    // methods

    OPENVINO_RTTI("ov::pass::MatcherPass");
    MatcherPass& operator = (const MatcherPass&);
    bool apply(std::shared_ptr<ov::Node> node);

    template <typename T, class... Args>
    std::shared_ptr<T> register_new_node(Args&&... args);

    template <typename T>
    std::shared_ptr<T> register_new_node(const std::shared_ptr<T>& node);

    std::shared_ptr<ov::Node> register_new_node_(const std::shared_ptr<ov::Node>& node);
    const std::vector<std::shared_ptr<ov::Node>>& get_new_nodes();
    void clear_new_nodes();
    std::shared_ptr<pattern::Matcher> get_matcher();
};

// direct descendants

class ConvertReduceBase;
class CvtReduceBase;
class CompressQuantizeWeights;
class ConvAddFusion;
class ConvMultiplyFusion;
class ConvertConvolution;
class ConvertDeconvolution;
class ConvertGRUCellMatcher;
class ConvertGRUSequenceMatcher;
class ConvertGatherToGatherIEMatcher;
class ConvertGatherTreeToGatherTreeIEMatcher;
class ConvertGroupConvolution;
class ConvertGroupDeconvolution;
class ConvertHardSigmoidToLegacyMatcher;
class ConvertInterpolateToInterpOrResampleMatcher;
class ConvertLRNToLegacyMatcher;
class ConvertLSTMCellMatcher;
class ConvertLSTMSequenceMatcher;
class ConvertMatMulToFC;
class ConvertMatMulToGemm;
class ConvertMulAddToScaleShiftOrPower;
class ConvertNMS5ToLegacyMatcher;
class ConvertNMSToNMSIEMatcher;
class ConvertNormalizeL2ToLegacyMatcher;
class ConvertNormalizeL2WithMulToNormalizeIE;
class ConvertOneHotToOneHotIEMatcher;
class ConvertPReLUToReLUIE;
class ConvertPadToLegacyMatcher;
class ConvertPowerToPowerIEMatcher;
class ConvertProposal4ToLegacyMatcher;
class ConvertProposalToLegacyMatcher;
class ConvertRNNCellMatcher;
class ConvertRNNSequenceMatcher;
class ConvertSeluToSeluIEMatcher;
class ConvertSqrtToPowerIEMatcher;
class ConvertStridedSliceToCropMatcher;
class ConvertSwishToSwishIEMatcher;
class ConvertTileToLegacyMatcher;
class ConvertTopKToTopKIEMatcher;
class DeconvAddFusion;
class FullyConnectedBiasFusion;
class InitConstMask;
class Reshape1DAvgPool;
class Reshape1DConvolution;
class Reshape1DMaxPool;
class ReshapeFullyConnected;
class ReshapeFullyConnectedFusion;
class ZeroPointOptimizer;
class ConvertSubtractConstant;

template <typename AttributeType, typename OperationType>
class CreatePrecisionsDependentAttribute;

class LayerTransformation;

template <typename AttributeType>
class PropagateThroughPrecisionPreserved;

template <typename AttributeType>
class PropagateToInput;

class PullReshapeThroughDequantization;
class PullTransposeThroughDequantization;

template <
    typename AttributeType,
    typename ExpectedAttributeType = AttributeType
    >
class UpdateSharedPrecisionPreserved;

class CommonOptimizations;
template ConvertConstantsToScalars;
class ConvertPowerToPowerStatic;
template FakeQuantizeDecomposition;
template InsertLoad;
template InsertMoveBroadcast;
template InsertStore;
template LoadMoveBroadcastToBroadcastLoad;
template SetScalarCountForLoad;
template SetScalarCountForStore;
template TokenizeSnippets;
class TransformConvertToConvertTruncation;
class AUGRUCellFusion;
class AddAddFusion;
class AddFakeQuantizeFusion;
class AddMultiplyFusion;
class AddOldApiMapToParameters;
class AlignEltwiseInputRanks;
class BatchNormDecomposition;
class BatchToSpaceFusion;
class BidirectionalGRUSequenceDecomposition;
class BidirectionalLSTMSequenceDecomposition;
class BidirectionalRNNSequenceDecomposition;
class BinarizeWeights;
class BroadcastConstRangeReplacement;
class BroadcastElementwiseFusion;
class ClampFusion;
class CompressFloatConstantsImpl;
class ConvStridesPropagation;
class ConvToBinaryConv;
class ConvertBatchToSpace;
class ConvertBroadcast3;
class ConvertBroadcastToTiles;
class ConvertConvertLike;
class ConvertDeformableConv8To1;
class ConvertDepthToSpace;
class ConvertDetectionOutput1ToDetectionOutput8;
class ConvertDetectionOutput8ToDetectionOutput1;
class ConvertDivide;
class ConvertDivideWithConstant;
class ConvertGELU;
class ConvertGP9ToGPIEInternal;
class ConvertGRUSequenceToTensorIterator;
class ConvertGather0D;
class ConvertGather1ToGather7;
class ConvertGather7ToGather1;
class ConvertGather7ToGather8;
class ConvertGather8ToGather7;
class ConvertInterpolate1ToInterpolate4;
class ConvertLSTMSequenceToTensorIterator;
class ConvertMVN1ToMVN6;
class ConvertMatrixNmsToMatrixNmsIE;
class ConvertMaxPool1ToMaxPool8;
class ConvertMaxPool8ToMaxPool1;
class ConvertMinimum;
class ConvertMod;
class ConvertMulticlassNms8ToMulticlassNms9;
class ConvertMulticlassNmsToMulticlassNmsIE;
class ConvertNMS1ToNMS5;
class ConvertNMS1ToNMS9;
class ConvertNMS3ToNMS5;
class ConvertNMS3ToNMS9;
class ConvertNMS4ToNMS5;
class ConvertNMS4ToNMS9;
class ConvertNMS5ToNMS9;
class ConvertNMS9ToNMSIEInternal;
class ConvertNMSToNMSIEInternal;
class ConvertNegative;
class ConvertPadToGroupConvolution;
class ConvertPriorBox8To0;
class ConvertQuantizeDequantize;
class ConvertRNNSequenceToTensorIterator;
class ConvertROIAlign3To9;
class ConvertROIAlign9To3;
class ConvertScatterElementsToScatter;
class ConvertShapeOf3;
class ConvertShuffleChannels3;
class ConvertSoftMax1ToSoftMax8;
class ConvertSoftMax8ToSoftMax1;
class ConvertSpaceToBatch;
class ConvertSpaceToDepth;
class ConvertSubtract;
class ConvertTensorIteratorToGRUSequence;
class ConvertTensorIteratorToLSTMSequence;
class ConvertTensorIteratorToRNNSequence;
class ConvertTopK3;
class ConvertXorToLogicalXor;
class ConvolutionBackpropDataMultiplyFusion;
class ConvolutionMultiplyFusion;
class DepthToSpaceFusion;
class DilatedConvolutionConverter;
class DisableDecompressionConvertConstantFolding;
class DisableRandomUniformConstantFolding;
class DisableShapeOfConstantFolding;
class DivideFusion;
class DivisionByZeroFP16Resolver;
class DropoutWithRandomUniformReplacer;
class EinsumDecomposition;
class EliminateConcat;
class EliminateConvert;
class EliminateConvertNonZero;
class EliminateDuplicateTIInputs;
class EliminateEltwise;
class EliminateGatherUnsqueeze;
class EliminatePad;
class EliminateScatterUpdate;
class EliminateSplit;
class EliminateSplitConcat;
class EliminateSqueeze;
class EliminateTranspose;
class EliminateUnsqueezeGather;
class EnableDecompressionConvertConstantFolding;
class EyeDecomposition;
class FakeQuantizeDecomposition;
class FakeQuantizeMulFusion;
class FakeQuantizeReshapeFusion;
class FoldSubgraphEmptyInputs;
class GRUCellDecomposition;
class GRUCellFusion;
class GatherNegativeConstIndicesNormalize;
class GatherNopElimination;
class Gelu7Downgrade;
class GeluFusionWithErfFour;
class GeluFusionWithErfOne;
class GeluFusionWithErfThree;
class GeluFusionWithErfTwo;
class GeluFusionWithTanh;
class GroupConvolutionBackpropDataMultiplyFusion;
class GroupConvolutionMultiplyFusion;
class GroupedGatherElimination;
class HSigmoidDecomposition;
class HSigmoidFusionWithClampDiv;
class HSigmoidFusionWithClampMul;
class HSigmoidFusionWithReluDiv;
class HSigmoidFusionWithReluMul;
class HSigmoidFusionWithoutRelu;
class HSwishDecomposition;
class HSwishFusionWithClamp;
class HSwishFusionWithHSigmoid;
class HSwishFusionWithReluDiv;
class HSwishFusionWithReluMul;
class InterpolateSequenceFusion;
class LSTMCellDecomposition;
class LeakyReluFusion;
class LogSoftmaxDecomposition;
class MVN6Decomposition;
class MVNFusionWithConstantsInside;
class MVNFusionWithoutConstants;
class MarkDequantizationSubgraph;
class MatMulConstTransposesExtraction;
class MatMulMultiplyFusion;
class MishFusion;
class MulFakeQuantizeFusion;
class MultiplyConvolutionBackpropDataFusion;
class MultiplyConvolutionFusion;
class MultiplyGroupConvolutionBackpropDataFusion;
class MultiplyGroupConvolutionFusion;
class MultiplyMultiplyFusion;
class NearestNeighborUpsamplingFusion;
class NormalizeL2Decomposition;
class NormalizeL2Fusion;
class PReluFusionMultiplyAdd;
class PReluFusionMultiplySub;
class PReluFusionNegativeAdd;
class PReluFusionNegativeSub;
class PadFusionAvgPool;
class PadFusionConvolution;
class PadFusionConvolutionBackpropData;
class PadFusionGroupConvolution;
class PadFusionGroupConvolutionBackpropData;
class Proposal1Scales;
class Proposal4Scales;
class PullReshapeThroughReduce;
class PullSqueezeThroughEltwise;
class PullTransposeThroughFQUp;
class PullUnsqueezeThroughReduce;
class RNNCellDecomposition;
class RandomUniformFusion;
class ReduceL1Decomposition;
class ReduceL2Decomposition;
class ReduceMerge;
class ReduceReshapeFusion;
class ReluFakeQuantizeFusion;
class RemoveConcatZeroDimInput;
class RemoveFilteringBoxesBySize;
class RemoveMultiSubGraphOpDanglingParams;
class ReplaceConcatReduceByMinOrMax;
class ReshapeAMatMul;
class ReshapeBMatMul;
class ReshapePRelu;
class ReshapeSequenceFusion;
class ReshapeSinkingMatMul;
class ReshapeTo1D;
class SelectWithOneValueCondition;
class SequenceFusion;
class ShapeOfConstFolding;
class ShuffleChannelsFusion;
class SkipGatherBeforeTransposeAndReshape;
class SliceToStridedSlice;
class SoftPlusDecomposition;
class SoftPlusFusion;
class SoftPlusToMishFusion;
class SoftSignDecomposition;
class SoftmaxDecomposition;
class SoftmaxFusion;
class SpaceToBatchFusion;
class SplitConcatPairToInterpolateFusion;
class SplitSqueezeConcatFusion;
class SqueezeStridedSlice;
class StridedSliceSqueeze;
class SubtractFusion;
class SupportedNodesStridesPropagation;
class SwishFusionWithBeta;
class SwishFusionWithSigmoid;
class SwishFusionWithSigmoidWithBeta;
class SwishFusionWithoutBeta;
class TransposeConvert;
class TransposeEltwise;
class TransposeFQReduction;
class TransposeFuse;
class TransposeMatMul;
class TransposeReduction;
class TransposeReshapeEliminationForMatmul;
class TransposeSinkingBinaryElementwiseBackward;
class TransposeSinkingBinaryElementwiseForward;
class TransposeSinkingConcatBackward;
class TransposeSinkingConcatForward;
class TransposeSinkingSplitBackward;
class TransposeSinkingSplitForward;
class TransposeSinkingUnaryBackward;
class TransposeSinkingUnaryForward;
class TransposeToReshape;
class UniqueDecomposition;
class UnsupportedNodesStridesPropagation;
class WeightsDequantizeToFakeQuantize;
class WrapInterpolateIntoTransposes;

Inherited Members

public:
    // typedefs

    typedef DiscreteTypeInfo type_info_t;

    // methods

    bool get_property(const PassPropertyMask& prop_mask) const;
    void set_name(const std::string& name);
    std::string get_name() const;
    void set_callback(const param_callback& callback);
    virtual void set_pass_config(const std::shared_ptr<PassConfig>& pass_config);
    std::shared_ptr<PassConfig> get_pass_config();
    bool m_transformation_callback(const std::shared_ptr<const Node>& node);
    bool transformation_callback(const std::shared_ptr<const Node>& node);
    virtual const type_info_t& get_type_info() const = 0;

Detailed Documentation

MatcherPass is a basic block for pattern based transformations. It describes pattern and action that is applied if pattern is matched.

MatcherPass consists of Matcher and matcher_pass_callback that needs to be implemented and finally registered by using

See also:

register_matcher. MatcherPass can be executed on node within

apply method. To run matcher pass on Function use GraphRewrite. In addition MatcherPass provides a way for adding new operations into GraphRewrite execution queue. That means that operations that were created inside transformation callback can be added for matching. To register node use

register_new_node method. GraphRewrite automatically takes registered nodes and put them to execution queue. If multiple nodes were register make sure that they were registered in topological order. Note: when implementing pattern for Matcher make sure that root node is an operation from opset or has ov::pass::pattern::op::WrapType. That will help GraphRewrite to execute matcher passes more efficient.