From 35eae5f544dd65576ec2d358ea33f43a806b2442 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 14:03:56 +0000 Subject: [PATCH 1/3] Initial plan From f824d05aa084c717e5681bea8ce5cc51e5232c34 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 14:18:15 +0000 Subject: [PATCH 2/3] Harden verification of hyperparams and vector shapes to only admit i64 entries Co-authored-by: ftynse <1512299+ftynse@users.noreply.github.com> Agent-Logs-Url: https://github.com/iree-org/wave/sessions/ae430a1c-845e-40e3-8b04-32d54bcce98e --- .../water/Dialect/Wave/IR/WaveAttrs.td | 1 + water/lib/Dialect/Wave/IR/WaveAttrs.cpp | 27 +++++++++++++++---- .../Dialect/Wave/attr-constraint-invalid.mlir | 10 ++++++- water/test/Dialect/Wave/ops-invalid.mlir | 5 ++++ 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/water/include/water/Dialect/Wave/IR/WaveAttrs.td b/water/include/water/Dialect/Wave/IR/WaveAttrs.td index a459c94d2d..bcf18e0188 100644 --- a/water/include/water/Dialect/Wave/IR/WaveAttrs.td +++ b/water/include/water/Dialect/Wave/IR/WaveAttrs.td @@ -506,6 +506,7 @@ def WaveHyperparameterAttr : AttrDef { let parameters = (ins "::mlir::DictionaryAttr":$mapping); let assemblyFormat = "`<` $mapping `>`"; + let genVerifyDecl = 1; let extraClassDeclaration = [{ /// Get the concrete value for a symbol name, returns std::nullopt if not found diff --git a/water/lib/Dialect/Wave/IR/WaveAttrs.cpp b/water/lib/Dialect/Wave/IR/WaveAttrs.cpp index 6f08d6d78f..687bdedeab 100644 --- a/water/lib/Dialect/Wave/IR/WaveAttrs.cpp +++ b/water/lib/Dialect/Wave/IR/WaveAttrs.cpp @@ -483,6 +483,12 @@ WaveIndexMappingAttr WaveIndexMappingAttr::removeInput(Attribute input) const { // WaveHyperparameterAttr //===----------------------------------------------------------------------===// +/// Returns true if `attr` is a signless i64 IntegerAttr. +static bool isI64IntegerAttr(Attribute attr) { + auto intAttr = dyn_cast(attr); + return intAttr && intAttr.getType().isSignlessInteger(64); +} + std::optional WaveHyperparameterAttr::getSymbolValue(StringRef symbolName) const { DictionaryAttr mapping = getMapping(); @@ -500,6 +506,18 @@ bool WaveHyperparameterAttr::hasSymbol(StringRef symbolName) const { return getMapping().get(symbolName) != nullptr; } +LogicalResult +WaveHyperparameterAttr::verify(function_ref emitError, + DictionaryAttr mapping) { + for (NamedAttribute attr : mapping) { + if (!isI64IntegerAttr(attr.getValue())) + return emitError() << "hyperparameter '" << attr.getName() + << "' must be an i64 integer value, got " + << attr.getValue(); + } + return success(); +} + //===----------------------------------------------------------------------===// // WaveSymbolAttr //===----------------------------------------------------------------------===// @@ -718,11 +736,10 @@ LogicalResult HardwareConstraintAttr::verify( if (vectorShapes) { for (NamedAttribute attr : vectorShapes) { // TODO: verify that attr.getName() is a valid WaveSymbol - Attribute value = attr.getValue(); - - if (!isa(value)) - return emitError() << attr.getName() - << " is not an IntegerAttr: " << attr.getValue(); + if (!isI64IntegerAttr(attr.getValue())) + return emitError() << "vector_shapes entry '" << attr.getName() + << "' must be an i64 integer value, got " + << attr.getValue(); } } diff --git a/water/test/Dialect/Wave/attr-constraint-invalid.mlir b/water/test/Dialect/Wave/attr-constraint-invalid.mlir index 127b0d9f4e..90fd5889d9 100644 --- a/water/test/Dialect/Wave/attr-constraint-invalid.mlir +++ b/water/test/Dialect/Wave/attr-constraint-invalid.mlir @@ -9,7 +9,7 @@ func.func private @test_num_dimensions_mismatch1() attributes { wave.constraints // ----- -// expected-error @below {{"M" is not an IntegerAttr: "BLOCK_M"}} +// expected-error @below {{vector_shapes entry 'M' must be an i64 integer value, got "BLOCK_M"}} #hw_constraint = #wave.hardware_constraint, @@ -18,6 +18,14 @@ func.func private @test_num_dimensions_mismatch2() attributes { wave.constraints // ----- +// expected-error @below {{vector_shapes entry 'M' must be an i64 integer value, got 1 : i32}} +#hw_constraint = #wave.hardware_constraint +func.func private @test_vector_shapes_non_i64() attributes { wave.constraints = [#hw_constraint] } + +// ----- + #hw_constraint = #wave.hardware_constraint #hw_constraint2 = #wave.hardware_constraint // expected-error @below {{only one hardware constraint is allowed}} diff --git a/water/test/Dialect/Wave/ops-invalid.mlir b/water/test/Dialect/Wave/ops-invalid.mlir index f661d4ffe4..20e3d8be7f 100644 --- a/water/test/Dialect/Wave/ops-invalid.mlir +++ b/water/test/Dialect/Wave/ops-invalid.mlir @@ -481,6 +481,11 @@ module attributes { wave.hyperparameters = #wave.hyperparameters<{}> } { // ----- +// expected-error @below {{hyperparameter 'A' must be an i64 integer value, got 42 : i32}} +module attributes { wave.hyperparameters = #wave.hyperparameters<{A = 42 : i32}> } {} + +// ----- + module attributes { wave.hyperparameters = #wave.hyperparameters<{A = 42, C = 43}> } { // expected-error @below {{region #0 block #0 argument type #0 uses symbolic value #wave.symbol<"B"> not provided as a hyperparameter}} // expected-note @below {{available symbols: A, C}} From 1106b5313b7e6ccae0939b4a201a6e242c6c3ef0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Mar 2026 09:03:50 +0000 Subject: [PATCH 3/3] Fix attribute name printing in error messages to use raw string (drop MLIR quotes) Co-authored-by: ftynse <1512299+ftynse@users.noreply.github.com> Agent-Logs-Url: https://github.com/iree-org/wave/sessions/09c361ea-f97c-4f64-970a-73114d9912d6 --- water/lib/Dialect/Wave/IR/WaveAttrs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/water/lib/Dialect/Wave/IR/WaveAttrs.cpp b/water/lib/Dialect/Wave/IR/WaveAttrs.cpp index 687bdedeab..be11353aa4 100644 --- a/water/lib/Dialect/Wave/IR/WaveAttrs.cpp +++ b/water/lib/Dialect/Wave/IR/WaveAttrs.cpp @@ -511,7 +511,7 @@ WaveHyperparameterAttr::verify(function_ref emitError, DictionaryAttr mapping) { for (NamedAttribute attr : mapping) { if (!isI64IntegerAttr(attr.getValue())) - return emitError() << "hyperparameter '" << attr.getName() + return emitError() << "hyperparameter '" << attr.getName().getValue() << "' must be an i64 integer value, got " << attr.getValue(); } @@ -737,7 +737,7 @@ LogicalResult HardwareConstraintAttr::verify( for (NamedAttribute attr : vectorShapes) { // TODO: verify that attr.getName() is a valid WaveSymbol if (!isI64IntegerAttr(attr.getValue())) - return emitError() << "vector_shapes entry '" << attr.getName() + return emitError() << "vector_shapes entry '" << attr.getName().getValue() << "' must be an i64 integer value, got " << attr.getValue(); }