.xoptim.patterns_ort

experimental_experiment.xoptim.patterns_ort.get_onnxruntime_patterns(verbose: int = 0) List[PatternOptimization][source]

Returns a default list of optimization patterns for onnxruntime. It is equal to the following list.

<<<

from experimental_experiment.xoptim.patterns_api import pattern_table_doc
from experimental_experiment.xoptim.patterns_ort import get_onnxruntime_patterns

print(pattern_table_doc(get_onnxruntime_patterns(), as_rst=True))

>>>

name

short_name

priority

doc

0

BiasGeluPattern

BiasGelu

1

Replaces by y = BiasGelu(x, B)

1

BiasSoftmaxPattern

BiasSoftmax

1

Replaces Softmax(Add(x,y), axis=-1) by BiasSoftmax(x,y,axis=-1) Model with nodes to be fused: .. gdot

2

ContribRotaryEmbeddingPattern

ContribRotaryEmbedding

2

Very similar to experimental_experiment.xoptim.patterns.onnx_rotary.RotaryEmbeddingPattern. Model with nodes to be fused: .. gdot

3

ContribRotaryEmbedding3DPattern

ContribRotaryEmbedding3D

1

Extension to experimental_experiment.xoptim.patterns_ort.llm_optim.ContribRotaryEmbeddingPattern, turn the operator into a 3D operator including the transpose. Model with nodes to be fused: .. gdot

4

GeluOrtPattern

GeluOrt

0

Detects the decomposed version of Gelu with Tanh .. math

5

GeluErfPattern

GeluErf

0

Detects the decomposed version of Gelu with Erf. Model with nodes to be fused: .. gdot

6

FusedConvPattern

FusedConv

2

Replaces the Conv + Relu into FusedConv. Model with nodes to be fused: .. gdot

7

FastGeluPattern

FastGelu

1

Replaces Gelu by FastGelu. Model with nodes to be fused: .. gdot

8

FusedMatMulPattern

FusedMatMul

2

Replaces the sequence Transpose, Matmul into FusedMatMul. Model with nodes to be fused: .. gdot

9

FusedMatMulx2Pattern

FusedMatMulx2

3

Replaces the sequence Div by a scalar consumed by two FusedMatMul. Model with nodes to be fused: .. gdot

10

FusedMatMulDivPattern

FusedMatMulDiv

2

Replaces the Matmul, Div into FusedMatMul. Model with nodes to be fused: .. gdot

11

FusedMatMulTransposePattern

FusedMatMulTranspose

3

Replaces the sequence (Fused)Matmul(A,B) + Transpose into FusedMatMul(B.T, A.T). Model with nodes to be fused: .. gdot

12

MissingCosSinPattern

MissingCosSin

1

Replaces Cos/Sin by Cast Cos/Sin Cast because of some missing kernels.

13

MissingRangePattern

MissingRange

1

Replaces Range by Cast Range Cast because of some missing kernels.

14

MultiHeadAttention3DPattern

MultiHeadAttention3D

1

Merges multiple nodes into MultiHeadAttention. It assumes pattern experimental_experiment.xoptim.patterns.onnx_attention.FunctionAttentionPattern was triggered before. Model with nodes to be fused: .. gdot

15

OrtBatchNormalizationTrainingPattern

OrtBatchNormalizationTraining

1

onnxruntime does not support batch normalization with training=1.

16

QuickGeluPattern

QuickGelu

1

Replaces Mul(x, Sigmoid(x)) by QuickGelu(x, alpha=1) Model with nodes to be fused: .. gdot

17

ReshapeGemmPattern

ReshapeGemm

3

Replaces the sequence Reshape(-1, …) + Gemm into FusedMatMul(). Model with nodes to be fused: .. gdot

18

SimplifiedLayerNormalizationPattern

SimplifiedLayerNormalization

1

Fuses the nodes equivalent to SimplifiedLayerNormalization. Model with nodes to be fused: .. gdot

19

SimplifiedLayerNormalizationMulPattern

SimplifiedLayerNormalizationMul

1

Replaces the sequence SimplifiedLayerNormalization + Mul by SimplifiedLayerNormalization. Model with nodes to be fused: .. gdot

20

SkipLayerNormalizationPattern

SkipLayerNormalization

1

Replaces the sequence Add + LayerNormalization into SkipLayerNormalization. Model with nodes to be fused: .. gdot

21

SkipSimplifiedLayerNormalizationPattern

SkipSimplifiedLayerNormalization

1

Replaces the sequence Add + SimplifiedLayerNormalization by SkipSimplifiedLayerNormalization. Model with nodes to be fused: .. gdot

22

SkipSimplifiedLayerNormalizationMulPattern

SkipSimplifiedLayerNormalizationMul

1

Replaces the sequence SkipSimplifiedLayerNormalization + Mul by SkipSimplifiedLayerNormalization. Model with nodes to be fused: .. gdot

23

SoftmaxGradPattern

SoftmaxGrad

1

Replaces the sequence Mul, ReduceSum, Mul, Sub by SoftmaxGrad.

24

TransposeFusedMatMulBPattern

TransposeFusedMatMulB

3

Replaces the sequence Transpose(B, [0, 2, 3, 1] + (Fused)Matmul(A,B) into Transpose(A, [0, 2, 1, 3]) + FusedMatMul(A, B, transB=1). Model with nodes to be fused: .. gdot