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 AddAddFusion;
class AddFakeQuantizeFusion;
class AddMultiplyFusion;
class AlignEltwiseInputRanks;
class BatchNormDecomposition;
class BatchToSpaceFusion;
class BidirectionalGRUSequenceDecomposition;
class BidirectionalLSTMSequenceDecomposition;
class BidirectionalRNNSequenceDecomposition;
class BinarizeWeights;
class BroadcastConstRangeReplacement;
class BroadcastElementwiseFusion;
class ClampFusion;
class CompressQuantizeWeights;
class ConvAddFusion;
class ConvMultiplyFusion;
class ConvStridesPropagation;
class ConvToBinaryConv;
class ConvertBatchToSpace;
class ConvertBroadcast3;
class ConvertBroadcastToTiles;
class ConvertConvertLike;
class ConvertConvolution;
class ConvertDeconvolution;
class ConvertDeformableConv8To1;
class ConvertDepthToSpace;
class ConvertDetectionOutput1ToDetectionOutput8;
class ConvertDetectionOutput8ToDetectionOutput1;
class ConvertDivide;
class ConvertDivideWithConstant;
class ConvertGELU;
class ConvertGRUCellMatcher;
class ConvertGRUSequenceMatcher;
class ConvertGRUSequenceToTensorIterator;
class ConvertGather0D;
class ConvertGather1ToGather7;
class ConvertGather7ToGather1;
class ConvertGather7ToGather8;
class ConvertGather8ToGather7;
class ConvertGatherToGatherIEMatcher;
class ConvertGatherTreeToGatherTreeIEMatcher;
class ConvertGroupConvolution;
class ConvertGroupDeconvolution;
class ConvertHardSigmoidToLegacyMatcher;
class ConvertInterpolate1ToInterpolate4;
class ConvertInterpolateToInterpOrResampleMatcher;
class ConvertLRNToLegacyMatcher;
class ConvertLSTMCellMatcher;
class ConvertLSTMSequenceMatcher;
class ConvertLSTMSequenceToTensorIterator;
class ConvertMVN1ToMVN6;
class ConvertMatMulToFC;
class ConvertMatMulToGemm;
class ConvertMatrixNmsToMatrixNmsIE;
class ConvertMaxPool1ToMaxPool8;
class ConvertMaxPool8ToMaxPool1;
class ConvertMinimum;
class ConvertMod;
class ConvertMulAddToScaleShiftOrPower;
class ConvertMulticlassNms8ToMulticlassNms9;
class ConvertMulticlassNmsToMulticlassNmsIE;
class ConvertNMS1ToNMS5;
class ConvertNMS1ToNMS9;
class ConvertNMS3ToNMS5;
class ConvertNMS3ToNMS9;
class ConvertNMS4ToNMS5;
class ConvertNMS4ToNMS9;
class ConvertNMS5ToLegacyMatcher;
class ConvertNMS5ToNMS9;
class ConvertNMS9ToNMSIEInternal;
class ConvertNMSToNMSIEInternal;
class ConvertNMSToNMSIEMatcher;
class ConvertNegative;
class ConvertNormalizeL2ToLegacyMatcher;
class ConvertNormalizeL2WithMulToNormalizeIE;
class ConvertOneHotToOneHotIEMatcher;
class ConvertPReLUToReLUIE;
class ConvertPadToGroupConvolution;
class ConvertPadToLegacyMatcher;
class ConvertPowerToPowerIEMatcher;
class ConvertPriorBox8To0;
class ConvertProposal4ToLegacyMatcher;
class ConvertProposalToLegacyMatcher;
class ConvertQuantizeDequantize;
class ConvertRNNCellMatcher;
class ConvertRNNSequenceMatcher;
class ConvertRNNSequenceToTensorIterator;
class ConvertROIAlign3To9;
class ConvertROIAlign9To3;
class ConvertScatterElementsToScatter;
class ConvertSeluToSeluIEMatcher;
class ConvertShapeOf3;
class ConvertShuffleChannels3;
class ConvertSoftMax1ToSoftMax8;
class ConvertSoftMax8ToSoftMax1;
class ConvertSpaceToBatch;
class ConvertSpaceToDepth;
class ConvertSqrtToPowerIEMatcher;
class ConvertStridedSliceToCropMatcher;
class ConvertSubtract;
class ConvertSwishToSwishIEMatcher;
class ConvertTensorIteratorToGRUSequence;
class ConvertTensorIteratorToLSTMSequence;
class ConvertTensorIteratorToRNNSequence;
class ConvertTileToLegacyMatcher;
class ConvertTopK3;
class ConvertTopKToTopKIEMatcher;
class ConvolutionBackpropDataMultiplyFusion;
class ConvolutionMultiplyFusion;
class DeconvAddFusion;
class DepthToSpaceFusion;
class DilatedConvolutionConverter;
class DisableConvertConstantFoldingOnConstPath;
class DisableRandomUniformConstantFolding;
class DisableShapeOfConstantFolding;
class DivideFusion;
class DropoutWithRandomUniformReplacer;
class EinsumDecomposition;
class EliminateConcat;
class EliminateConvert;
class EliminateConvertNonZero;
class EliminateEltwise;
class EliminateGatherUnsqueeze;
class EliminatePad;
class EliminateSplit;
class EliminateSqueeze;
class EliminateTranspose;
class EliminateUnsqueezeGather;
class FakeQuantizeDecomposition;
class FakeQuantizeMulFusion;
class FakeQuantizeReshapeFusion;
class FullyConnectedBiasFusion;
class GRUCellDecomposition;
class GatherNegativeConstIndicesNormalize;
class GatherNopElimination;
class Gelu7Downgrade;
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 InitConstMask;
class InterpolateSequenceFusion;
class LSTMCellDecomposition;
class LeakyReluFusion;
class LogSoftmaxDecomposition;
class MVN6Decomposition;
class MVNFusionWithConstantsInside;
class MVNFusionWithoutConstants;
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 PullSqueezeThroughEltwise;
class PullTransposeThroughFQUp;
class RNNCellDecomposition;
class RandomUniformFusion;
class ReduceL1Decomposition;
class ReduceL2Decomposition;
class ReduceMerge;
class ReluFakeQuantizeFusion;
class RemoveFilteringBoxesBySize;
class ReplaceConcatReduceByMinOrMax;
class Reshape1DAvgPool;
class Reshape1DConvolution;
class Reshape1DMaxPool;
class ReshapeAMatMul;
class ReshapeBMatMul;
class ReshapeFullyConnected;
class ReshapeFullyConnectedFusion;
class ReshapeSequenceFusion;
class ReshapeTo1D;
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 TransposeToReshape;
class UnsupportedNodesStridesPropagation;
class WeightsDequantizeToFakeQuantize;
class WrapInterpolateIntoTransposes;
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;
template ConvertConstantsToScalars;
class ConvertPowerToPowerStatic;
template InsertLoad;
template InsertMoveBroadcast;
template InsertStore;
template LoadMoveBroadcastToBroadcastLoad;
template ReplaceLoadsWithScalarLoads;
template ReplaceStoresWithScalarStores;
template TokenizeSnippets;
class AddOldApiMapToParameters;
class CompressFloatConstantsImpl;
class DisableDecompressionConvertConstantFolding;
class DivisionByZeroFP16Resolver;
class EnableDecompressionConvertConstantFolding;
class FoldSubgraphEmptyInputs;
class RemoveConcatZeroDimInput;
class RemoveMultiSubGraphOpDanglingParams;
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.