.xoptim.patterns_ort¶
modules
- .xoptim.patterns_ort.activation
- .xoptim.patterns_ort.activation_grad
- .xoptim.patterns_ort.attention_patterns
- .xoptim.patterns_ort.batch_normalization
- .xoptim.patterns_ort.fused_conv
- .xoptim.patterns_ort.fused_matmul
- .xoptim.patterns_ort.gather_grad
- .xoptim.patterns_ort.llm_optim
- .xoptim.patterns_ort.simplified_layer_normalization
- 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
AttentionPattern
Attention
3
Replaces many nodes by Attention [com.microsoft]. The first sketch of the pattern was generared from an onnx model and the following code: .. code-block
1
BiasGeluPattern
BiasGelu
1
Replaces by
y = BiasGelu(x, B)
2
BiasSoftmaxPattern
BiasSoftmax
1
Replaces Softmax(Add(x,y), axis=-1) by BiasSoftmax(x,y,axis=-1)
3
GeluOrtPattern
GeluOrt
0
Detects the decomposed version of Gelu with Tanh .. math
4
GeluErfPattern
GeluErf
0
Detects the decomposed version of Gelu with Erf.
5
FusedConvPattern
FusedConv
2
Replaces the Conv + Relu into FusedConv.
6
FastGeluPattern
FastGelu
1
Replaces Gelu by FastGelu.
7
FusedMatMulPattern
FusedMatMul
2
Replaces the sequence Transpose, Matmul into FusedMatMul.
8
FusedMatMulx2Pattern
FusedMatMulx2
3
Replaces the sequence Div by a scalar consumed by two FusedMatMul.
9
FusedMatMulDivPattern
FusedMatMulDiv
2
Replaces the Matmul, Div into FusedMatMul.
10
FusedMatMulTransposePattern
FusedMatMulTranspose
3
Replaces the sequence (Fused)Matmul(A,B) + Transpose into FusedMatMul(B.T, A.T).
11
OrtBatchNormalizationTrainingPattern
OrtBatchNormalizationTraining
1
onnxruntime does not support batch normalization with training=1.
12
QuickGeluPattern
QuickGelu
1
Replaces Mul(x, Sigmoid(x)) by QuickGelu(x, alpha=1)
13
ReshapeGemmPattern
ReshapeGemm
3
Replaces the sequence Reshape(-1, …) + Gemm into FusedMatMul().
14
SimplifiedLayerNormalizationPattern
SimplifiedLayerNormalization
1
Replaces the sequence Transpose, Matmul into FusedMatMul.
15
SkipLayerNormalizationPattern
SkipLayerNormalization
1
Replaces the sequence Add + LayerNormalization into SkipLayerNormalization.
16
SoftmaxGradPattern
SoftmaxGrad
1
Replaces the sequence Mul, ReduceSum, Mul, Sub by SoftmaxGrad
17
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).