Skip to content

Conversation

@lhutton1
Copy link
Contributor

The requirement for a boolean condition is already checked for both operators elsewhere. cond_if requires a boolean condition at construction. while_loop cond_graph is checked in the verifier for a scalar boolean output type.

The requirement for a boolean condition is already checked for both
operators elsewhere. `cond_if` requires a boolean condition at
construction. `while_loop` cond_graph is checked in the verifier for
a scalar boolean output type.

Change-Id: I508dc664a44cf163fcc3fb7731ae8369424de132
@llvmbot
Copy link
Member

llvmbot commented Jul 11, 2025

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-tosa

Author: Luke Hutton (lhutton1)

Changes

The requirement for a boolean condition is already checked for both operators elsewhere. cond_if requires a boolean condition at construction. while_loop cond_graph is checked in the verifier for a scalar boolean output type.


Full diff: https://github.com/llvm/llvm-project/pull/148212.diff

2 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc (-2)
  • (modified) mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp (+2-16)
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc b/mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc
index c77da91942ef9..1f718accabd15 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc
@@ -433,8 +433,6 @@ extensionComplianceMap = {
       {{Extension::fp8e4m3}, {{fp8e4m3T, fp8e4m3T}}},
       {{Extension::fp8e5m2}, {{fp8e5m2T, fp8e5m2T}}},
       {{Extension::bf16}, {{bf16T, bf16T}}}}},
-    {"tosa.cond_if", {{{Extension::controlflow}, {{boolT}}}}},
-    {"tosa.while_loop", {{{Extension::controlflow}, {{boolT}}}}},
     {"tosa.variable", {{{Extension::variable}, {{i8T}, {fp16T}, {fp32T}}}}},
     {"tosa.variable_write",
      {{{Extension::variable}, {{i8T}, {fp16T}, {fp32T}}}}},
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp
index a4edccfd4c9c7..88b0f3650ca01 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp
@@ -225,20 +225,6 @@ LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::VariableWriteOp op) {
   return success();
 }
 
-template <>
-LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::IfOp op) {
-  addValue(op.getCondition());
-  return success();
-}
-
-template <>
-LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::WhileOp op) {
-  Block *block = &op.getCondGraph().front();
-  Operation *terminator = block->getTerminator();
-  addValue(terminator->getOperands().front());
-  return success();
-}
-
 LogicalResult ProfileInfoDepot::populatationDispatch(Operation *op) {
 // This helper function only populates the info for the customised operands.
 #define POPULATE_PROFILE_INFO_CUSTOM(tosaOp)                                   \
@@ -280,8 +266,6 @@ LogicalResult ProfileInfoDepot::populatationDispatch(Operation *op) {
   POPULATE_PROFILE_INFO_CUSTOM(MatMul)
   POPULATE_PROFILE_INFO_CUSTOM(Variable)
   POPULATE_PROFILE_INFO_CUSTOM(VariableWrite)
-  POPULATE_PROFILE_INFO_CUSTOM(If)
-  POPULATE_PROFILE_INFO_CUSTOM(While)
 
   // For the most of tosa operators, all operands are profile/extension related
   // and hence are all considered in this profile-based compilance check.
@@ -340,6 +324,8 @@ LogicalResult ProfileInfoDepot::populatationDispatch(Operation *op) {
   // constraint for those operations.
   POPULATE_PROFILE_INFO_SKIP(ConstShape)
   POPULATE_PROFILE_INFO_SKIP(Yield)
+  POPULATE_PROFILE_INFO_SKIP(If)
+  POPULATE_PROFILE_INFO_SKIP(While)
 
   return failure();
 }

@lhutton1 lhutton1 merged commit d7f6660 into llvm:main Jul 16, 2025
12 checks passed
@lhutton1 lhutton1 deleted the remove-if-while-compliance-checks branch July 16, 2025 08:14
{{Extension::fp8e4m3}, {{fp8e4m3T, fp8e4m3T}}},
{{Extension::fp8e5m2}, {{fp8e5m2T, fp8e5m2T}}},
{{Extension::bf16}, {{bf16T, bf16T}}}}},
{"tosa.cond_if", {{{Extension::controlflow}, {{boolT}}}}},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the impact of having these here ?
Is it just redundancy ?

For each Op, do we have a clear boundary on what the verifier checks vs Profile check ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes just redundancy since they are enforced at a higher level (on construction or during the verifier). I've removed them since the script that generates this list (part of the specification) no longer generates these entries, helping to make future updates to this list easier.

Yes - verifier checks should be used where an operator semantically doesn't make sense, while profile checks are used to check for alignment with the spec. Since the profile check list is auto-generated, I think it's possible there is some redundancy, which is okay IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants