Skip to content

Commit bf29a4f

Browse files
committed
[mlir][tosa] Avoid requirement to specify enum name for enum attributes
This commit updates the printer/parser of operations that use enum type attributes such that they aren't required to specify the full enum name e.g. `rounding_mode = #tosa.rounding_mode<SINGLE_ROUND>` becomes `rounding_mode = SINGLE_ROUND`. For compatibility, text with #tosa.rounding_mode<...> will still be accepted by the parser. Change-Id: Ic19c961069a297d442450fdab3dc727b0b64bd1a Signed-off-by: Tai Ly <tai.ly@arm.com>
1 parent 8754f57 commit bf29a4f

24 files changed

+580
-192
lines changed

mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -391,22 +391,22 @@ def Tosa_RESIZE_BILINEAR : I32EnumAttrCase<"BILINEAR", 2>;
391391

392392
def Tosa_ResizeModeAttr
393393
: Tosa_I32EnumAttr<"ResizeMode", "Supported resize/upsampling strategies", "resize_mode",
394-
[Tosa_RESIZE_NEAREST_NEIGHBOR, Tosa_RESIZE_BILINEAR]>;
394+
[Tosa_RESIZE_NEAREST_NEIGHBOR, Tosa_RESIZE_BILINEAR]>;
395395

396396
def Tosa_NANPROPAGATION_PROPAGATE : I32EnumAttrCase<"PROPAGATE", 1>;
397397
def Tosa_NANPROPAGATION_IGNORE : I32EnumAttrCase<"IGNORE", 2>;
398398

399399
def Tosa_NanPropagationModeAttr
400400
: Tosa_I32EnumAttr<"NanPropagationMode", "Supported NaN propagation strategies", "nan_mode",
401-
[Tosa_NANPROPAGATION_PROPAGATE, Tosa_NANPROPAGATION_IGNORE]>;
401+
[Tosa_NANPROPAGATION_PROPAGATE, Tosa_NANPROPAGATION_IGNORE]>;
402402

403403
def Tosa_ROUNDING_SINGLE_ROUND : I32EnumAttrCase<"SINGLE_ROUND", 1>;
404404
def Tosa_ROUNDING_INEXACT_ROUND : I32EnumAttrCase<"INEXACT_ROUND", 2>;
405405
def Tosa_ROUNDING_DOUBLE_ROUND : I32EnumAttrCase<"DOUBLE_ROUND", 3>;
406406

407407
def Tosa_RoundingModeAttr
408408
: Tosa_I32EnumAttr<"RoundingMode", "Supported rounding modes", "rounding_mode",
409-
[Tosa_ROUNDING_SINGLE_ROUND, Tosa_ROUNDING_INEXACT_ROUND, Tosa_ROUNDING_DOUBLE_ROUND]>;
409+
[Tosa_ROUNDING_SINGLE_ROUND, Tosa_ROUNDING_INEXACT_ROUND, Tosa_ROUNDING_DOUBLE_ROUND]>;
410410

411411

412412
//===----------------------------------------------------------------------===//
@@ -472,33 +472,26 @@ class Tosa_ElementwiseOp<string mnemonic, list<Trait> traits = []> :
472472
ResultsBroadcastableShape,
473473
TosaElementwiseOperator,
474474
SameOperandsAndResultRank,
475-
Pure])> {
476-
let assemblyFormat =
477-
"operands attr-dict `:` functional-type(operands, results)";
478-
}
475+
Pure])> {}
479476

480477
class Tosa_ElementwiseUnaryOp<string mnemonic, list<Trait> traits = []> :
481478
Tosa_ElementwiseOp<mnemonic, !listconcat(traits, [
482479
SameOperandsAndResultShape,
483480
SameOperandsAndResultElementType])> {}
484481

485482
class Tosa_InferTensorTypeOp<string mnemonic, list<Trait> traits = []>
486-
: Tosa_Op<mnemonic, !listconcat(traits, [InferTensorTypeAdaptor, Pure])> {
487-
let assemblyFormat =
488-
"operands attr-dict `:` functional-type(operands, results)";
489-
}
483+
: Tosa_Op<mnemonic, !listconcat(traits, [InferTensorTypeAdaptor, Pure])> {}
490484

491485
class Tosa_InferShapedTypeOp<string mnemonic, list<Trait> traits = []>
492-
: Tosa_Op<mnemonic, !listconcat(traits, [InferShapedTypeOpAdaptor, Pure])> {
493-
let assemblyFormat =
494-
"operands attr-dict `:` functional-type(operands, results)";
495-
}
486+
: Tosa_Op<mnemonic, !listconcat(traits, [InferShapedTypeOpAdaptor, Pure])> {}
496487

497488
// The "SameVariadicOperandSize" trait allows us to pass optional arguments
498489
// for multiple zero points in convolution ops.
499490
class Tosa_ConvOp<string mnemonic, list<Trait> traits = []>
500491
: Tosa_InferShapedTypeOp<mnemonic, !listconcat(traits,
501492
[SameVariadicOperandSize])> {
493+
let assemblyFormat =
494+
"operands attr-dict `:` functional-type(operands, results)";
502495
}
503496

504497
#endif // TOSA_OP_BASE

0 commit comments

Comments
 (0)