Skip to content

Commit 57abfe1

Browse files
AnnuCodeTai78641
authored andcommitted
Use Tosa_I32EnumAttr instead of StringBasedAttr to represent Tosa enumerations.
This PR replaces `StringBasedAttr` with `Tosa_I32EnumAttr` to represent Tosa enumerations as per the specification. The intent is to make the IR and C++ APIs more type-safe and prevent fragile string comparisons in passes. Enumerations rewritten are: - `Tosa_ResizeTypeAttr` - `Tosa_NanPropagationAttr` - `Tosa_RoundingTypeAttr` BREAKING CHANGE: This commit changes attribute assembly and the C++ API surface for the listed attributes. Code that previously used `StringAttr` for these fields must now be updated to use the new enum representation. In `.mlir` files, replace string literals with the enum assembly (e.g. `mode = #tosa.resize_type<BILINEAR>`). In C++, update call sites to either pass the generated enum (e.g. `::mlir::tosa::RoundingType::SINGLE_ROUND`) into builder overloads or construct the typed attribute with `tosa::RoundingTypeAttr::get(context, /*enum*/)` and pass that. Change-Id: Ic101ddfc3bef73a08ab2d6f59f54598c8e0dbad8
1 parent f65f60e commit 57abfe1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,9 @@ struct TosaValidation : public tosa::impl::TosaValidationBase<TosaValidation> {
514514
<< "failed attribute check: rounding_mode = DOUBLE_ROUND "
515515
<< "requires extension [doubleround]";
516516
return false;
517-
} else if (rescale.getRoundingMode() == RoundingMode::INEXACT_ROUND &&
518-
!targetEnv.allows(Extension::inexactround)) {
517+
}
518+
if (rescale.getRoundingMode() == RoundingMode::INEXACT_ROUND &&
519+
!targetEnv.allows(Extension::inexactround)) {
519520
op->emitOpError()
520521
<< "failed attribute check: rounding_mode = INEXACT_ROUND "
521522
<< "requires extension [inexactround]";

0 commit comments

Comments
 (0)