This repository was archived by the owner on Nov 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 9 files changed +726
-32
lines changed
test/Conversion/TosaToTensor Expand file tree Collapse file tree 9 files changed +726
-32
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,15 @@ if(MLIR_DIALECT_XEGPU_ENABLE)
200200 add_compile_definitions (MLIR_DIALECT_XEGPU_ENABLE)
201201endif ()
202202
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+
203212add_subdirectory (include /mlir)
204213add_subdirectory (lib)
205214# 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)
66add_public_tablegen_target(MLIRConversionPassIncGen)
77
88add_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 7070#include " mlir/Conversion/TosaToLinalg/TosaToLinalg.h"
7171#include " mlir/Conversion/TosaToMLProgram/TosaToMLProgram.h"
7272#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
7476#include " mlir/Conversion/UBToLLVM/UBToLLVM.h"
7577#include " mlir/Conversion/UBToSPIRV/UBToSPIRV.h"
7678#include " mlir/Conversion/VectorToArmSME/VectorToArmSME.h"
Original file line number Diff line number Diff line change @@ -1216,18 +1216,18 @@ def TosaToSCF : Pass<"tosa-to-scf"> {
12161216// TosaToTensor
12171217//===----------------------------------------------------------------------===//
12181218
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- // }
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+ }
12311231
12321232//===----------------------------------------------------------------------===//
12331233// UBToLLVM
Original file line number Diff line number Diff line change 1+
2+ if (MLIR_CONVERSION_TOSATOTENSOR_ENABLE)
3+ set (LLVM_TARGET_DEFINITIONS Passes.td)
4+ mlir_tablegen(Passes.h.inc -gen-pass-decls -name TosaToTensor)
5+ mlir_tablegen(Passes.capi.h.inc -gen-pass-capi-header --prefix TosaToTensor)
6+ mlir_tablegen(Passes.capi.cpp.inc -gen-pass-capi-impl --prefix TosaToTensor)
7+ add_public_tablegen_target(MLIRTosaToTensorPassIncGen)
8+ endif ()
Original file line number Diff line number Diff line change @@ -78,8 +78,9 @@ add_subdirectory(TosaToArith)
7878add_subdirectory (TosaToLinalg)
7979add_subdirectory (TosaToMLProgram)
8080add_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 ()
8384add_subdirectory (UBToLLVM)
8485add_subdirectory (UBToSPIRV)
8586add_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
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 ()
Original file line number Diff line number Diff line change 1+ // RUN: mlir-opt --split-input-file -pass-pipeline="builtin.module(func.func(tosa-to-tensor))" %s -verify-diagnostics
2+
3+ // CHECK-LABEL: @slice_resultType_unranked
4+ func.func @slice_resultType_unranked (%arg0: tensor <?xf32 >) -> (tensor <*xf32 >) {
5+ // expected-error@+1 {{failed to legalize operation 'tosa.slice'}}
6+ %0 = " tosa.slice" (%arg0 ) {start = array<i64 : 2 >, size = array<i64 : 0 >} : (tensor <?xf32 >) -> (tensor <*xf32 >)
7+ return %0 : tensor <*xf32 >
8+ }
You can’t perform that action at this time.
0 commit comments