[Mlir-commits] [mlir] Align TOSA->EmitC integration tests with MLGO config (PR #216787)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Aug 17 10:59:58 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: ioana ghiban (ioghiban)

<details>
<summary>Changes</summary>

Adapt existing TOSA->EmitC integration tests to use exactly the same pipeline as the MLGO CMake config proposes in https://github.com/llvm/llvm-project/pull/212650

The missing `buffer-deallocation-pipeline` lead to a skipped canonicalization that created `arith` ops, which the current pipeline couldn't actually lower, due to recent changes in the `arith-expand` pass. This patch completes the pipeline and catches potential future regressions. Also, the pipeline now clearly separates rewrites from dialect conversions, per dialect.

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


2 Files Affected:

- (modified) mlir/test/Integration/Dialect/EmitC/inline-oz-test-model-tosa.mlir (+39-4) 
- (modified) mlir/test/Integration/Dialect/EmitC/regalloc-eviction-test-model-tosa.mlir (+30-5) 


``````````diff
diff --git a/mlir/test/Integration/Dialect/EmitC/inline-oz-test-model-tosa.mlir b/mlir/test/Integration/Dialect/EmitC/inline-oz-test-model-tosa.mlir
index b2259563fdd08..117ca600eece7 100644
--- a/mlir/test/Integration/Dialect/EmitC/inline-oz-test-model-tosa.mlir
+++ b/mlir/test/Integration/Dialect/EmitC/inline-oz-test-model-tosa.mlir
@@ -1,21 +1,56 @@
+// DEFINE: %{wrap_in_class_passes} = 
+// DEFINE: %{promote_to_stack_pass} =
+
 // DEFINE: %{pipeline} = "builtin.module(\
+// DEFINE:   func.func(\
+// DEFINE:     tosa-to-linalg-named,\
+// DEFINE:     tosa-to-linalg,\
+// DEFINE:     tosa-to-arith,\
+// DEFINE:     tosa-to-tensor\
+// DEFINE:   ),\
 // DEFINE:   symbol-privatize,\
 // DEFINE:   scalarize-single-element-tensor-return,\
 // DEFINE:   one-shot-bufferize{\
 // DEFINE:     bufferize-function-boundaries=true\
 // DEFINE:     function-boundary-type-conversion=identity-layout-map\
+// DEFINE:     buffer-alignment=0\
 // DEFINE:   },\
+// DEFINE:   buffer-results-to-out-params{\
+// DEFINE:     hoist-static-allocs=true\
+// DEFINE:   }%{promote_to_stack_pass},\
 // DEFINE:   buffer-deallocation-pipeline,\
-// DEFINE:   convert-to-emitc\
-// DEFINE: )"
+// DEFINE:   func.func(\
+// DEFINE:     convert-linalg-to-loops\
+// DEFINE:   ),\
+// DEFINE:   expand-strided-metadata,\
+// DEFINE:   canonicalize,\
+// DEFINE:   memref-elide-reinterpret-cast,\
+// DEFINE:   math-expand-ops{ops=rsqrt},\
+// DEFINE:   arith-expand{\
+// DEFINE:     include-min-max-f=true\
+// DEFINE:     include-min-max-i=true\
+// DEFINE:   },\
+// DEFINE:   convert-to-emitc,\
+// DEFINE:   convert-math-to-emitc,\
+// DEFINE:   convert-arith-to-emitc%{wrap_in_class_passes})"
 
 // DEFINE: %{lower_to_emitc} = mlir-opt --pass-pipeline=%{pipeline} %s -o %t
-// DEFINE: %{translate} = mlir-translate -mlir-to-cpp %t -o %t.c 
-// DEFINE: %{compile} =  %host_cc -include stdint.h -fsyntax-only -Wpedantic -Wall -Werror -Wno-unused %t.c
+// DEFINE: %{translate} = mlir-translate -mlir-to-cpp %t -o %t.cpp
+// DEFINE: %{compile} =  %host_cc -include stdint.h -fsyntax-only -Wpedantic -Wall -Werror -Wno-unused %t.cpp
 
 /// Lower via the pipeline defined above
 // RUN: rm -f %t && %{lower_to_emitc} && FileCheck %s --input-file=%t && %{translate} && %{compile}
 
+// REDEFINE: %{wrap_in_class_passes} = ,\
+// REDEFINE:   wrap-emitc-func-in-class,\
+// REDEFINE:   mlgo-add-reflection-map{\
+// REDEFINE:     included-field-attrs=tf_saved_model.index_path\
+// REDEFINE:   }
+
+// REDEFINE: %{promote_to_stack_pass} = ",\func.func(promote-buffers-to-stack)"
+
+// RUN: rm -f %t && %{lower_to_emitc} && FileCheck %s --input-file=%t && %{translate} && %{compile}
+
 /// Generated by llvm/lib/Analysis/models/gen-inline-oz-test-model.py + llvm/lib/Analysis/models/saved-model-to-tflite.py
 /// Renamed "main" to avoid:
 ///   error: 'main' should not be declared static
diff --git a/mlir/test/Integration/Dialect/EmitC/regalloc-eviction-test-model-tosa.mlir b/mlir/test/Integration/Dialect/EmitC/regalloc-eviction-test-model-tosa.mlir
index 9e4767fd9b450..e074c0ee7138f 100644
--- a/mlir/test/Integration/Dialect/EmitC/regalloc-eviction-test-model-tosa.mlir
+++ b/mlir/test/Integration/Dialect/EmitC/regalloc-eviction-test-model-tosa.mlir
@@ -1,3 +1,6 @@
+// DEFINE: %{wrap_in_class_passes} = 
+// DEFINE: %{promote_to_stack_pass} =
+
 // DEFINE: %{pipeline} = "builtin.module(\
 // DEFINE:   func.func(\
 // DEFINE:     tosa-to-linalg-named,\
@@ -10,23 +13,45 @@
 // DEFINE:   one-shot-bufferize{\
 // DEFINE:     bufferize-function-boundaries=true\
 // DEFINE:     function-boundary-type-conversion=identity-layout-map\
+// DEFINE:     buffer-alignment=0\
 // DEFINE:   },\
+// DEFINE:   buffer-results-to-out-params{\
+// DEFINE:     hoist-static-allocs=true\
+// DEFINE:   }%{promote_to_stack_pass},\
+// DEFINE:   buffer-deallocation-pipeline,\
 // DEFINE:   func.func(\
 // DEFINE:     convert-linalg-to-loops\
 // DEFINE:   ),\
+// DEFINE:   expand-strided-metadata,\
+// DEFINE:   canonicalize,\
+// DEFINE:   memref-elide-reinterpret-cast,\
+// DEFINE:   math-expand-ops{ops=rsqrt},\
+// DEFINE:   arith-expand{\
+// DEFINE:     include-min-max-f=true\
+// DEFINE:     include-min-max-i=true\
+// DEFINE:   },\
 // DEFINE:   convert-to-emitc,\
-// DEFINE:   arith-expand,\
-// DEFINE:   convert-arith-to-emitc\
-// DEFINE: )"
+// DEFINE:   convert-math-to-emitc,\
+// DEFINE:   convert-arith-to-emitc%{wrap_in_class_passes})"
 
 // DEFINE: %{lower_to_emitc} = mlir-opt --pass-pipeline=%{pipeline} %s -o %t
-// DEFINE: %{translate} = mlir-translate -mlir-to-cpp %t -o %t.c 
+// DEFINE: %{translate} = mlir-translate -mlir-to-cpp %t -o %t.cpp
 // DEFINE: %{compile} =  %host_cc -include stddef.h -include stdint.h -include stdlib.h\
-// DEFINE:   -include stdbool.h -fsyntax-only -Wpedantic -Wall -Werror -Wno-unused %t.c
+// DEFINE:   -include stdbool.h -fsyntax-only -Wpedantic -Wall -Werror -Wno-unused %t.cpp
 
 /// Lower via the pipeline defined above
 // RUN: rm -f %t && %{lower_to_emitc} && FileCheck %s --input-file=%t && %{translate} && %{compile}
 
+// REDEFINE: %{wrap_in_class_passes} = ,\
+// REDEFINE:   wrap-emitc-func-in-class,\
+// REDEFINE:   mlgo-add-reflection-map{\
+// REDEFINE:     included-field-attrs=tf_saved_model.index_path\
+// REDEFINE:   }
+
+// REDEFINE: %{promote_to_stack_pass} = ",\func.func(promote-buffers-to-stack)"
+
+// RUN: rm -f %t && %{lower_to_emitc} && FileCheck %s --input-file=%t && %{translate} && %{compile}
+
 /// Generated by llvm/lib/Analysis/models/gen-regalloc-eviction-test-model.py + llvm/lib/Analysis/models/saved-model-to-tflite.py
 /// Renamed "main" to avoid:
 ///   error: 'main' should not be declared static

``````````

</details>


https://github.com/llvm/llvm-project/pull/216787


More information about the Mlir-commits mailing list