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 2
2
3
3
This section demonstrates the use of the ` _allow_other_inputs ` option in pattern-based rewriting.
4
4
The ` _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
6
6
have exactly the specified inputs for a successful match. If set to ` True ` , the pattern will
7
7
match nodes that have the specified inputs plus any number of additional inputs.
8
8
@@ -22,6 +22,6 @@ This is particularly useful when matching operations like `Conv` that can have o
22
22
```
23
23
24
24
In 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
26
26
` _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:
15
15
:pyobject: custom_relu_pattern
16
16
```
17
17
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
19
19
"custom.domain" domain will be matched, not standard ONNX ` Relu ` operations.
20
20
21
21
## Creating replacement operations in a specific domain
@@ -35,4 +35,4 @@ provide optimized implementations of standard operations.
35
35
36
36
This example shows how domain-specific pattern matching can be used to migrate operations
37
37
between 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):
68
68
69
69
70
70
_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):
83
83
# The rewrite rule will now match the Relu operation in the custom domain
84
84
# and replace it with a standard ONNX Relu operation
85
85
_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):
73
73
74
74
75
75
_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
26
26
In the replacement, ` _outputs=["first_half", "second_half"] ` creates two outputs with
27
27
descriptive names. This can make the replacement pattern more readable and maintainable.
28
28
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
30
30
outputs in the target pattern. Since the pattern specifies ` _outputs=2 ` , the replacement
31
31
must also produce exactly 2 outputs.
32
32
@@ -40,4 +40,4 @@ The `_outputs` option is particularly important when:
40
40
- Working with operations that have variable numbers of outputs (like ` Split ` )
41
41
- Creating custom operations that need specific output configurations
42
42
- 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