mirror of https://github.com/llvm/torch-mlir
914 lines
27 KiB
Python
914 lines
27 KiB
Python
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "td_library")
|
|
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
|
|
|
|
package(
|
|
default_visibility = [
|
|
"//visibility:public",
|
|
],
|
|
)
|
|
|
|
# Format bazel BUILD and .bzl files with a standard convention
|
|
# Invoke as `bazel run @torch-mlir//:buildifier`
|
|
buildifier(
|
|
name = "buildifier",
|
|
)
|
|
|
|
# Torch Dialect/IR
|
|
td_library(
|
|
name = "MLIRTorchOpsIncGenTdFiles",
|
|
srcs = glob([
|
|
"include/torch-mlir/Dialect/Torch/IR/*.td",
|
|
]),
|
|
includes = ["include"],
|
|
deps = [
|
|
"@llvm-project//mlir:CastInterfacesTdFiles",
|
|
"@llvm-project//mlir:ControlFlowInterfacesTdFiles",
|
|
"@llvm-project//mlir:InferTypeOpInterfaceTdFiles",
|
|
"@llvm-project//mlir:OpBaseTdFiles",
|
|
"@llvm-project//mlir:SideEffectInterfacesTdFiles",
|
|
],
|
|
)
|
|
|
|
gentbl_cc_library(
|
|
name = "MLIRTorchOpsIncGen",
|
|
strip_include_prefix = "include",
|
|
tbl_outs = [
|
|
(
|
|
["-gen-op-decls"],
|
|
"include/torch-mlir/Dialect/Torch/IR/TorchOps.h.inc",
|
|
),
|
|
(
|
|
["-gen-op-defs"],
|
|
"include/torch-mlir/Dialect/Torch/IR/TorchOps.cpp.inc",
|
|
),
|
|
(
|
|
[
|
|
"-gen-dialect-decls",
|
|
"-dialect=torch",
|
|
],
|
|
"include/torch-mlir/Dialect/Torch/IR/TorchDialect.h.inc",
|
|
),
|
|
(
|
|
[
|
|
"-gen-dialect-defs",
|
|
"-dialect=torch",
|
|
],
|
|
"include/torch-mlir/Dialect/Torch/IR/TorchDialect.cpp.inc",
|
|
),
|
|
],
|
|
tblgen = "@llvm-project//mlir:mlir-tblgen",
|
|
td_file = "include/torch-mlir/Dialect/Torch/IR/TorchOps.td",
|
|
deps = [
|
|
":MLIRTorchOpsIncGenTdFiles",
|
|
],
|
|
)
|
|
|
|
gentbl_cc_library(
|
|
name = "MLIRTorchTypesIncGen",
|
|
strip_include_prefix = "include",
|
|
tbl_outs = [
|
|
(
|
|
["-gen-typedef-decls"],
|
|
"include/torch-mlir/Dialect/Torch/IR/TorchTypes.h.inc",
|
|
),
|
|
(
|
|
["-gen-typedef-defs"],
|
|
"include/torch-mlir/Dialect/Torch/IR/TorchTypes.cpp.inc",
|
|
),
|
|
],
|
|
tblgen = "@llvm-project//mlir:mlir-tblgen",
|
|
td_file = "include/torch-mlir/Dialect/Torch/IR/TorchTypes.td",
|
|
deps = [
|
|
":MLIRTorchOpsIncGenTdFiles",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchDialectUtils",
|
|
srcs = [
|
|
"lib/Dialect/Torch/Utils/SparsityUtils.cpp",
|
|
"lib/Dialect/Torch/Utils/TorchUpstream.cpp",
|
|
"lib/Dialect/Torch/Utils/Utils.cpp",
|
|
],
|
|
hdrs = [
|
|
"include/torch-mlir/Dialect/Torch/IR/TorchOps.h",
|
|
"include/torch-mlir/Dialect/Torch/IR/TorchTraits.h",
|
|
"include/torch-mlir/Dialect/Torch/IR/TorchTypes.h",
|
|
"include/torch-mlir/Dialect/Torch/Utils/SparsityUtils.h",
|
|
"include/torch-mlir/Dialect/Torch/Utils/TorchUpstream.h",
|
|
"include/torch-mlir/Dialect/Torch/Utils/Utils.h",
|
|
],
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":MLIRTorchOpsIncGen",
|
|
":MLIRTorchTypesIncGen",
|
|
"@llvm-project//mlir:CastInterfaces",
|
|
"@llvm-project//mlir:ControlFlowInterfaces",
|
|
"@llvm-project//mlir:IR",
|
|
"@llvm-project//mlir:InferTypeOpInterface",
|
|
"@llvm-project//mlir:SparseTensorDialect",
|
|
"@llvm-project//mlir:SparseTensorEnums",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchDialect",
|
|
srcs = [
|
|
"lib/Dialect/Torch/IR/TorchDialect.cpp",
|
|
"lib/Dialect/Torch/IR/TorchOps.cpp",
|
|
"lib/Dialect/Torch/IR/TorchOpsODSGenerated.cpp",
|
|
"lib/Dialect/Torch/IR/TorchTypes.cpp",
|
|
"lib/Dialect/Torch/IR/UtilsForODSGenerated.cpp",
|
|
"lib/Dialect/Torch/IR/UtilsForODSGenerated.h",
|
|
],
|
|
hdrs = glob([
|
|
"include/torch-mlir/Dialect/Torch/IR/*.h",
|
|
]),
|
|
includes = ["include"],
|
|
deps = [
|
|
":MLIRTorchOpsIncGen",
|
|
":MLIRTorchTypesIncGen",
|
|
":TorchMLIRTorchDialectUtils",
|
|
"@llvm-project//mlir:ControlFlowInterfaces",
|
|
"@llvm-project//mlir:FuncDialect",
|
|
"@llvm-project//mlir:IR",
|
|
"@llvm-project//mlir:InferTypeOpInterface",
|
|
"@llvm-project//mlir:SparseTensorDialect",
|
|
"@llvm-project//mlir:TransformUtils",
|
|
],
|
|
)
|
|
|
|
# Torch Dialect/Transforms
|
|
td_library(
|
|
name = "TorchMLIRTorchPassesTdFiles",
|
|
srcs = [
|
|
"include/torch-mlir/Dialect/Torch/Transforms/Passes.td",
|
|
],
|
|
includes = ["include"],
|
|
deps = [
|
|
"@llvm-project//mlir:OpBaseTdFiles",
|
|
],
|
|
)
|
|
|
|
gentbl_cc_library(
|
|
name = "TorchMLIRTorchPassesIncGen",
|
|
strip_include_prefix = "include",
|
|
tbl_outs = [
|
|
(
|
|
["-gen-pass-decls"],
|
|
"include/torch-mlir/Dialect/Torch/Transforms/Passes.h.inc",
|
|
),
|
|
],
|
|
tblgen = "@llvm-project//mlir:mlir-tblgen",
|
|
td_file = "include/torch-mlir/Dialect/Torch/Transforms/Passes.td",
|
|
deps = [
|
|
":TorchMLIRTorchPassesTdFiles",
|
|
"@llvm-project//mlir:PassBaseTdFiles",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchPasses",
|
|
srcs = glob([
|
|
"lib/Dialect/Torch/Transforms/*.cpp",
|
|
"lib/Dialect/Torch/Transforms/*.h",
|
|
]),
|
|
hdrs = [
|
|
"include/torch-mlir/Dialect/Torch/Transforms/Passes.h",
|
|
],
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRTorchBackendTypeConversion",
|
|
":TorchMLIRTorchDialect",
|
|
":TorchMLIRTorchPassesIncGen",
|
|
"@llvm-project//mlir:FuncDialect",
|
|
"@llvm-project//mlir:IR",
|
|
"@llvm-project//mlir:Parser",
|
|
"@llvm-project//mlir:Pass",
|
|
"@llvm-project//mlir:Transforms",
|
|
],
|
|
)
|
|
|
|
# TorchConversion diaelct
|
|
td_library(
|
|
name = "MLIRTorchConversionOpsTdFiles",
|
|
srcs = [
|
|
"include/torch-mlir/Dialect/TorchConversion/IR/TorchConversionBase.td",
|
|
"include/torch-mlir/Dialect/TorchConversion/IR/TorchConversionOps.td",
|
|
],
|
|
includes = ["include"],
|
|
deps = [
|
|
":MLIRTorchOpsIncGenTdFiles",
|
|
"@llvm-project//mlir:AttrTdFiles",
|
|
"@llvm-project//mlir:CastInterfacesTdFiles",
|
|
"@llvm-project//mlir:ControlFlowInterfacesTdFiles",
|
|
"@llvm-project//mlir:InferTypeOpInterfaceTdFiles",
|
|
"@llvm-project//mlir:OpBaseTdFiles",
|
|
"@llvm-project//mlir:SideEffectInterfacesTdFiles",
|
|
],
|
|
)
|
|
|
|
gentbl_cc_library(
|
|
name = "MLIRTorchConversionOpsIncGen",
|
|
strip_include_prefix = "include",
|
|
tbl_outs = [
|
|
(
|
|
["-gen-op-decls"],
|
|
"include/torch-mlir/Dialect/TorchConversion/IR/TorchConversionOps.h.inc",
|
|
),
|
|
(
|
|
["-gen-op-defs"],
|
|
"include/torch-mlir/Dialect/TorchConversion/IR/TorchConversionOps.cpp.inc",
|
|
),
|
|
(
|
|
[
|
|
"-gen-dialect-decls",
|
|
"-dialect=torch_c",
|
|
],
|
|
"include/torch-mlir/Dialect/TorchConversion/IR/TorchConversionDialect.h.inc",
|
|
),
|
|
(
|
|
[
|
|
"-gen-dialect-defs",
|
|
"-dialect=torch_c",
|
|
],
|
|
"include/torch-mlir/Dialect/TorchConversion/IR/TorchConversionDialect.cpp.inc",
|
|
),
|
|
],
|
|
tblgen = "@llvm-project//mlir:mlir-tblgen",
|
|
td_file = "include/torch-mlir/Dialect/TorchConversion/IR/TorchConversionOps.td",
|
|
deps = [
|
|
":MLIRTorchConversionOpsTdFiles",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchConversionDialect",
|
|
srcs = glob(["lib/Dialect/TorchConversion/IR/*.cpp"]),
|
|
hdrs = glob(["include/torch-mlir/Dialect/TorchConversion/IR/*.h"]),
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":MLIRTorchConversionOpsIncGen",
|
|
":TorchMLIRTorchDialect",
|
|
"@llvm-project//mlir:IR",
|
|
"@llvm-project//mlir:InferTypeOpInterface",
|
|
],
|
|
)
|
|
|
|
# Conversion
|
|
td_library(
|
|
name = "TorchMLIRConversionPassesTdFiles",
|
|
srcs = [
|
|
"include/torch-mlir/Conversion/Passes.td",
|
|
],
|
|
includes = ["include"],
|
|
)
|
|
|
|
gentbl_cc_library(
|
|
name = "TorchMLIRConversionPassesIncGen",
|
|
strip_include_prefix = "include",
|
|
tbl_outs = [
|
|
(
|
|
[
|
|
"-gen-pass-decls",
|
|
"-DTORCH_MLIR_ENABLE_STABLEHLO",
|
|
],
|
|
"include/torch-mlir/Conversion/Passes.h.inc",
|
|
),
|
|
],
|
|
tblgen = "@llvm-project//mlir:mlir-tblgen",
|
|
td_file = "include/torch-mlir/Conversion/Passes.td",
|
|
deps = [
|
|
":TorchMLIRConversionPassesTdFiles",
|
|
"@llvm-project//mlir:PassBaseTdFiles",
|
|
],
|
|
)
|
|
|
|
td_library(
|
|
name = "TorchMLIRConversionTorchOnnxToTorchPassTdFiles",
|
|
srcs = [
|
|
"include/torch-mlir/Conversion/TorchOnnxToTorch/Passes.td",
|
|
],
|
|
includes = ["include"],
|
|
)
|
|
|
|
gentbl_cc_library(
|
|
name = "TorchMLIRConversionTorchOnnxToTorchPassIncGen",
|
|
strip_include_prefix = "include",
|
|
tbl_outs = [
|
|
(
|
|
["-gen-pass-decls"],
|
|
"include/torch-mlir/Conversion/TorchOnnxToTorch/Passes.h.inc",
|
|
),
|
|
],
|
|
tblgen = "@llvm-project//mlir:mlir-tblgen",
|
|
td_file = "include/torch-mlir/Conversion/TorchOnnxToTorch/Passes.td",
|
|
deps = [
|
|
":TorchMLIRConversionTorchOnnxToTorchPassTdFiles",
|
|
"@llvm-project//mlir:PassBaseTdFiles",
|
|
],
|
|
)
|
|
|
|
# TorchConversion transforms
|
|
td_library(
|
|
name = "TorchMLIRTorchConversionPassesTdFiles",
|
|
srcs = [
|
|
"include/torch-mlir/Dialect/TorchConversion/Transforms/Passes.td",
|
|
],
|
|
deps = [
|
|
"@llvm-project//mlir:OpBaseTdFiles",
|
|
],
|
|
)
|
|
|
|
gentbl_cc_library(
|
|
name = "TorchMLIRTorchConversionPassesIncGen",
|
|
strip_include_prefix = "include",
|
|
tbl_outs = [
|
|
(
|
|
["-gen-pass-decls"],
|
|
"include/torch-mlir/Dialect/TorchConversion/Transforms/Passes.h.inc",
|
|
),
|
|
],
|
|
tblgen = "@llvm-project//mlir:mlir-tblgen",
|
|
td_file = "include/torch-mlir/Dialect/TorchConversion/Transforms/Passes.td",
|
|
deps = [
|
|
":TorchMLIRTorchConversionPassesTdFiles",
|
|
"@llvm-project//mlir:PassBaseTdFiles",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRConversionUtils",
|
|
srcs = [
|
|
"lib/Conversion/Utils/Utils.cpp",
|
|
],
|
|
hdrs = [
|
|
"include/torch-mlir/Conversion/Utils/Utils.h",
|
|
],
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRTorchDialect",
|
|
"@llvm-project//mlir:ArithDialect",
|
|
"@llvm-project//mlir:ControlFlowDialect",
|
|
"@llvm-project//mlir:IR",
|
|
"@llvm-project//mlir:LinalgDialect",
|
|
"@llvm-project//mlir:Transforms",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchToLinalg",
|
|
srcs = glob([
|
|
"lib/Conversion/*.h",
|
|
"lib/Conversion/TorchToLinalg/*.cpp",
|
|
"lib/Conversion/TorchToLinalg/*.h",
|
|
]),
|
|
hdrs = glob(["include/torch-mlir/Conversion/TorchToLinalg/*.h"]),
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRConversionPassesIncGen",
|
|
":TorchMLIRConversionUtils",
|
|
":TorchMLIRTorchBackendTypeConversion",
|
|
":TorchMLIRTorchConversionDialect",
|
|
":TorchMLIRTorchDialect",
|
|
"@llvm-project//mlir:ArithDialect",
|
|
"@llvm-project//mlir:ControlFlowDialect",
|
|
"@llvm-project//mlir:Dialect",
|
|
"@llvm-project//mlir:LinalgDialect",
|
|
"@llvm-project//mlir:Pass",
|
|
"@llvm-project//mlir:TensorUtils",
|
|
"@llvm-project//mlir:TransformUtils",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchToSCF",
|
|
srcs = glob([
|
|
"lib/Conversion/*.h",
|
|
"lib/Conversion/TorchToSCF/*.cpp",
|
|
]),
|
|
hdrs = glob(["include/torch-mlir/Conversion/TorchToSCF/*.h"]),
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRConversionPassesIncGen",
|
|
":TorchMLIRTorchBackendTypeConversion",
|
|
":TorchMLIRTorchConversionDialect",
|
|
"@llvm-project//mlir:ArithDialect",
|
|
"@llvm-project//mlir:ControlFlowDialect",
|
|
"@llvm-project//mlir:Dialect",
|
|
"@llvm-project//mlir:LinalgDialect",
|
|
"@llvm-project//mlir:Pass",
|
|
"@llvm-project//mlir:TensorUtils",
|
|
"@llvm-project//mlir:TransformUtils",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchToArith",
|
|
srcs = glob([
|
|
"lib/Conversion/*.h",
|
|
"lib/Conversion/TorchToArith/*.cpp",
|
|
]),
|
|
hdrs = glob([
|
|
"include/torch-mlir/Conversion/TorchToArith/*.h",
|
|
]),
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRConversionPassesIncGen",
|
|
":TorchMLIRConversionUtils",
|
|
":TorchMLIRTorchBackendTypeConversion",
|
|
":TorchMLIRTorchConversionDialect",
|
|
"@llvm-project//mlir:Dialect",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchToTensor",
|
|
srcs = glob([
|
|
"lib/Conversion/*.h",
|
|
"lib/Conversion/TorchToTensor/*.cpp",
|
|
]),
|
|
hdrs = glob([
|
|
"include/torch-mlir/Conversion/TorchToTensor/*.h",
|
|
]),
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRConversionPassesIncGen",
|
|
":TorchMLIRConversionUtils",
|
|
":TorchMLIRTorchBackendTypeConversion",
|
|
":TorchMLIRTorchConversionDialect",
|
|
":TorchMLIRTorchDialect",
|
|
"@llvm-project//mlir:Dialect",
|
|
"@llvm-project//mlir:IR",
|
|
"@llvm-project//mlir:Pass",
|
|
"@llvm-project//mlir:TensorDialect",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchConversionToMLProgram",
|
|
srcs = glob([
|
|
"lib/Conversion/*.h",
|
|
"lib/Conversion/TorchConversionToMLProgram/*.cpp",
|
|
]),
|
|
hdrs = glob([
|
|
"include/torch-mlir/Conversion/TorchConversionToMLProgram/*.h",
|
|
]),
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRConversionPassesIncGen",
|
|
":TorchMLIRConversionUtils",
|
|
":TorchMLIRTorchBackendTypeConversion",
|
|
":TorchMLIRTorchConversionDialect",
|
|
"@llvm-project//mlir:Dialect",
|
|
"@llvm-project//mlir:LinalgDialect",
|
|
"@llvm-project//mlir:MLProgramDialect",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchToTMTensor",
|
|
srcs = glob([
|
|
"lib/Conversion/*.h",
|
|
"lib/Conversion/TorchToTMTensor/*.cpp",
|
|
]),
|
|
hdrs = glob(["include/torch-mlir/Conversion/TorchToTMTensor/*.h"]),
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRConversionPassesIncGen",
|
|
":TorchMLIRConversionUtils",
|
|
":TorchMLIRTMTensorDialect",
|
|
":TorchMLIRTorchBackendTypeConversion",
|
|
":TorchMLIRTorchConversionDialect",
|
|
"@llvm-project//mlir:LinalgDialect",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchToStablehlo",
|
|
srcs = glob([
|
|
"lib/Conversion/*.h",
|
|
"lib/Conversion/TorchToStablehlo/*.h",
|
|
"lib/Conversion/TorchToStablehlo/*.cpp",
|
|
]),
|
|
hdrs = glob(["include/torch-mlir/Conversion/TorchToStablehlo/*.h"]),
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRConversionPassesIncGen",
|
|
":TorchMLIRConversionUtils",
|
|
":TorchMLIRTorchBackendTypeConversion",
|
|
":TorchMLIRTorchConversionDialect",
|
|
"@llvm-project//mlir:Dialect",
|
|
"@stablehlo//:register",
|
|
"@stablehlo//:stablehlo_passes",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchOnnxToTorch",
|
|
srcs = glob([
|
|
"lib/Conversion/TorchOnnxToTorch/*.h",
|
|
"lib/Conversion/TorchOnnxToTorch/*.cpp",
|
|
]),
|
|
hdrs = glob(["include/torch-mlir/Conversion/TorchOnnxToTorch/*.h"]),
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRConversionTorchOnnxToTorchPassIncGen",
|
|
":TorchMLIRTorchDialect",
|
|
"@llvm-project//mlir:IR",
|
|
"@llvm-project//mlir:Pass",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRConversionPasses",
|
|
srcs = [
|
|
"lib/Conversion/Passes.cpp",
|
|
],
|
|
hdrs = [
|
|
"include/torch-mlir/Conversion/Passes.h",
|
|
],
|
|
defines = [
|
|
"TORCH_MLIR_ENABLE_STABLEHLO",
|
|
],
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRTorchConversionToMLProgram",
|
|
":TorchMLIRTorchOnnxToTorch",
|
|
":TorchMLIRTorchToArith",
|
|
":TorchMLIRTorchToLinalg",
|
|
":TorchMLIRTorchToSCF",
|
|
":TorchMLIRTorchToStablehlo",
|
|
":TorchMLIRTorchToTMTensor",
|
|
":TorchMLIRTorchToTensor",
|
|
":TorchMLIRTorchToTosa",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchConversionPasses",
|
|
srcs = glob([
|
|
"lib/Dialect/TorchConversion/Transforms/*.cpp",
|
|
"lib/Dialect/TorchConversion/Transforms/*.h",
|
|
]),
|
|
hdrs = glob(["include/torch-mlir/Dialect/TorchConversion/Transforms/*.h"]),
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRTorchBackendTypeConversion",
|
|
":TorchMLIRTorchConversionDialect",
|
|
":TorchMLIRTorchConversionPassesIncGen",
|
|
":TorchMLIRTorchConversionToMLProgram",
|
|
":TorchMLIRTorchDialect",
|
|
":TorchMLIRTorchPasses",
|
|
":TorchMLIRTorchToArith",
|
|
":TorchMLIRTorchToLinalg",
|
|
":TorchMLIRTorchToSCF",
|
|
":TorchMLIRTorchToStablehlo",
|
|
":TorchMLIRTorchToTMTensor",
|
|
":TorchMLIRTorchToTensor",
|
|
":TorchMLIRTorchToTosa",
|
|
"@llvm-project//mlir:ConversionPasses",
|
|
"@llvm-project//mlir:FuncDialect",
|
|
"@llvm-project//mlir:LinalgDialect",
|
|
"@llvm-project//mlir:LinalgTransforms",
|
|
"@llvm-project//mlir:MemRefDialect",
|
|
"@llvm-project//mlir:MemRefTransforms",
|
|
"@llvm-project//mlir:Pass",
|
|
"@llvm-project//mlir:TosaDialect",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTorchToTosa",
|
|
srcs = glob([
|
|
"lib/Conversion/*.h",
|
|
"lib/Conversion/TorchToTosa/*.cpp",
|
|
]),
|
|
hdrs = glob(["include/torch-mlir/Conversion/TorchToTosa/*.h"]),
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRConversionPassesIncGen",
|
|
":TorchMLIRConversionUtils",
|
|
":TorchMLIRTorchBackendTypeConversion",
|
|
":TorchMLIRTorchConversionDialect",
|
|
"@llvm-project//mlir:Dialect",
|
|
"@llvm-project//mlir:QuantOps",
|
|
"@llvm-project//mlir:TosaDialect",
|
|
],
|
|
)
|
|
|
|
# Dialects.TorchConversion
|
|
cc_library(
|
|
name = "TorchMLIRTorchBackendTypeConversion",
|
|
srcs = [
|
|
"lib/Dialect/TorchConversion/Transforms/BackendTypeConversion.cpp",
|
|
],
|
|
hdrs = [
|
|
"include/torch-mlir/Dialect/TorchConversion/Transforms/BackendTypeConversion.h",
|
|
],
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRTorchConversionDialect",
|
|
"@llvm-project//mlir:FuncTransforms",
|
|
],
|
|
)
|
|
|
|
td_library(
|
|
name = "TorchMLIRTMTensorOpsTdFiles",
|
|
srcs = [
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/ScalarLoopOpInterface.td",
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorBase.td",
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorInterfaces.td",
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorOps.td",
|
|
],
|
|
includes = ["include"],
|
|
deps = [
|
|
"@llvm-project//mlir:ControlFlowInterfacesTdFiles",
|
|
"@llvm-project//mlir:OpBaseTdFiles",
|
|
"@llvm-project//mlir:SideEffectInterfacesTdFiles",
|
|
],
|
|
)
|
|
|
|
gentbl_cc_library(
|
|
name = "TorchMLIRTMTensorInterfacesIncGen",
|
|
strip_include_prefix = "include",
|
|
tbl_outs = [
|
|
(
|
|
["-gen-op-interface-decls"],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorOpInterfaces.h.inc",
|
|
),
|
|
(
|
|
["-gen-op-interface-defs"],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorOpInterfaces.cpp.inc",
|
|
),
|
|
(
|
|
["-gen-type-interface-decls"],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorTypeInterfaces.h.inc",
|
|
),
|
|
(
|
|
["-gen-type-interface-defs"],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorTypeInterfaces.cpp.inc",
|
|
),
|
|
],
|
|
tblgen = "@llvm-project//mlir:mlir-tblgen",
|
|
td_file = "include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorInterfaces.td",
|
|
deps = [
|
|
":TorchMLIRTMTensorOpsTdFiles",
|
|
],
|
|
)
|
|
|
|
gentbl_cc_library(
|
|
name = "TorchMLIRTMTensorScalarLoopOpInterfaceIncGen",
|
|
strip_include_prefix = "include",
|
|
tbl_outs = [
|
|
(
|
|
["-gen-op-interface-decls"],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/ScalarLoopOpInterface.h.inc",
|
|
),
|
|
(
|
|
["-gen-op-interface-defs"],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/ScalarLoopOpInterface.cpp.inc",
|
|
),
|
|
],
|
|
tblgen = "@llvm-project//mlir:mlir-tblgen",
|
|
td_file = "include/torch-mlir-dialects/Dialect/TMTensor/IR/ScalarLoopOpInterface.td",
|
|
deps = [
|
|
":TorchMLIRTMTensorOpsTdFiles",
|
|
],
|
|
)
|
|
|
|
gentbl_cc_library(
|
|
name = "TorchMLIRTMTensorOpsIncGen",
|
|
strip_include_prefix = "include",
|
|
tbl_outs = [
|
|
(
|
|
["-gen-op-decls"],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorOps.h.inc",
|
|
),
|
|
(
|
|
["-gen-op-defs"],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorOps.cpp.inc",
|
|
),
|
|
(
|
|
["-gen-typedef-decls"],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorTypes.h.inc",
|
|
),
|
|
(
|
|
[
|
|
"-gen-dialect-decls",
|
|
"-dialect=tm_tensor",
|
|
],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorDialect.h.inc",
|
|
),
|
|
(
|
|
[
|
|
"-gen-dialect-defs",
|
|
"-dialect=tm_tensor",
|
|
],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorDialect.cpp.inc",
|
|
),
|
|
],
|
|
tblgen = "@llvm-project//mlir:mlir-tblgen",
|
|
td_file = "include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorOps.td",
|
|
deps = [
|
|
":TorchMLIRTMTensorOpsTdFiles",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTMTensorDialect",
|
|
srcs = [
|
|
"lib/Dialect/TMTensor/IR/ScalarLoopOpInterface.cpp",
|
|
"lib/Dialect/TMTensor/IR/TMTensorDialect.cpp",
|
|
"lib/Dialect/TMTensor/IR/TMTensorInterfaces.cpp",
|
|
"lib/Dialect/TMTensor/IR/TMTensorOps.cpp",
|
|
],
|
|
hdrs = [
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/ScalarLoopOpInterface.h",
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorDialect.h",
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorInterfaces.h",
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorOps.h",
|
|
],
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRTMTensorInterfacesIncGen",
|
|
":TorchMLIRTMTensorOpsIncGen",
|
|
":TorchMLIRTMTensorScalarLoopOpInterfaceIncGen",
|
|
"@llvm-project//mlir:AffineDialect",
|
|
"@llvm-project//mlir:ControlFlowInterfaces",
|
|
"@llvm-project//mlir:Dialect",
|
|
"@llvm-project//mlir:DialectUtils",
|
|
"@llvm-project//mlir:FuncDialect",
|
|
"@llvm-project//mlir:LinalgDialect",
|
|
"@llvm-project//mlir:ViewLikeInterface",
|
|
],
|
|
)
|
|
|
|
td_library(
|
|
name = "TorchMLIRTMTensorTransformsPassesTdFiles",
|
|
srcs = [
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/Transforms/Passes.td",
|
|
],
|
|
deps = [
|
|
"@llvm-project//mlir:OpBaseTdFiles",
|
|
"@llvm-project//mlir:PassBaseTdFiles",
|
|
],
|
|
)
|
|
|
|
gentbl_cc_library(
|
|
name = "TorchMLIRTMTensorTransformsPassesIncGen",
|
|
strip_include_prefix = "include",
|
|
tbl_outs = [
|
|
(
|
|
["-gen-pass-decls"],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/Transforms/Passes.h.inc",
|
|
),
|
|
(
|
|
["-gen-pass-capi-header"],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/Transforms/Passes.h.cpi.inc",
|
|
),
|
|
(
|
|
["-gen-pass-capi-impl"],
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/Transforms/Passes.cpi.cpp.inc",
|
|
),
|
|
],
|
|
tblgen = "@llvm-project//mlir:mlir-tblgen",
|
|
td_file = "include/torch-mlir-dialects/Dialect/TMTensor/Transforms/Passes.td",
|
|
deps = [
|
|
":TorchMLIRTMTensorTransformsPassesTdFiles",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRTMTensorPasses",
|
|
srcs = [
|
|
"lib/Dialect/TMTensor/Transforms/Bufferize.cpp",
|
|
"lib/Dialect/TMTensor/Transforms/ConvertToLoops.cpp",
|
|
"lib/Dialect/TMTensor/Transforms/Passes.cpp",
|
|
],
|
|
hdrs = [
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/Transforms/PassDetail.h",
|
|
"include/torch-mlir-dialects/Dialect/TMTensor/Transforms/Passes.h",
|
|
],
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRTMTensorDialect",
|
|
":TorchMLIRTMTensorTransformsPassesIncGen",
|
|
"@llvm-project//mlir:BufferizationTransforms",
|
|
"@llvm-project//mlir:FuncTransforms",
|
|
"@llvm-project//mlir:LinalgDialect",
|
|
"@llvm-project//mlir:LinalgTransforms",
|
|
"@llvm-project//mlir:Pass",
|
|
"@llvm-project//mlir:Transforms",
|
|
],
|
|
)
|
|
|
|
# RefBackend
|
|
filegroup(
|
|
name = "TorchMLIRRefBackendPassesDetails",
|
|
srcs = [
|
|
"lib/RefBackend/PassDetail.h",
|
|
],
|
|
)
|
|
|
|
td_library(
|
|
name = "TorchMLIRRefBackendPassTdFiles",
|
|
srcs = [
|
|
"include/torch-mlir/RefBackend/Passes.td",
|
|
],
|
|
deps = [
|
|
"@llvm-project//mlir:OpBaseTdFiles",
|
|
],
|
|
)
|
|
|
|
gentbl_cc_library(
|
|
name = "TorchMLIRRefBackendPassIncGen",
|
|
strip_include_prefix = "include",
|
|
tbl_outs = [
|
|
(
|
|
["-gen-pass-decls"],
|
|
"include/torch-mlir/RefBackend/Passes.h.inc",
|
|
),
|
|
],
|
|
tblgen = "@llvm-project//mlir:mlir-tblgen",
|
|
td_file = "include/torch-mlir/RefBackend/Passes.td",
|
|
deps = [
|
|
":TorchMLIRRefBackendPassTdFiles",
|
|
"@llvm-project//mlir:PassBaseTdFiles",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRRefBackendPass",
|
|
srcs = [
|
|
"lib/RefBackend/RefBackend.cpp",
|
|
] + [":TorchMLIRRefBackendPassesDetails"],
|
|
hdrs = [
|
|
"include/torch-mlir/RefBackend/Passes.h",
|
|
],
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRRefBackendPassIncGen",
|
|
":TorchMLIRTorchBackendTypeConversion",
|
|
":TorchMLIRTorchConversionDialect",
|
|
"@llvm-project//mlir:ArithTransforms",
|
|
"@llvm-project//mlir:LinalgDialect",
|
|
"@llvm-project//mlir:LinalgTransforms",
|
|
"@llvm-project//mlir:MLProgramDialect",
|
|
"@llvm-project//mlir:MathTransforms",
|
|
"@llvm-project//mlir:MemRefDialect",
|
|
"@llvm-project//mlir:Pass",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "TorchMLIRInitAll",
|
|
srcs = [
|
|
"lib/InitAll.cpp",
|
|
],
|
|
hdrs = [
|
|
"include/torch-mlir/InitAll.h",
|
|
],
|
|
copts = [
|
|
"-DTORCH_MLIR_ENABLE_REFBACKEND",
|
|
"-DTORCH_MLIR_ENABLE_STABLEHLO",
|
|
],
|
|
strip_include_prefix = "include",
|
|
deps = [
|
|
":TorchMLIRConversionPasses",
|
|
":TorchMLIRRefBackendPass",
|
|
":TorchMLIRTMTensorDialect",
|
|
":TorchMLIRTMTensorPasses",
|
|
":TorchMLIRTorchConversionDialect",
|
|
":TorchMLIRTorchConversionPasses",
|
|
":TorchMLIRTorchDialect",
|
|
":TorchMLIRTorchPasses",
|
|
"@llvm-project//mlir:AllExtensions",
|
|
"@llvm-project//mlir:Dialect",
|
|
"@llvm-project//mlir:DialectUtils",
|
|
"@llvm-project//mlir:IR",
|
|
"@stablehlo//:linalg_passes",
|
|
"@stablehlo//:stablehlo_passes",
|
|
],
|
|
)
|
|
|
|
# tools
|
|
cc_binary(
|
|
name = "torch-mlir-opt",
|
|
srcs = [
|
|
"tools/torch-mlir-opt/torch-mlir-opt.cpp",
|
|
],
|
|
deps = [
|
|
":TorchMLIRInitAll",
|
|
":TorchMLIRTorchDialect",
|
|
":TorchMLIRTorchPasses",
|
|
"@llvm-project//mlir:AllExtensions",
|
|
"@llvm-project//mlir:AllPassesAndDialects",
|
|
"@llvm-project//mlir:MlirOptLib",
|
|
],
|
|
)
|