.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)

2

ContribRotaryEmbeddingPattern

ContribRotaryEmbedding

2

Very similar to experimental_experiment.xoptim.patterns.onnx_rotary.RotaryEmbeddingPattern.

3

ContribRotaryEmbedding3DPattern

ContribRotaryEmbedding3D

1

Extension to experimental_experiment.xoptim.patterns_ort.llm_optim.ContribRotaryEmbeddingPattern, turn the operator into a 3D operator including the transpose.

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.

6

FusedConvPattern

FusedConv

2

Replaces the Conv + Relu into FusedConv.

7

FastGeluPattern

FastGelu

1

Replaces Gelu by FastGelu.

8

FusedMatMulPattern

FusedMatMul

2

Replaces the sequence Transpose, Matmul into FusedMatMul.

9

FusedMatMulx2Pattern

FusedMatMulx2

3

Replaces the sequence Div by a scalar consumed by two FusedMatMul.

10

FusedMatMulDivPattern

FusedMatMulDiv

2

Replaces the Matmul, Div into FusedMatMul.

11

FusedMatMulTransposePattern

FusedMatMulTranspose

3

Replaces the sequence (Fused)Matmul(A,B) + Transpose into FusedMatMul(B.T, A.T).

12

MultiHeadAttention3DPattern

MultiHeadAttention3D

1

Merges multiple nodes into MultiHeadAttention. It assumes pattern experimental_experiment.xoptim.patterns.onnx_attention.FunctionAttentionPattern was triggered before.

13

OrtBatchNormalizationTrainingPattern

OrtBatchNormalizationTraining

1

onnxruntime does not support batch normalization with training=1.

14

QuickGeluPattern

QuickGelu

1

Replaces Mul(x, Sigmoid(x)) by QuickGelu(x, alpha=1)

15

ReshapeGemmPattern

ReshapeGemm

3

Replaces the sequence Reshape(-1, …) + Gemm into FusedMatMul().

16

SimplifiedLayerNormalizationPattern

SimplifiedLayerNormalization

1

Fuses the nodes equivalent to SimplifiedLayerNormalization.

17

SimplifiedLayerNormalizationMulPattern

SimplifiedLayerNormalizationMul

1

Replaces the sequence SimplifiedLayerNormalization + Mul by SimplifiedLayerNormalization.

18

SkipLayerNormalizationPattern

SkipLayerNormalization

1

Replaces the sequence Add + LayerNormalization into SkipLayerNormalization.

19

SkipSimplifiedLayerNormalizationPattern

SkipSimplifiedLayerNormalization

1

Replaces the sequence Add + SimplifiedLayerNormalization by SkipSimplifiedLayerNormalization.

20

SkipSimplifiedLayerNormalizationMulPattern

SkipSimplifiedLayerNormalizationMul

1

Replaces the sequence SkipSimplifiedLayerNormalization + Mul by SkipSimplifiedLayerNormalization.

21

SoftmaxGradPattern

SoftmaxGrad

1

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

22

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).