[Mlir-commits] [mlir] Align TOSA->EmitC integration tests with MLGO config (PR #216787)
ioana ghiban
llvmlistbot at llvm.org
Wed Aug 19 01:14:42 PDT 2026
https://github.com/ioghiban updated https://github.com/llvm/llvm-project/pull/216787
>From e26f95259ee9827c88c12f63164cd81f53947293 Mon Sep 17 00:00:00 2001
From: Ioana Ghiban <ioana.ghiban at arm.com>
Date: Mon, 17 Aug 2026 19:24:54 +0200
Subject: [PATCH 1/2] Align TOSA->EmitC integration tests with MLGO config
---
.../EmitC/inline-oz-test-model-tosa.mlir | 43 +++++++++++++++++--
.../regalloc-eviction-test-model-tosa.mlir | 35 ++++++++++++---
2 files changed, 69 insertions(+), 9 deletions(-)
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
>From c31c1db4902a35ec73a5feded04a6ed3dcc6d285 Mon Sep 17 00:00:00 2001
From: Ioana Ghiban <ioana.ghiban at arm.com>
Date: Wed, 19 Aug 2026 10:14:22 +0200
Subject: [PATCH 2/2] Add missing comments
---
.../Integration/Dialect/EmitC/inline-oz-test-model-tosa.mlir | 3 ++-
.../Dialect/EmitC/regalloc-eviction-test-model-tosa.mlir | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
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 117ca600eece7..1ea07e961fbc0 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
@@ -38,7 +38,7 @@
// 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
+/// Test TOSA->EmitC lowering.
// RUN: rm -f %t && %{lower_to_emitc} && FileCheck %s --input-file=%t && %{translate} && %{compile}
// REDEFINE: %{wrap_in_class_passes} = ,\
@@ -49,6 +49,7 @@
// REDEFINE: %{promote_to_stack_pass} = ",\func.func(promote-buffers-to-stack)"
+/// Test class-based C++ code generation.
// 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
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 e074c0ee7138f..f9828f67121e5 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
@@ -39,7 +39,7 @@
// 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.cpp
-/// Lower via the pipeline defined above
+/// Test TOSA->EmitC lowering.
// RUN: rm -f %t && %{lower_to_emitc} && FileCheck %s --input-file=%t && %{translate} && %{compile}
// REDEFINE: %{wrap_in_class_passes} = ,\
@@ -50,6 +50,7 @@
// REDEFINE: %{promote_to_stack_pass} = ",\func.func(promote-buffers-to-stack)"
+/// Test class-based C++ code generation.
// 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
More information about the Mlir-commits
mailing list