@@ -23,7 +23,7 @@ operations. This open and extensible ecosystem leads to the "stringly" type IR
23
23
problem, e.g., repetitive string comparisons during optimization and analysis
24
24
passes, unintuitive accessor methods (e.g., generic/error prone ` getOperand(3) `
25
25
vs self-documenting ` getStride() ` ) with more generic return types, verbose and
26
- generic constructors without default arguments, verbose textual IR dump , and so
26
+ generic constructors without default arguments, verbose textual IR dumps , and so
27
27
on. Furthermore, operation verification is:
28
28
29
29
1 . best case: a central string-to-verification-function map,
@@ -57,7 +57,7 @@ including but not limited to:
57
57
58
58
We use TableGen as the language for specifying operation information. TableGen
59
59
itself just provides syntax for writing records; the syntax and constructs
60
- allowed in a TableGen file (typically with filename suffix ` .td ` ) can be found
60
+ allowed in a TableGen file (typically with the filename suffix ` .td ` ) can be found
61
61
[ here] [ TableGenProgRef ] .
62
62
63
63
* TableGen ` class ` is similar to C++ class; it can be templated and
@@ -80,7 +80,7 @@ types and expressions supported by TableGen.
80
80
MLIR defines several common constructs to help operation definition and provide
81
81
their semantics via a special [ TableGen backend] [ TableGenBackend ] :
82
82
[ ` OpDefinitionsGen ` ] [ OpDefinitionsGen ] . These constructs are defined in
83
- [ ` OpBase.td ` ] [ OpBase ] . The main ones are
83
+ [ ` OpBase.td ` ] [ OpBase ] . The main ones are:
84
84
85
85
* The ` Op ` class: It is the main construct for defining operations. All facts
86
86
regarding the operation are specified when specializing this class, with the
@@ -91,7 +91,7 @@ their semantics via a special [TableGen backend][TableGenBackend]:
91
91
and constraints of the operation, including whether the operation has side
92
92
effect or whether its output has the same shape as the input.
93
93
* The ` ins ` /` outs ` marker: These are two special markers builtin to the
94
- ` OpDefinitionsGen ` backend. They lead the definitions of operands/attributes
94
+ ` OpDefinitionsGen ` backend. They lead to the definitions of operands/attributes
95
95
and results respectively.
96
96
* The ` TypeConstraint ` class hierarchy: They are used to specify the
97
97
constraints over operands or results. A notable subclass hierarchy is
@@ -134,7 +134,7 @@ the `Op` class for the complete list of fields supported.
134
134
135
135
### Operation name
136
136
137
- The operation name is a unique identifier of the operation within MLIR, e.g.,
137
+ The operation name is a unique identifier for the operation within MLIR, e.g.,
138
138
` tf.Add ` for addition operation in the TensorFlow dialect. This is the
139
139
equivalent of the mnemonic in assembly language. It is used for parsing and
140
140
printing in the textual format. It is also used for pattern matching in graph
@@ -207,12 +207,13 @@ named argument a named getter will be generated that returns the argument with
207
207
the return type (in the case of attributes the return type will be constructed
208
208
from the storage type, while for operands it will be ` Value ` ). Each attribute's
209
209
raw value (e.g., as stored) can also be accessed via generated ` <name>Attr `
210
- getters for use in transformation passes where the more user friendly return
210
+ getters for use in transformation passes where the more user- friendly return
211
211
type is less suitable.
212
212
213
- All the arguments should be named to 1) provide documentation, 2) drive
214
- auto-generation of getter methods, 3) provide a handle to reference for other
215
- places like constraints.
213
+ All the arguments should be named to:
214
+ - provide documentation,
215
+ - drive auto-generation of getter methods, and
216
+ - provide a handle to reference for other places like constraints.
216
217
217
218
#### Variadic operands
218
219
@@ -221,7 +222,7 @@ To declare a variadic operand, wrap the `TypeConstraint` for the operand with
221
222
222
223
Normally operations have no variadic operands or just one variadic operand. For
223
224
the latter case, it is easy to deduce which dynamic operands are for the static
224
- variadic operand definition. Though , if an operation has more than one variable
225
+ variadic operand definition. However , if an operation has more than one variable
225
226
length operands (either optional or variadic), it would be impossible to
226
227
attribute dynamic operands to the corresponding static variadic operand
227
228
definitions without further information from the operation. Therefore, either
@@ -247,7 +248,7 @@ To declare an optional operand, wrap the `TypeConstraint` for the operand with
247
248
248
249
Normally operations have no optional operands or just one optional operand. For
249
250
the latter case, it is easy to deduce which dynamic operands are for the static
250
- operand definition. Though , if an operation has more than one variable length
251
+ operand definition. However , if an operation has more than one variable length
251
252
operands (either optional or variadic), it would be impossible to attribute
252
253
dynamic operands to the corresponding static variadic operand definitions
253
254
without further information from the operation. Therefore, either the
@@ -425,7 +426,7 @@ The first form provides basic uniformity so that we can create ops using the
425
426
same form regardless of the exact op. This is particularly useful for
426
427
implementing declarative pattern rewrites.
427
428
428
- The second and third forms are good for use in manually written code given that
429
+ The second and third forms are good for use in manually written code, given that
429
430
they provide better guarantee via signatures.
430
431
431
432
The third form will be generated if any of the op's attribute has different
@@ -434,14 +435,14 @@ from an unwrapped value (i.e., `Attr.constBuilderCall` is defined.)
434
435
Additionally, for the third form, if an attribute appearing later in the
435
436
`arguments` list has a default value, the default value will be supplied in the
436
437
declaration. This works for `BoolAttr`, `StrAttr`, `EnumAttr` for now and the
437
- list can grow in the future. So if possible, default valued attribute should be
438
+ list can grow in the future. So if possible, the default- valued attribute should be
438
439
placed at the end of the `arguments` list to leverage this feature. (This
439
440
behavior is essentially due to C++ function parameter default value placement
440
441
restrictions.) Otherwise, the builder of the third form will still be generated
441
442
but default values for the attributes not at the end of the `arguments` list
442
443
will not be supplied in the builder's signature.
443
444
444
- ODS will generate a builder that doesn't require return type specified if
445
+ ODS will generate a builder that doesn't require the return type specified if
445
446
446
447
* Op implements InferTypeOpInterface interface;
447
448
* All return types are either buildable types or are the same as a given
@@ -581,18 +582,18 @@ of these verification methods.
581
582
The verification of an operation involves several steps,
582
583
583
584
1 . StructuralOpTrait will be verified first, they can be run independently.
584
- 1 . ` verifyInvariants ` which is constructed by ODS, it verifies the type,
585
+ 2 . ` verifyInvariants ` which is constructed by ODS, it verifies the type,
585
586
attributes, .etc.
586
- 1 . Other Traits/Interfaces that have marked their verifier as ` verifyTrait ` or
587
+ 3 . Other Traits/Interfaces that have marked their verifier as ` verifyTrait ` or
587
588
` verifyWithRegions=0 ` .
588
- 1 . Custom verifier which is defined in the op and has marked ` hasVerifier=1 `
589
+ 4 . Custom verifier which is defined in the op and has been marked ` hasVerifier=1 `
589
590
590
591
If an operation has regions, then it may have the second phase,
591
592
592
593
1 . Traits/Interfaces that have marked their verifier as ` verifyRegionTrait ` or
593
594
` verifyWithRegions=1 ` . This implies the verifier needs to access the
594
595
operations in its regions.
595
- 1 . Custom verifier which is defined in the op and has marked
596
+ 2 . Custom verifier which is defined in the op and has been marked
596
597
` hasRegionVerifier=1 `
597
598
598
599
Note that the second phase will be run after the operations in the region are
0 commit comments