Skip to main content
Ctrl+K
yet-another-onnx-builder 0.1.0 documentation - Home yet-another-onnx-builder 0.1.0 documentation - Home
  • API
  • Converters
  • Core
  • Galleries
  • CMDs
    • Installation
    • Getting Started
    • Miscellaneous
  • GitHub
  • API
  • Converters
  • Core
  • Galleries
  • CMDs
  • Installation
  • Getting Started
  • Miscellaneous
  • GitHub

Section Navigation

Core

  • yobx.convert
  • yobx.typing
  • yobx.builder
    • yobx.builder.light
      • yobx.builder.light – Graph
      • yobx.builder.light – Variables
      • yobx.builder.light – Single-input Operators
      • yobx.builder.light – Multi-input Operators
    • yobx.builder.onnxscript
      • yobx.builder.onnxscript.bridge_graph_builder
    • yobx.builder.spox
      • yobx.builder.spox.bridge_graph_builder
  • yobx.container
    • yobx.container.build_stats
    • yobx.container.export_artifact
    • yobx.container.model_container
  • yobx.helpers
    • yobx.helpers.cube_helper
    • yobx.helpers.dot_helper
    • yobx.helpers.einsum_helper
      • yobx.helpers._einsum.einsum_impl
      • yobx.helpers._einsum.einsum_impl_classes
      • yobx.helpers._einsum.einsum_impl_ext
      • yobx.helpers._einsum.blas_lapack
      • yobx.helpers._einsum._onnx_utils
    • yobx.helpers.helper
    • yobx.helpers.mini_onnx_builder
    • yobx.helpers.onnx_helper
    • yobx.helpers.patch_helper
    • yobx.helpers.rt_helper
    • yobx.helpers.stats_helper
    • yobx.helpers.to_onnx_helper
  • yobx.reference
    • yobx.reference.evaluator
    • yobx.reference.onnxruntime_evaluator
    • yobx.reference.report_results_comparison
    • yobx.reference.runtime_info
    • yobx.reference.torch_evaluator
    • yobx.reference.ops
      • yobx.reference.ops.op__overwrite_gather
      • yobx.reference.ops.op_complex
      • yobx.reference.ops.op_fast_gelu
      • yobx.reference.ops.op_fused_matmul_activation
      • yobx.reference.ops.op_gemm_fast_gelu
    • yobx.reference.torch_ops
  • yobx.translate
    • yobx.translate.base_emitter
    • yobx.translate.builder_emitter
    • yobx.translate.inner_emitter
    • yobx.translate.light_emitter
    • yobx.translate.make_helper
    • yobx.translate.mermaid_emitter
    • yobx.translate.reverse_graph_builder
    • yobx.translate.translator
  • yobx.xbuilder
    • yobx.xbuilder.builder_stats_helper
    • yobx.xbuilder.function_options
    • yobx.xbuilder.graph_builder
    • yobx.xbuilder.graph_builder_opset
    • yobx.xbuilder.infer_shapes_options
    • yobx.xbuilder.optimization_options
    • yobx.xbuilder.order_optim
  • yobx.xoptim
    • yobx.xoptim.graph_builder_optim
    • yobx.xoptim.patterns_api
    • yobx.xoptim.patterns
      • yobx.xoptim.patterns.onnx_any
      • yobx.xoptim.patterns.onnx_attention
      • yobx.xoptim.patterns.onnx_cast
      • yobx.xoptim.patterns.onnx_clip
      • yobx.xoptim.patterns.onnx_concat
      • yobx.xoptim.patterns.onnx_constants
      • yobx.xoptim.patterns.onnx_conv
      • yobx.xoptim.patterns.onnx_dropout
      • yobx.xoptim.patterns.onnx_equal
      • yobx.xoptim.patterns.onnx_expand
      • yobx.xoptim.patterns.onnx_functions
      • yobx.xoptim.patterns.onnx_layer_normalization
      • yobx.xoptim.patterns.onnx_matmul
      • yobx.xoptim.patterns.onnx_mul
      • yobx.xoptim.patterns.onnx_range
      • yobx.xoptim.patterns.onnx_reduce
      • yobx.xoptim.patterns.onnx_reshape
      • yobx.xoptim.patterns.onnx_rotary
      • yobx.xoptim.patterns.onnx_sequence
      • yobx.xoptim.patterns.onnx_shape
      • yobx.xoptim.patterns.onnx_slice
      • yobx.xoptim.patterns.onnx_split
      • yobx.xoptim.patterns.onnx_sub
      • yobx.xoptim.patterns.onnx_transpose
      • yobx.xoptim.patterns.onnx_unsqueeze
      • yobx.xoptim.patterns.onnx_where
    • yobx.xoptim.patterns_exp
      • yobx.xoptim.patterns_exp.binary_operators
      • yobx.xoptim.patterns_exp.constant_of_shape_scatter_nd
      • yobx.xoptim.patterns_exp.constants
      • yobx.xoptim.patterns_exp.simple_rotary
      • yobx.xoptim.patterns_exp.unary_operators
      • yobx.xoptim.patterns_exp.where_replace
    • yobx.xoptim.patterns_fix
      • yobx.xoptim.patterns_fix.add_reduction_scatter_nd
    • yobx.xoptim.patterns_investigation
      • yobx.xoptim.patterns_investigation.element_wise
      • yobx.xoptim.patterns_investigation.llm_patterns
    • yobx.xoptim.patterns_ml
      • yobx.xoptim.patterns_ml.tree_ensemble
    • yobx.xoptim.patterns_ort
      • yobx.xoptim.patterns_ort.activation
      • yobx.xoptim.patterns_ort.causal_conv
      • yobx.xoptim.patterns_ort.complex_mul
      • yobx.xoptim.patterns_ort.embed_layer_normalization
      • yobx.xoptim.patterns_ort.fused_conv
      • yobx.xoptim.patterns_ort.fused_matmul
      • yobx.xoptim.patterns_ort.greedy_search
      • yobx.xoptim.patterns_ort.llm_optim
      • yobx.xoptim.patterns_ort.missing_kernels
      • yobx.xoptim.patterns_ort.moe
      • yobx.xoptim.patterns_ort.relative_position_bias
      • yobx.xoptim.patterns_ort.simplified_layer_normalization
    • yobx.xoptim.repeated_optim
    • yobx.xoptim.unfused
  • yobx.xexpressions
    • yobx.xexpressions.expressions_torch
    • yobx.xexpressions.evaluate_expressions
    • yobx.xexpressions.operations
    • yobx.xexpressions.rename_expressions
    • yobx.xexpressions.simplify_expressions
  • yobx.xshape
    • yobx.xshape._builder_runtime
    • yobx.xshape._inference_runtime
    • yobx.xshape._shape_runtime
    • yobx.xshape._shape_helper
    • yobx.xshape.cost_inference
    • yobx.xshape.shape_builder
    • yobx.xshape.shape_builder_impl
    • yobx.xshape.shape_type_compute
    • yobx.xshape.type_inference
  • yobx.xtracing
    • yobx.xtracing.numpy_array
    • yobx.xtracing.tracing
    • yobx.xtracing — dataframe_trace module
    • yobx.xtracing — parse module

Converters

  • yobx.to_onnx
  • yobx.litert
    • yobx.litert.to_onnx
    • yobx.litert.convert
    • yobx.litert.register
    • yobx.litert.litert_helper
    • yobx.litert.ops
      • yobx.litert.ops.activations
      • yobx.litert.ops.elementwise
      • yobx.litert.ops.nn_ops
      • yobx.litert.ops.reshape_ops
  • yobx.sql
    • yobx.sql.dataframe_to_onnx
    • yobx.sql.sql_to_onnx
    • yobx.sql.sql_to_onnx_graph
    • yobx.sql.parsed_query_to_onnx
    • yobx.sql.parsed_query_to_onnx_graph
    • yobx.sql.lazyframe_to_onnx
    • yobx.sql.trace_numpy_to_onnx
    • yobx.sql.to_onnx
    • yobx.sql.coverage
    • yobx.sql.sql_convert
    • yobx.sql.polars_convert
    • yobx.sql.convert
    • yobx.sql._expr
    • yobx.sql.ops
      • yobx.sql.ops.register
      • yobx.sql.ops.filter_op
      • yobx.sql.ops.join_op
  • yobx.sklearn
    • yobx.sklearn.to_onnx
    • yobx.sklearn.convert_options
    • yobx.sklearn.convert
    • yobx.sklearn.convert_helper
    • yobx.sklearn.register
    • yobx.sklearn.skl2onnx_converter
    • yobx.sklearn.sklearn_helper
    • yobx.sklearn.tests_helper
    • yobx.sklearn.traceable_converter
    • yobx.sklearn.calibration
      • yobx.sklearn.calibration.calibrated_classifier
    • yobx.sklearn.category_encoders
      • yobx.sklearn.category_encoders.binary_encoder
      • yobx.sklearn.category_encoders.one_hot_encoder
      • yobx.sklearn.category_encoders.ordinal_encoder
      • yobx.sklearn.category_encoders.polynomial_encoder
      • yobx.sklearn.category_encoders.quantile_encoder
      • yobx.sklearn.category_encoders.target_encoder
      • yobx.sklearn.category_encoders.woe_encoder
    • yobx.sklearn.cluster
      • yobx.sklearn.cluster.affinity_propagation
      • yobx.sklearn.cluster.birch
      • yobx.sklearn.cluster.bisecting_kmeans
      • yobx.sklearn.cluster.feature_agglomeration
      • yobx.sklearn.cluster.kmeans
      • yobx.sklearn.cluster.mean_shift
      • yobx.sklearn.cluster.mini_batch_kmeans
    • yobx.sklearn.compose
      • yobx.sklearn.compose.column_transformer
    • yobx.sklearn.covariance
      • yobx.sklearn.covariance.elliptic_envelope
      • yobx.sklearn.covariance.empirical_covariance
      • yobx.sklearn.covariance.graphical_lasso
      • yobx.sklearn.covariance.ledoit_wolf
      • yobx.sklearn.covariance.min_cov_det
      • yobx.sklearn.covariance.oas
      • yobx.sklearn.covariance.shrunk_covariance
    • yobx.sklearn.cross_decomposition
      • yobx.sklearn.cross_decomposition.cca
    • yobx.sklearn.decomposition
      • yobx.sklearn.decomposition.factor_analysis
      • yobx.sklearn.decomposition.fast_ica
      • yobx.sklearn.decomposition.gaussian_random_projection
      • yobx.sklearn.decomposition.incremental_pca
      • yobx.sklearn.decomposition.kernel_pca
      • yobx.sklearn.decomposition.latent_dirichlet_allocation
      • yobx.sklearn.decomposition.nmf
      • yobx.sklearn.decomposition.pca
      • yobx.sklearn.decomposition.pls_regression
      • yobx.sklearn.decomposition.pls_svd
      • yobx.sklearn.decomposition.sparse_pca
      • yobx.sklearn.decomposition.truncated_svd
    • yobx.sklearn.discriminant_analysis
      • yobx.sklearn.discriminant_analysis.lda
      • yobx.sklearn.discriminant_analysis.qda
    • yobx.sklearn.dummy
      • yobx.sklearn.dummy.dummy
    • yobx.sklearn.ensemble
      • yobx.sklearn.ensemble.adaboost
      • yobx.sklearn.ensemble.bagging
      • yobx.sklearn.ensemble.gradient_boosting
      • yobx.sklearn.ensemble.hist_gradient_boosting
      • yobx.sklearn.ensemble.isolation_forest
      • yobx.sklearn.ensemble.random_forest
      • yobx.sklearn.ensemble.random_trees_embedding
      • yobx.sklearn.ensemble.stacking
      • yobx.sklearn.ensemble.voting
    • yobx.sklearn.feature_extraction
      • yobx.sklearn.feature_extraction.count_vectorizer
      • yobx.sklearn.feature_extraction.feature_hasher
      • yobx.sklearn.feature_extraction.patch_extractor
      • yobx.sklearn.feature_extraction.tfidf_transformer
      • yobx.sklearn.feature_extraction.tfidf_vectorizer
    • yobx.sklearn.feature_selection
      • yobx.sklearn.feature_selection.rfe
      • yobx.sklearn.feature_selection.select_fdr
      • yobx.sklearn.feature_selection.select_from_model
      • yobx.sklearn.feature_selection.select_fpr
      • yobx.sklearn.feature_selection.select_fwe
      • yobx.sklearn.feature_selection.select_k_best
      • yobx.sklearn.feature_selection.select_percentile
      • yobx.sklearn.feature_selection.variance_threshold
    • yobx.sklearn.gaussian_process
      • yobx.sklearn.gaussian_process.gp
    • yobx.sklearn.impute
      • yobx.sklearn.impute.knn_imputer
      • yobx.sklearn.impute.missing_indicator
      • yobx.sklearn.impute.simple_imputer
    • yobx.sklearn.imblearn
      • yobx.sklearn.imblearn.balanced_random_forest
      • yobx.sklearn.imblearn.easy_ensemble
      • yobx.sklearn.imblearn.balanced_bagging
      • yobx.sklearn.imblearn.rus_boost
    • yobx.sklearn.isotonic
      • yobx.sklearn.isotonic.isotonic_regression
    • yobx.sklearn.kernel_approximation
      • yobx.sklearn.kernel_approximation.additive_chi2_sampler
      • yobx.sklearn.kernel_approximation.nystroem
      • yobx.sklearn.kernel_approximation.rbf_sampler
    • yobx.sklearn.kernel_ridge
      • yobx.sklearn.kernel_ridge.kernel_ridge
    • yobx.sklearn.lightgbm
      • yobx.sklearn.lightgbm.lgbm
      • yobx.sklearn.lightgbm.lgbm_model
    • yobx.sklearn.linear_model
      • yobx.sklearn.linear_model.glm
      • yobx.sklearn.linear_model.linear_classifier
      • yobx.sklearn.linear_model.linear_regressor
      • yobx.sklearn.linear_model.logistic_regression
      • yobx.sklearn.linear_model.ransac
      • yobx.sklearn.linear_model.sgd_one_class_svm
    • yobx.sklearn.manifold
      • yobx.sklearn.manifold.isomap
      • yobx.sklearn.manifold.locally_linear_embedding
    • yobx.sklearn.mixture
      • yobx.sklearn.mixture.bayesian_gaussian_mixture
      • yobx.sklearn.mixture.gaussian_mixture
    • yobx.sklearn.model_selection
      • yobx.sklearn.model_selection.grid_search
      • yobx.sklearn.model_selection.halving_search
      • yobx.sklearn.model_selection.random_search
      • yobx.sklearn.model_selection.tuned_threshold_classifier_cv
    • yobx.sklearn.multiclass
      • yobx.sklearn.multiclass.one_vs_one
      • yobx.sklearn.multiclass.one_vs_rest
      • yobx.sklearn.multiclass.output_code
    • yobx.sklearn.multioutput
      • yobx.sklearn.multioutput.classifier_chain
      • yobx.sklearn.multioutput.multioutput
      • yobx.sklearn.multioutput.regressor_chain
    • yobx.sklearn.naive_bayes
      • yobx.sklearn.naive_bayes.categorical_nb
      • yobx.sklearn.naive_bayes.nb
    • yobx.sklearn.neural_network
      • yobx.sklearn.neural_network.bernoulli_rbm
      • yobx.sklearn.neural_network.mlp
    • yobx.sklearn.neighbors
      • yobx.sklearn.neighbors.kneighbors
      • yobx.sklearn.neighbors.kneighbors_transformer
      • yobx.sklearn.neighbors.kernel_density
      • yobx.sklearn.neighbors.local_outlier_factor
      • yobx.sklearn.neighbors.nearest_centroid
      • yobx.sklearn.neighbors.neighborhood_components_analysis
      • yobx.sklearn.neighbors.radiusneighbors
      • yobx.sklearn.neighbors.radiusneighbors_transformer
    • yobx.sklearn.pipeline
      • yobx.sklearn.pipeline.feature_union
      • yobx.sklearn.pipeline.pipeline
    • yobx.sklearn.preprocessing
      • yobx.sklearn.preprocessing.binarizer
      • yobx.sklearn.preprocessing.function_transformer
      • yobx.sklearn.preprocessing.kbins_discretizer
      • yobx.sklearn.preprocessing.kernel_centerer
      • yobx.sklearn.preprocessing.max_abs_scaler
      • yobx.sklearn.preprocessing.min_max_scaler
      • yobx.sklearn.preprocessing.normalizer
      • yobx.sklearn.preprocessing.one_hot_encoder
      • yobx.sklearn.preprocessing.ordinal_encoder
      • yobx.sklearn.preprocessing.polynomial_features
      • yobx.sklearn.preprocessing.power_transformer
      • yobx.sklearn.preprocessing.quantile_transformer
      • yobx.sklearn.preprocessing.robust_scaler
      • yobx.sklearn.preprocessing.spline_transformer
      • yobx.sklearn.preprocessing.standard_scaler
    • yobx.sklearn.sksurv
      • yobx.sklearn.sksurv.ensemble
      • yobx.sklearn.sksurv.linear_model
    • yobx.sklearn.statsmodels
      • yobx.sklearn.statsmodels.glm
    • yobx.sklearn.svm
      • yobx.sklearn.svm.linear_svm
      • yobx.sklearn.svm.one_class_svm
      • yobx.sklearn.svm.svm
    • yobx.sklearn.tree
      • yobx.sklearn.tree.decision_tree
      • yobx.sklearn.tree (ExtraTree)
    • yobx.sklearn.xgboost
      • yobx.sklearn.xgboost.xgb
  • yobx.tensorflow
    • yobx.tensorflow.to_onnx
    • yobx.tensorflow.convert
    • yobx.tensorflow.register
    • yobx.tensorflow.tensorflow_helper
    • yobx.tensorflow.ops
      • yobx.tensorflow.ops.activations
      • yobx.tensorflow.ops.binary_ops
      • yobx.tensorflow.ops.const
      • yobx.tensorflow.ops.conv
      • yobx.tensorflow.ops.element_wise
      • yobx.tensorflow.ops.gather_ops
      • yobx.tensorflow.ops.jax_ops
      • yobx.tensorflow.ops.math_ops
      • yobx.tensorflow.ops.matmul
      • yobx.tensorflow.ops.nn_ops
      • yobx.tensorflow.ops.padding
      • yobx.tensorflow.ops.pooling
      • yobx.tensorflow.ops.random_ops
      • yobx.tensorflow.ops.reduction_ops
      • yobx.tensorflow.ops.shape_ops
      • yobx.tensorflow.ops.special_ops
      • yobx.tensorflow.ops.unary_ops
      • yobx.tensorflow.ops.xla_call_module
      • yobx.tensorflow.ops.xla_call_module_helper
      • yobx.tensorflow.ops.xla_call_module_layer
      • yobx.tensorflow.ops.xla_call_module_parsing
  • yobx.torch
    • yobx.torch.to_onnx
    • yobx.torch.export_helper
    • yobx.torch.export_options
    • yobx.torch.fake_tensor_helper
    • yobx.torch.flatten
    • yobx.torch.input_observer
    • yobx.torch.patch
    • yobx.torch.tiny_models
    • yobx.torch.torch_helper
    • yobx.torch.tracing
    • yobx.torch.validate
    • yobx.torch.in_torch
      • yobx.torch.coverage.op_coverage
    • yobx.torch.coverage
      • yobx.torch.in_torch.patches
    • yobx.torch.in_transformers
      • yobx.torch.in_transformers._patches_model_rope_utils
      • yobx.torch.in_transformers.cache_helper
      • yobx.torch.in_transformers.flatten_class
      • yobx.torch.in_transformers.patches
      • yobx.torch.in_transformers.register
      • yobx.torch.in_transformers.models
        • yobx.torch.in_transformers.models.configs
      • yobx.torch.in_transformers.classes
        • yobx.torch.in_transformers.classes.llama_attention
    • yobx.torch.interpreter
      • yobx.torch.interpreter._aten_functions
      • yobx.torch.interpreter._aten_functions_attention
      • yobx.torch.interpreter._aten_getitem
      • yobx.torch.interpreter._aten_functions_transformers
      • yobx.torch.interpreter._aten_methods
      • yobx.torch.interpreter._doc_
      • yobx.torch.interpreter._exceptions
      • yobx.torch.interpreter._math_functions
      • yobx.torch.interpreter._non_aten_functions
      • yobx.torch.interpreter._prims_functions
      • yobx.torch.interpreter._torch_helper
      • yobx.torch.interpreter.aten_functions
      • yobx.torch.interpreter.aten_functions_transformers
      • yobx.torch.interpreter.aten_methods
      • yobx.torch.interpreter.dispatcher
      • yobx.torch.interpreter.interpreter
      • yobx.torch.interpreter.onnx_export
    • yobx.torch.new_tracing
      • yobx.torch.new_tracing.shape
      • yobx.torch.new_tracing.tensor
      • yobx.torch.new_tracing.tracer
    • yobx.torch.testing
      • yobx.torch.testing._model_eval_cases
      • yobx.torch.testing.model_eval_cases

documentation / tests

  • yobx.doc
  • yobx.ext_test_case
  • yobx.pv_version
  • API
  • yobx.xoptim
  • yobx.xoptim.patterns_ort
  • yobx.xoptim.patterns_ort.greedy_search

yobx.xoptim.patterns_ort.greedy_search#

class yobx.xoptim.patterns_ort.greedy_search.GreedySearchPattern(verbose: int = 0, priority: int = 2)[source]#

Ensures com.microsoft.GreedySearch receives INT32 integer inputs.

The ORT contrib operator GreedySearch requires all integer tensors (input_ids, max_length, min_length, vocab_mask, prefix_vocab_mask, and attention_mask) to be of type INT32. PyTorch typically produces INT64 tensors, so without this pattern the node would fail at runtime.

This pattern matches any com.microsoft.GreedySearch node that has at least one integer input with dtype INT64 and inserts Cast(INT64→INT32) nodes for every such input.

Model with nodes to be fused:

        graph TD

    classDef ioNode fill:#dfd,stroke:#333,color:#333
    classDef initNode fill:#cccc00,stroke:#333,color:#333
    classDef constNode fill:#f9f,stroke:#333,stroke-width:2px,color:#333
    classDef opNode fill:#bbf,stroke:#333,stroke-width:2px,color:#333

    I_input_ids(["input_ids INT64(batch, seq)"])
    I_max_length(["max_length INT64(1)"])

    GreedySearch_0[["com.microsoft.GreedySearch(.decoder, .)"]]

    I_input_ids -->|"INT64(batch, seq)"| GreedySearch_0
    I_max_length -->|"INT64(1)"| GreedySearch_0

    O_sequences(["sequences INT32(batch, max_seq)"])
    GreedySearch_0 --> O_sequences

    class I_input_ids,I_max_length,O_sequences ioNode
    class GreedySearch_0 opNode
    

Outcome of the fusion:

        graph TD

    classDef ioNode fill:#dfd,stroke:#333,color:#333
    classDef initNode fill:#cccc00,stroke:#333,color:#333
    classDef constNode fill:#f9f,stroke:#333,stroke-width:2px,color:#333
    classDef opNode fill:#bbf,stroke:#333,stroke-width:2px,color:#333

    I_input_ids(["input_ids INT64(batch, seq)"])
    I_max_length(["max_length INT64(1)"])

    Cast_0[["Cast(., to=INT32)"]]
    Cast_1[["Cast(., to=INT32)"]]
    GreedySearch_2[["com.microsoft.GreedySearch(.decoder, .)"]]

    I_input_ids -->|"INT64(batch, seq)"| Cast_0
    I_max_length -->|"INT64(1)"| Cast_1
    Cast_0 -->|"INT32(batch, seq)"| GreedySearch_2
    Cast_1 -->|"INT32(1)"| GreedySearch_2

    O_sequences(["sequences INT32(batch, max_seq)"])
    GreedySearch_2 --> O_sequences

    class I_input_ids,I_max_length,O_sequences ioNode
    class Cast_0,Cast_1,GreedySearch_2 opNode
    
apply(g: GraphBuilder, node: NodeProto) → List[NodeProto][source]#

The method does the rewriting. It assumes it can happen. It takes a list of nodes impacted by the rewriting assumes no other pattern optimizer will be modify them. It receives the list of nodes returned by method apply. Since it is a list of argument, method match can include None values. The method returns the new nodes. The optimizer considers that any node given to this function is removed from the graph, and any node returned by it are added. If a received node must be kept, it must be added to the list of returned node.

Parameters:

nodes – nodes returned by method match, there are then removed

Returns:

nodes to add to graph.

match(g: GraphBuilderPatternOptimization, node: NodeProto, matched: List[MatchResult]) → MatchResult | None[source]#

Determines nodes around node which can be rewritten.

Parameters:
  • g – is a GraphBuilderPatternOptimization, it holds all the existing nodes, is able to return any information about type, shape, the node before, the node after another one.

  • node – the matching must determine if some nodes around this one are part of set of nodes this pattern optimizer can rewrite. From there, the function explores wherever it needs, checking any condition it needs.

  • matched – usually unused, it returns of nodes already matching a pattern

The method must not modify the graph. The method returns None if no match is found or an instance of class MatchResult. It must contain:

  • a list of nodes involved in the rewriting. It does not mean all of them will be removed but all of them are needed to do the rewriting and must not be impacted by other pattern optimizer.

  • A function doing the rewriting (usually method apply of the pattern class).

  • An existing node where the rewritten nodes can be inserted. Knowing it makes it faster to rewriter. If not specified, the optimizer will automatically determine the position of the new nodes.

previous

yobx.xoptim.patterns_ort.fused_matmul

next

yobx.xoptim.patterns_ort.llm_optim

On this page
  • GreedySearchPattern
    • GreedySearchPattern.apply()
    • GreedySearchPattern.match()

This Page

  • Show Source

Created using Sphinx 9.0.4.

Built with the PyData Sphinx Theme 0.16.1.