experimental_experiment.xbuilder.optimization_options¶
- class experimental_experiment.xbuilder.optimization_options.OptimizationOptions(remove_unused: bool = True, constant_folding: bool = False, constant_size: int = 1024, constant_fusing: bool = True, remove_identity: bool = True, patterns: str | List[PatternOptimization] = 'default', max_iter: int = -1, recursive: bool = False, stop_after: int = -1, verbose: int = 0, verifies: bool = False, dump_applied_patterns: str | None = None, processor: str = 'CPU', order: OrderAlgorithm | None = None)[source]¶
Defines all the optimization to apply.
- Parameters:
remove_unused – remove all unused nodes, this must be true if pattern optimization is enabled
constant_folding – folds constant as much as possible
constant_size – all node Constant above this threshold should be defined as initializer
remove_identity – remove identity nodes
patterns – list of pattern optimization to apply to the graph, it looks a a specific subsequence of nodes in a graph and do some replacements, ‘default’ means a default list of optimization patterns are applied, see below for the most common values
constant_fusing – similar node Constant and ConstantOfShape are used, this options avoids creating new nodes when they are the same
max_iter – maximum number of iteration when doing pattern optimizations, -1 to let it undefined
recursive – optimizes subgraphs and functions as well
stop_after – for investigation, stop_after this number of applies patterns, -1 to never stop
verbose – verbosity level (for pattern optimization)
verifies – run verifications to ensure the model is correct everytime it is modifies, it is mostly to find bugs, it is very slow
dump_applied_patterns – dump applied patterns in a folder, the users can check every pattern dumped as a FunctionProto
processor – optimization should be made for this processor or this list of processors (comma separated value)
order – order algorithm to apply
It is possible to define a precise of the pattern to apply to a model. The value is interpreter by
experimental_experiment.xoptim.get_pattern_list()
.patterns=None
: no pattern optimizationpatterns="TransposeTranspose,TransposeMatMul"
: applies two patternspatterns=["FusedMatMul"]
: applies one patternpatterns=[RotaryEmbeddingPattern(verbose=10)]
: applies one pattern with a specific verbosity valuepatterns="default
: applies all patterns modifying standard onnx operators into other standard onnx operatorspatterns="default+onnxruntime
: applies all patterns modifying standard onnx operators into other standard onnx operators as well as patterns fusing nodes into custom operators implemented by onnxruntimepatterns="default+onnxruntime+experimental
: applies all patterns modifying standard onnx operators into other standard onnx operators, patterns fusing nodes into custom operators implemented by onnxruntime,