From 8f31e381846afade3e966a2eb9d216d3e61f6992 Mon Sep 17 00:00:00 2001 From: Bangtian Liu Date: Thu, 19 Dec 2024 00:03:38 -0800 Subject: [PATCH] update tuning.md and test file Signed-off-by: Bangtian Liu --- .../Codegen/Common/test/verify_tuning_specs.mlir | 11 ++++++++++- .../Codegen/Dialect/Codegen/IR/IREECodegenAttrs.h | 2 +- .../Codegen/Dialect/Codegen/IR/IREECodegenDialect.cpp | 6 +++--- docs/website/docs/reference/tuning.md | 2 ++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/compiler/src/iree/compiler/Codegen/Common/test/verify_tuning_specs.mlir b/compiler/src/iree/compiler/Codegen/Common/test/verify_tuning_specs.mlir index 691a522c550d3..6a3c6b292ecd6 100644 --- a/compiler/src/iree/compiler/Codegen/Common/test/verify_tuning_specs.mlir +++ b/compiler/src/iree/compiler/Codegen/Common/test/verify_tuning_specs.mlir @@ -54,6 +54,15 @@ module @foo_module attributes { transform.with_named_sequence } { // ----- -// expected-error @+1{{The default tuning specification must include an operation with the symbol name '__kernel_config'}} +// expected-error @+1{{The tuning specification must include a named sequence with the symbol name '__kernel_config'}} module @iree_default_tuning_spec attributes { iree_codegen.tuning_spec_with_default_entrypoint } { } + +// ----- + +// expected-error @+1{{The tuning specification must include a named sequence with the symbol name '__kernel_config'}} +module @iree_default_tuning_spec attributes { iree_codegen.tuning_spec_with_default_entrypoint } { + func.func @__kernel_config(%arg0: i32) -> () { + return + } +} diff --git a/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenAttrs.h b/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenAttrs.h index d80d1a961341f..cae3f08295996 100644 --- a/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenAttrs.h +++ b/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenAttrs.h @@ -45,7 +45,7 @@ namespace mlir::iree_compiler { // Constant names. //===----------------------------------------------------------------------===// constexpr StringLiteral kConfigAttrName = "lowering_config"; -constexpr StringLiteral kTuningDefaultSpecAttrName = +constexpr StringLiteral kTuningSpecDefaultEntrypointAttrName = "iree_codegen.tuning_spec_with_default_entrypoint"; constexpr StringLiteral kTuningSpecEntrypointAttrName = "iree_codegen.tuning_spec_entrypoint"; diff --git a/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenDialect.cpp b/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenDialect.cpp index 68e2fe7233808..afd1d6232b04a 100644 --- a/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenDialect.cpp +++ b/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenDialect.cpp @@ -64,7 +64,7 @@ IREECodegenDialect::verifyOperationAttribute(Operation *op, // b. It must have exactly one argument type, and the argument must be // of type `transform::AnyOpType`. - if (symbol == kTuningDefaultSpecAttrName) { + if (symbol == kTuningSpecDefaultEntrypointAttrName) { if (auto moduleOp = dyn_cast(op)) { if (!llvm::any_of(moduleOp.getOps(), [](auto &op) { if (auto namedSeqOp = dyn_cast(&op)) { @@ -75,8 +75,8 @@ IREECodegenDialect::verifyOperationAttribute(Operation *op, return false; })) { return moduleOp.emitError() - << "The default tuning specification must include an " - "operation with the symbol name '" + << "The tuning specification must include a named " + "sequence with the symbol name '" << kKernelConfigSpecName << "'."; } } diff --git a/docs/website/docs/reference/tuning.md b/docs/website/docs/reference/tuning.md index 5dea9b4842820..f3e46276366a0 100644 --- a/docs/website/docs/reference/tuning.md +++ b/docs/website/docs/reference/tuning.md @@ -123,6 +123,8 @@ that conform to the following format: `!transform.any_op`. * All entry points in the final tuning specs must either read (`transform.readonly`) or consume (`transform.consumed`) the argument. +* The `iree_codegen.tuning_spec_with_default_entrypoint` attribute ensures that + the tuning spec includes a named sequence op marked with `__kernel_config`. The tuning spec above attempts to match `linalg.generic` ops that correspond to the matmul operation with the RHS operand transposed (a.k.a. mmt) of shape