@@ -72,15 +72,40 @@ IREECodegenDialect::verifyOperationAttribute(Operation *op,
72
72
73
73
if (symbol == kTuningSpecDefaultEntrypointAttrName ) {
74
74
if (auto moduleOp = dyn_cast<ModuleOp>(op)) {
75
- if (!llvm::any_of (moduleOp.getOps <transform::NamedSequenceOp>(),
75
+ auto kernelConfigOpIt =
76
+ llvm::find_if (moduleOp.getOps <transform::NamedSequenceOp>(),
76
77
[](transform::NamedSequenceOp op) {
77
78
return op.getName () == kKernelConfigSpecName ;
78
- })) {
79
+ });
80
+
81
+ if (kernelConfigOpIt ==
82
+ moduleOp.getOps <transform::NamedSequenceOp>().end ()) {
79
83
return moduleOp.emitError ()
80
- << " The tuning specification must include a named "
81
- " sequence with the symbol name '"
84
+ << " The tuning specification must include a named sequence with "
85
+ " the symbol name '"
82
86
<< kKernelConfigSpecName << " '." ;
83
87
}
88
+
89
+ transform::NamedSequenceOp kernelConfigOp = *kernelConfigOpIt;
90
+
91
+ // Verify that the NamedSequenceOp has the attribute
92
+ // `kTuningSpecEntrypointAttrName`.
93
+ if (!kernelConfigOp->hasAttr (kTuningSpecEntrypointAttrName )) {
94
+ return kernelConfigOp.emitError ()
95
+ << " The named sequence '" << kKernelConfigSpecName
96
+ << " ' must have the attribute '" << kTuningSpecEntrypointAttrName
97
+ << " '." ;
98
+ }
99
+
100
+ // Ensure there is exactly one ForeachMatchOp inside the NamedSequenceOp.
101
+ auto foreachMatchOps =
102
+ llvm::to_vector (kernelConfigOp.getOps <transform::ForeachMatchOp>());
103
+ if (foreachMatchOps.size () != 1 ) {
104
+ return kernelConfigOp.emitError ()
105
+ << " The named sequence '" << kKernelConfigSpecName
106
+ << " ' must contain exactly one 'ForeachMatchOp', but found "
107
+ << foreachMatchOps.size () << " ." ;
108
+ }
84
109
}
85
110
}
86
111
0 commit comments