Skip to content

Commit 2562998

Browse files
authored
[Encoding][NFC] Use assemblyFormat for testing encodings. (#20520)
Signed-off-by: hanhanW <[email protected]>
1 parent b64da91 commit 2562998

File tree

2 files changed

+13
-70
lines changed

2 files changed

+13
-70
lines changed

compiler/src/iree/compiler/Dialect/Encoding/IR/EncodingAttrs.cpp

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -666,65 +666,12 @@ TestingEncodingAttr::cloneWithLayouts(ArrayRef<Attribute> layouts) const {
666666
return TestingEncodingAttr::get(ctx, ArrayAttr::get(ctx, layouts));
667667
}
668668

669-
Attribute UnspecializedEncodingAttr::parse(AsmParser &p, Type type) {
670-
if (failed(p.parseLess())) {
671-
return {};
672-
}
673-
IntegerAttr seed;
674-
if (failed(p.parseAttribute(seed))) {
675-
return {};
676-
}
677-
if (failed(p.parseGreater())) {
678-
return {};
679-
}
680-
return get(p.getContext(), seed);
681-
}
682-
683-
void UnspecializedEncodingAttr::print(AsmPrinter &p) const {
684-
auto &os = p.getStream();
685-
os << "<";
686-
p.printAttributeWithoutType(getSeed());
687-
os << ">";
688-
}
689-
690669
Attribute
691670
UnspecializedEncodingAttr::cloneWithSimplifiedConfig(DictionaryAttr) const {
692671
MLIRContext *ctx = getContext();
693672
return SpecializedEncodingAttr::get(ctx, getSeed(), /*type=*/{});
694673
}
695674

696-
Attribute SpecializedEncodingAttr::parse(AsmParser &p, Type type) {
697-
if (failed(p.parseLess())) {
698-
return {};
699-
}
700-
701-
IntegerAttr seed;
702-
if (failed(p.parseAttribute(seed))) {
703-
return {};
704-
}
705-
706-
TypeAttr typeAttr;
707-
if (succeeded(p.parseOptionalComma()) && failed(p.parseAttribute(typeAttr))) {
708-
return {};
709-
}
710-
711-
if (failed(p.parseGreater())) {
712-
return {};
713-
}
714-
return get(p.getContext(), seed, typeAttr);
715-
}
716-
717-
void SpecializedEncodingAttr::print(AsmPrinter &p) const {
718-
auto &os = p.getStream();
719-
os << "<";
720-
p.printAttributeWithoutType(getSeed());
721-
if (auto typeAttr = getType()) {
722-
os << ", ";
723-
p.printAttribute(typeAttr);
724-
}
725-
os << ">";
726-
}
727-
728675
Attribute SpecializedEncodingAttr::getLayout(RankedTensorType type) const {
729676
MLIRContext *ctx = getContext();
730677
return get(ctx, getSeed(), TypeAttr::get(type.dropEncoding()));

compiler/src/iree/compiler/Dialect/Encoding/IR/EncodingAttrs.td

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -369,24 +369,21 @@ def UnspecializedEncodingAttr :
369369
]>
370370
]> {
371371
let mnemonic = "unspecialized_encoding";
372+
let assemblyFormat = "`<` $seed `>`";
372373

373374
let summary = "An attribute that indicates the encoding is not yet specialized";
374375

375376
let description = [{
376377
This attribute indicates this is an unspecialized encoding. It implements
377-
very basic interface methods of EncodingLayoutResolverAttrInterface that converts
378-
it to the SpecializeEncodingAttr during encoding specialization. It is
379-
mainly for testing purpose as some transformations do not depend on actual
380-
dialects that implement the attribute interface.
381-
}];
378+
very basic interface methods of EncodingLayoutResolverAttrInterface that
379+
converts it to the SpecializeEncodingAttr during encoding specialization.
380+
It is mainly for testing purpose as some transformations do not depend on
381+
actual dialects that implement the attribute interface.
382382

383-
let parameters = (ins
384-
AttrParameter<"IntegerAttr", "The seed that attached on the attribute. "
385-
"Different seed values indicate different layouts.">:$seed
386-
);
383+
Different seed values indicate different layouts.
384+
}];
387385

388-
let hasCustomAssemblyFormat = 1;
389-
let genVerifyDecl = 0;
386+
let parameters = (ins "int32_t":$seed);
390387
}
391388

392389
def SpecializedEncodingAttr :
@@ -397,6 +394,7 @@ def SpecializedEncodingAttr :
397394
IREEEncoding_SerializableEncodingAttrInterface
398395
]> {
399396
let mnemonic = "specialized_encoding";
397+
let assemblyFormat = "`<` $seed (`,` $type^)? `>`";
400398

401399
let summary = "An attribute that indicates the encoding is specialized";
402400

@@ -405,16 +403,14 @@ def SpecializedEncodingAttr :
405403
type. The attribute denotes the layout of the type. Different seed values
406404
indicate different layouts, which can be used to emulate different encoding
407405
attributes.
406+
407+
Different seed values indicate different layouts.
408408
}];
409409

410410
let parameters = (ins
411-
AttrParameter<"IntegerAttr", "The seed that attached on the attribute. "
412-
"Different seed values indicate different layouts.">:$seed,
413-
AttrParameter<"TypeAttr", "">:$type
411+
"int32_t":$seed,
412+
OptionalParameter<"TypeAttr", "">:$type
414413
);
415-
416-
let hasCustomAssemblyFormat = 1;
417-
let genVerifyDecl = 0;
418414
}
419415

420416
#endif // IREE_DIALECT_ENCODING_ATTRS

0 commit comments

Comments
 (0)