File tree Expand file tree Collapse file tree 6 files changed +10
-10
lines changed
Expand file tree Collapse file tree 6 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 22
33This section demonstrates the use of the ` _allow_other_inputs ` option in pattern-based rewriting.
44The ` _allow_other_inputs ` option allows the pattern to match nodes that have additional inputs
5- beyond those specified in the pattern. If it is set to ` False ` (the default), then the node must
5+ beyond those specified in the pattern. If it is set to ` False ` (the default), then the node must
66have exactly the specified inputs for a successful match. If set to ` True ` , the pattern will
77match nodes that have the specified inputs plus any number of additional inputs.
88
@@ -22,6 +22,6 @@ This is particularly useful when matching operations like `Conv` that can have o
2222```
2323
2424In this example, the pattern matches ` Conv ` operations with any number of inputs. A ` Conv ` operation
25- might have 2 inputs (input and weight) or 3 inputs (input, weight, and bias). By setting
25+ might have 2 inputs (input and weight) or 3 inputs (input, weight, and bias). By setting
2626` _allow_other_inputs=True ` , our pattern will match both cases even though we only specify 2 inputs
27- in the pattern definition.
27+ in the pattern definition.
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ ONNX operators can belong to different domains:
1515:pyobject: custom_relu_pattern
1616```
1717
18- In this pattern, ` _domain="custom.domain" ` ensures that only ` Relu ` operations from the
18+ In this pattern, ` _domain="custom.domain" ` ensures that only ` Relu ` operations from the
1919"custom.domain" domain will be matched, not standard ONNX ` Relu ` operations.
2020
2121## Creating replacement operations in a specific domain
@@ -35,4 +35,4 @@ provide optimized implementations of standard operations.
3535
3636This example shows how domain-specific pattern matching can be used to migrate operations
3737between different operator domains, such as replacing custom domain operations with
38- standard ONNX operations or vice versa.
38+ standard ONNX operations or vice versa.
Original file line number Diff line number Diff line change @@ -68,4 +68,4 @@ def apply_rewrite(model):
6868
6969
7070_model_with_rewrite = apply_rewrite (_model )
71- onnx .checker .check_model (_model_with_rewrite )
71+ onnx .checker .check_model (_model_with_rewrite )
Original file line number Diff line number Diff line change @@ -83,4 +83,4 @@ def apply_rewrite(model):
8383# The rewrite rule will now match the Relu operation in the custom domain
8484# and replace it with a standard ONNX Relu operation
8585_model_with_rewrite = apply_rewrite (_model )
86- onnx .checker .check_model (_model_with_rewrite )
86+ onnx .checker .check_model (_model_with_rewrite )
Original file line number Diff line number Diff line change @@ -73,4 +73,4 @@ def apply_rewrite(model):
7373
7474
7575_model_with_rewrite = apply_rewrite (_model )
76- onnx .checker .check_model (_model_with_rewrite )
76+ onnx .checker .check_model (_model_with_rewrite )
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ specification ensures the pattern only matches operations with this specific out
2626In the replacement, ` _outputs=["first_half", "second_half"] ` creates two outputs with
2727descriptive names. This can make the replacement pattern more readable and maintainable.
2828
29- ** Important** : The number of outputs in the replacement pattern must match the number of
29+ ** Important** : The number of outputs in the replacement pattern must match the number of
3030outputs in the target pattern. Since the pattern specifies ` _outputs=2 ` , the replacement
3131must also produce exactly 2 outputs.
3232
@@ -40,4 +40,4 @@ The `_outputs` option is particularly important when:
4040- Working with operations that have variable numbers of outputs (like ` Split ` )
4141- Creating custom operations that need specific output configurations
4242- Ensuring pattern matching precision by specifying exact output counts
43- - Improving code readability by naming outputs in replacement patterns
43+ - Improving code readability by naming outputs in replacement patterns
You can’t perform that action at this time.
0 commit comments