File tree Expand file tree Collapse file tree 10 files changed +732
-32
lines changed Expand file tree Collapse file tree 10 files changed +732
-32
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,15 @@ if(MLIR_DIALECT_XEGPU_ENABLE)
200
200
add_compile_definitions (MLIR_DIALECT_XEGPU_ENABLE )
201
201
endif ()
202
202
203
+ # TosaToTensor Conversion Option (Default OFF)
204
+ option (MLIR_CONVERSION_TOSATOTENSOR_ENABLE
205
+ "Enable TosaToTensor conversion"
206
+ OFF )
207
+
208
+ if (MLIR_CONVERSION_TOSATOTENSOR_ENABLE )
209
+ add_compile_definitions (MLIR_CONVERSION_TOSATOTENSOR_ENABLE )
210
+ endif ()
211
+
203
212
add_subdirectory (include /mlir )
204
213
add_subdirectory (lib )
205
214
# C API needs all dialects for registration, but should be built before tests.
Original file line number Diff line number Diff line change @@ -6,3 +6,7 @@ mlir_tablegen(Passes.capi.cpp.inc -gen-pass-capi-impl --prefix Conversion)
6
6
add_public_tablegen_target (MLIRConversionPassIncGen )
7
7
8
8
add_mlir_doc (Passes ConversionPasses ./ -gen-pass-doc )
9
+
10
+ if (MLIR_CONVERSION_TOSATOTENSOR_ENABLE )
11
+ add_subdirectory (TosaToTensor )
12
+ endif ()
Original file line number Diff line number Diff line change 70
70
#include " mlir/Conversion/TosaToLinalg/TosaToLinalg.h"
71
71
#include " mlir/Conversion/TosaToMLProgram/TosaToMLProgram.h"
72
72
#include " mlir/Conversion/TosaToSCF/TosaToSCF.h"
73
- /* #include "mlir/Conversion/TosaToTensor/TosaToTensor.h" */
73
+ #ifdef MLIR_CONVERSION_TOSATOTENSOR_ENABLE
74
+ #include " mlir/Conversion/TosaToTensor/TosaToTensor.h"
75
+ #endif
74
76
#include " mlir/Conversion/UBToLLVM/UBToLLVM.h"
75
77
#include " mlir/Conversion/UBToSPIRV/UBToSPIRV.h"
76
78
#include " mlir/Conversion/VectorToArmSME/VectorToArmSME.h"
Original file line number Diff line number Diff line change @@ -1215,19 +1215,20 @@ def TosaToSCF : Pass<"tosa-to-scf"> {
1215
1215
//===----------------------------------------------------------------------===//
1216
1216
// TosaToTensor
1217
1217
//===----------------------------------------------------------------------===//
1218
+ #ifdef MLIR_CONVERSION_TOSATOTENSOR_ENABLE
1219
+ def TosaToTensor : Pass<"tosa-to-tensor"> {
1220
+ let summary = "Lower TOSA to the Tensor dialect";
1221
+ let dependentDialects = [
1222
+ "tensor::TensorDialect",
1223
+ ];
1224
+ let description = [{
1225
+ Pass that converts TOSA operations to the equivalent operations using the
1226
+ operations in the Tensor dialect.
1227
+ }];
1218
1228
1219
- // def TosaToTensor : Pass<"tosa-to-tensor"> {
1220
- // let summary = "Lower TOSA to the Tensor dialect";
1221
- // let dependentDialects = [
1222
- // "tensor::TensorDialect",
1223
- // ];
1224
- // let description = [{
1225
- // Pass that converts TOSA operations to the equivalent operations using the
1226
- // operations in the Tensor dialect.
1227
- // }];
1228
- //
1229
- // let constructor = "tosa::createTosaToTensor()";
1230
- //}
1229
+ let constructor = "tosa::createTosaToTensor()";
1230
+ }
1231
+ #endif
1231
1232
1232
1233
//===----------------------------------------------------------------------===//
1233
1234
// UBToLLVM
Original file line number Diff line number Diff line change
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 ()
Original file line number Diff line number Diff line change @@ -78,8 +78,9 @@ add_subdirectory(TosaToArith)
78
78
add_subdirectory (TosaToLinalg )
79
79
add_subdirectory (TosaToMLProgram )
80
80
add_subdirectory (TosaToSCF )
81
- # FIXME(askrebko): cannot be compiled: no conversion between ShapedType and TensorType
82
- # add_subdirectory(TosaToTensor)
81
+ if (MLIR_CONVERSION_TOSATOTENSOR_ENABLE )
82
+ add_subdirectory (TosaToTensor )
83
+ endif ()
83
84
add_subdirectory (UBToLLVM )
84
85
add_subdirectory (UBToSPIRV )
85
86
add_subdirectory (VectorToArmSME )
Original file line number Diff line number Diff line change 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
4
5
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
8
9
9
- DEPENDS
10
- MLIRConversionPassIncGen
10
+ DEPENDS
11
+ MLIRConversionPassIncGen
11
12
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 ()
Original file line number Diff line number Diff line change
1
+ // REQUIRES: tosa-to-tensor-enabled
2
+ // RUN: mlir-opt --split-input-file -pass-pipeline="builtin.module(func.func(tosa-to-tensor))" %s -verify-diagnostics
3
+
4
+ // CHECK-LABEL: @slice_resultType_unranked
5
+ func.func @slice_resultType_unranked (%arg0: tensor <?xf32 >) -> (tensor <*xf32 >) {
6
+ // expected-error@+1 {{failed to legalize operation 'tosa.slice'}}
7
+ %0 = " tosa.slice" (%arg0 ) {start = array<i64 : 2 >, size = array<i64 : 0 >} : (tensor <?xf32 >) -> (tensor <*xf32 >)
8
+ return %0 : tensor <*xf32 >
9
+ }
You can’t perform that action at this time.
0 commit comments