Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Codegen][Tuner] verifier for the default tuning spec #19525

Merged
merged 6 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
// Check that both the user tuning spec and the default spec get linked and
// materialized. The user spec should have precedence over the default one.

// BOTH-LABEL: module @iree_linked_tuning_spec attributes {transform.with_named_sequence}
// BOTH-LABEL: module @iree_linked_tuning_spec attributes {iree_codegen.tuning_spec_with_default_entrypoint, transform.with_named_sequence}
bangtianliu marked this conversation as resolved.
Show resolved Hide resolved
// BOTH-LABEL: module @mmt_tile_and_fuse_spec_0 attributes {transform.with_named_sequence}
// BOTH-LABEL: transform.named_sequence @main
// BOTH-SAME: attributes {iree_codegen.tuning_spec_entrypoint}
// BOTH-LABEL: module @iree_default_tuning_spec_gfx942_1 attributes {iree_codegen.tuning_spec_with_default_entrypoint, transform.with_named_sequence}
// BOTH-LABEL: module @iree_default_tuning_spec_gfx942_1 attributes {transform.with_named_sequence}
// BOTH: transform.named_sequence @__kernel_config
// BOTH-SAME: attributes {iree_codegen.tuning_spec_entrypoint}
// BOTH: transform.named_sequence @__kernel_config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ emitLinkedTuningSpec(ModuleOp module, ArrayRef<NamedSequenceOp> specsToLink) {
0, hasConsumedSequences ? kArgConsumedAttrName : kArgReadOnlyAttrName,
builder.getUnitAttr());
newSpec->setAttr(kTuningSpecEntrypointAttrName, builder.getUnitAttr());
// As the newSpec is a named sequence operation with the symbol name
// '__kernel_config', the module should add the unit attribute
// 'iree_codegen.tuning_spec_with_default_entrypoint' to indicate this change.
bangtianliu marked this conversation as resolved.
Show resolved Hide resolved
bangtianliu marked this conversation as resolved.
Show resolved Hide resolved
module->setAttr(kTuningDefaultSpecAttrName, builder.getUnitAttr());

Region &region = newSpec.getRegion();
Block *body = builder.createBlock(&region, region.begin(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ struct MaterializeTuningSpecsPass final
UnitAttr::get(ctx));
for (auto [idx, spec] : llvm::enumerate(allSpecs)) {
ModuleOp clonedSpec = spec.clone();
// Drop the module-level attribute due to renamed entrypoints during
// linking.
if (clonedSpec->hasAttr(kTuningDefaultSpecAttrName)) {
clonedSpec->removeAttr(kTuningDefaultSpecAttrName);
}
// Make sure there are no symbol name collisions.
clonedSpec.setSymName(
llvm::formatv("{}_{}", clonedSpec.getSymName().value(), idx).str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ IREECodegenDialect::verifyOperationAttribute(Operation *op,
if (auto moduleOp = dyn_cast<ModuleOp>(op)) {
if (!llvm::any_of(moduleOp.getOps(), [](auto &op) {
bangtianliu marked this conversation as resolved.
Show resolved Hide resolved
bangtianliu marked this conversation as resolved.
Show resolved Hide resolved
if (auto namedSeqOp = dyn_cast<transform::NamedSequenceOp>(&op)) {
return SymbolTable::getSymbolName(namedSeqOp)
.getValue()
.contains(kKernelConfigSpecName);
return SymbolTable::getSymbolName(namedSeqOp).getValue() ==
kKernelConfigSpecName;
bangtianliu marked this conversation as resolved.
Show resolved Hide resolved
}
return false;
})) {
Expand Down
Loading