Skip to content

Commit 525e76f

Browse files
committed
EISW-163564 Add CMake option to conditionally disable TosaToTensor conversion
1 parent 14e16e2 commit 525e76f

File tree

10 files changed

+60
-19
lines changed

10 files changed

+60
-19
lines changed

mlir/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,24 @@ set(MLIR_PDLL_TABLEGEN_TARGET "${MLIR_PDLL_TABLEGEN_TARGET}" CACHE INTERNAL "")
221221
set(MLIR_SRC_SHARDER_TABLEGEN_EXE "${MLIR_SRC_SHARDER_TABLEGEN_EXE}" CACHE INTERNAL "")
222222
set(MLIR_SRC_SHARDER_TABLEGEN_TARGET "${MLIR_SRC_SHARDER_TABLEGEN_TARGET}" CACHE INTERNAL "")
223223

224+
# XeGPU Dialect Option (Default OFF)
225+
option(MLIR_DIALECT_XEGPU_ENABLE
226+
"Enable the XeGPU dialect."
227+
OFF)
228+
229+
if(MLIR_DIALECT_XEGPU_ENABLE)
230+
add_compile_definitions(MLIR_DIALECT_XEGPU_ENABLE)
231+
endif()
232+
233+
# TosaToTensor Conversion Option (Default OFF)
234+
option(MLIR_CONVERSION_TOSATOTENSOR_ENABLE
235+
"Enable TosaToTensor conversion"
236+
OFF)
237+
238+
if(MLIR_CONVERSION_TOSATOTENSOR_ENABLE)
239+
add_compile_definitions(MLIR_CONVERSION_TOSATOTENSOR_ENABLE)
240+
endif()
241+
224242
add_subdirectory(include/mlir)
225243
add_subdirectory(lib)
226244
# C API needs all dialects for registration, but should be built before tests.

mlir/include/mlir/Conversion/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ add_public_tablegen_target(MLIRConversionPassIncGen)
77

88
add_mlir_doc(Passes ConversionPasses ./ -gen-pass-doc)
99

10+
if(MLIR_CONVERSION_TOSATOTENSOR_ENABLE)
11+
add_subdirectory(TosaToTensor)
12+
endif()
1013
add_subdirectory(ConvertToLLVM)

mlir/include/mlir/Conversion/Passes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@
7171
#include "mlir/Conversion/TosaToLinalg/TosaToLinalg.h"
7272
#include "mlir/Conversion/TosaToMLProgram/TosaToMLProgram.h"
7373
#include "mlir/Conversion/TosaToSCF/TosaToSCF.h"
74+
#ifdef MLIR_CONVERSION_TOSATOTENSOR_ENABLE
7475
#include "mlir/Conversion/TosaToTensor/TosaToTensor.h"
76+
#endif
7577
#include "mlir/Conversion/UBToLLVM/UBToLLVM.h"
7678
#include "mlir/Conversion/UBToSPIRV/UBToSPIRV.h"
7779
#include "mlir/Conversion/VectorToArmSME/VectorToArmSME.h"

mlir/include/mlir/Conversion/Passes.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ def TosaToSCF : Pass<"tosa-to-scf"> {
12591259
//===----------------------------------------------------------------------===//
12601260
// TosaToTensor
12611261
//===----------------------------------------------------------------------===//
1262-
1262+
#ifdef MLIR_CONVERSION_TOSATOTENSOR_ENABLE
12631263
def TosaToTensor : Pass<"tosa-to-tensor"> {
12641264
let summary = "Lower TOSA to the Tensor dialect";
12651265
let dependentDialects = [
@@ -1272,6 +1272,7 @@ def TosaToTensor : Pass<"tosa-to-tensor"> {
12721272

12731273
let constructor = "tosa::createTosaToTensor()";
12741274
}
1275+
#endif
12751276

12761277
//===----------------------------------------------------------------------===//
12771278
// UBToLLVM
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if(MLIR_CONVERSION_TOSATOTENSOR_ENABLE)
2+
set(LLVM_TARGET_DEFINITIONS Passes.td)
3+
mlir_tablegen(Passes.h.inc -gen-pass-decls -name TosaToTensor)
4+
mlir_tablegen(Passes.capi.h.inc -gen-pass-capi-header --prefix TosaToTensor)
5+
mlir_tablegen(Passes.capi.cpp.inc -gen-pass-capi-impl --prefix TosaToTensor)
6+
add_public_tablegen_target(MLIRTosaToTensorPassIncGen)
7+
endif()

mlir/lib/Conversion/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ add_subdirectory(TosaToArith)
8080
add_subdirectory(TosaToLinalg)
8181
add_subdirectory(TosaToMLProgram)
8282
add_subdirectory(TosaToSCF)
83-
add_subdirectory(TosaToTensor)
83+
if(MLIR_CONVERSION_TOSATOTENSOR_ENABLE)
84+
add_subdirectory(TosaToTensor)
85+
endif()
8486
add_subdirectory(UBToLLVM)
8587
add_subdirectory(UBToSPIRV)
8688
add_subdirectory(VectorToArmSME)
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
add_mlir_conversion_library(MLIRTosaToTensor
2-
TosaToTensor.cpp
3-
TosaToTensorPass.cpp
1+
if(MLIR_CONVERSION_TOSATOTENSOR_ENABLE)
2+
add_mlir_conversion_library(MLIRTosaToTensor
3+
TosaToTensor.cpp
4+
TosaToTensorPass.cpp
45

5-
ADDITIONAL_HEADER_DIRS
6-
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Tosa
7-
${MLIR_MAIN_INCLUDE_DIR}/mlir/IR
6+
ADDITIONAL_HEADER_DIRS
7+
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Tosa
8+
${MLIR_MAIN_INCLUDE_DIR}/mlir/IR
89

9-
DEPENDS
10-
MLIRConversionPassIncGen
10+
DEPENDS
11+
MLIRConversionPassIncGen
1112

12-
LINK_LIBS PUBLIC
13-
MLIRTensorDialect
14-
MLIRTensorUtils
15-
MLIRIR
16-
MLIRPass
17-
MLIRTosaDialect
18-
MLIRTosaTransforms
19-
MLIRSupport
20-
)
13+
LINK_LIBS PUBLIC
14+
MLIRTensorDialect
15+
MLIRTensorUtils
16+
MLIRIR
17+
MLIRPass
18+
MLIRTosaDialect
19+
MLIRTosaTransforms
20+
MLIRSupport
21+
)
22+
endif()

mlir/test/Conversion/TosaToTensor/tosa-to-tensor-invalid.mlir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// REQUIRES: tosa-to-tensor-enabled
12
// RUN: mlir-opt --split-input-file -pass-pipeline="builtin.module(func.func(tosa-to-tensor))" %s -verify-diagnostics
23

34
// CHECK-LABEL: @slice_resultType_unranked

mlir/test/Conversion/TosaToTensor/tosa-to-tensor.mlir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// REQUIRES: tosa-to-tensor-enabled
12
// RUN: mlir-opt --split-input-file --tosa-to-tensor %s -o -| FileCheck %s
23

34
// -----

mlir/test/lit.site.cfg.py.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ config.riscv_vector_emulator_options = "@RISCV_VECTOR_EMULATOR_OPTIONS@"
6969
config.riscv_emulator_lli_executable = "@RISCV_EMULATOR_LLI_EXECUTABLE@"
7070
config.riscv_emulator_utils_lib_dir = "@RISCV_EMULATOR_UTILS_LIB_DIR@"
7171

72+
# Add feature to enable/disable TosaTotensor tests
73+
if "@MLIR_CONVERSION_TOSATOTENSOR_ENABLE@" == "ON":
74+
config.available_features.add("tosa-to-tensor-enabled")
75+
7276
import lit.llvm
7377
lit.llvm.initialize(lit_config, config)
7478

0 commit comments

Comments
 (0)