Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@
[submodule "third_party/stablehlo"]
path = third_party/stablehlo
url = https://github.com/iree-org/stablehlo.git
[submodule "third_party/torch-mlir"]
path = third_party/torch-mlir
url = https://github.com/llvm/torch-mlir.git
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -812,10 +812,7 @@ else()
# Add default external projects.
iree_llvm_add_external_project(mlir-iree-dialects ${CMAKE_CURRENT_SOURCE_DIR}/llvm-external-projects/iree-dialects)
iree_llvm_add_external_project(stablehlo ${CMAKE_CURRENT_SOURCE_DIR}/third_party/stablehlo)
if(IREE_INPUT_TORCH)
iree_llvm_add_external_project(torch-mlir-dialects ${CMAKE_CURRENT_SOURCE_DIR}/third_party/torch-mlir-dialects)
endif()


# Ensure that LLVM-based dependencies needed for testing are included.
add_dependencies(iree-test-deps FileCheck)
if(IREE_LLD_TARGET)
Expand Down
7 changes: 0 additions & 7 deletions build_tools/bazel/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,6 @@ def configure_iree_submodule_deps(iree_repo_alias = "@", iree_path = "./"):
path = paths.join(iree_path, "third_party/spirv_cross"),
)

maybe(
native.new_local_repository,
name = "torch-mlir-dialects",
build_file = iree_repo_alias + "//:build_tools/third_party/torch-mlir-dialects/BUILD.overlay",
path = paths.join(iree_path, "third_party/torch-mlir-dialects"),
)

maybe(
native.new_local_repository,
name = "tracy_client",
Expand Down
4 changes: 0 additions & 4 deletions build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ def __init__(self, repo_map: Dict[str, str]):
"@nccl//:headers": [
"nccl::headers",
],
# Torch-MLIR.
"@torch-mlir-dialects//:TorchMLIRTMTensorDialect": [
"TorchMLIRTMTensorDialect"
],
# Tracy.
"@tracy_client//:runtime": ["tracy_client::runtime"],
# Vulkan
Expand Down
157 changes: 0 additions & 157 deletions build_tools/third_party/torch-mlir-dialects/BUILD.overlay

This file was deleted.

25 changes: 25 additions & 0 deletions compiler/plugins/input/Torch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2023 Nod Labs, Inc
#
# 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

set(TORCH_MLIR_ROOT_DIR "${IREE_SOURCE_DIR}/third_party/torch-mlir")
set(IREE_PACKAGE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(IREE_PACKAGE_ROOT_PREFIX "")
set(IREE_COMPILER_TABLEGEN_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")

add_library(torch-iree_compiler_defs INTERFACE)
target_include_directories(torch-iree_compiler_defs
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)

# Configures all iree_cc_* targets to take this implicit dep,
# which provides common includes and copts for the tree.
set(IREE_IMPLICIT_DEFS_CC_DEPS torch-iree_compiler_defs)

add_subdirectory(torch-iree)
add_subdirectory(torch-mlir)
add_subdirectory(torch-mlir-dialects)
32 changes: 32 additions & 0 deletions compiler/plugins/input/Torch/torch-iree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2023 Nod Labs, Inc
#
# 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

add_subdirectory(InputConversion)

iree_cc_library(
NAME
registration
SRCS
"PluginRegistration.cpp"
DEPS
MLIRIR
MLIRPass
iree::compiler::PluginAPI
torch-iree::InputConversion
torch-mlir::TorchConversionDialectIR
torch-mlir::TorchDialectIR
torch-mlir::TorchDialectPasses
torch-mlir::ConversionPasses
torch-mlir-dialects::TMTensorDialectIR
PUBLIC
)

iree_compiler_register_plugin(
PLUGIN_ID
torch_iree
TARGET
::registration
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2023 Nod Labs, Inc
#
# 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

add_subdirectory(test)

iree_tablegen_library(
NAME
PassesIncGen
TD_FILE
"Passes.td"
OUTS
--gen-pass-decls Passes.h.inc
)

iree_cc_library(
NAME
PassHeaders
HDRS
"PassDetail.h"
"Passes.h"
"Passes.h.inc"
DEPS
::PassesIncGen
MLIRPass
MLIRTransforms
PUBLIC
)

iree_cc_library(
NAME
InputConversion
HDRS
"Passes.h"
SRCS
"ConvertTMTensorToLinalgExt.cpp"
"Passes.cpp"
DEPS
::PassHeaders
::PassesIncGen
IREELinalgExtDialect
MLIRFuncDialect
MLIRIR
MLIRPass
MLIRTensorDialect
MLIRTransforms
torch-mlir-dialects::TMTensorDialectIR
PUBLIC
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

#include "iree-dialects/Dialect/LinalgExt/IR/LinalgExtDialect.h"
#include "iree-dialects/Dialect/LinalgExt/IR/LinalgExtOps.h"
#include "iree/compiler/InputConversion/TMTensor/PassDetail.h"
#include "iree/compiler/InputConversion/TMTensor/Passes.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "torch-iree/InputConversion/PassDetail.h"
#include "torch-iree/InputConversion/Passes.h"
#include "torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorOps.h"

namespace mlir {
namespace iree_compiler {
namespace TMTensor {
namespace TorchInput {

namespace {

Expand Down Expand Up @@ -205,6 +205,6 @@ createConvertTMTensorToLinalgExtPass() {
return std::make_unique<ConvertTMTensorToLinalgExtPass>();
}

} // namespace TMTensor
} // namespace TorchInput
} // namespace iree_compiler
} // namespace mlir
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef IREE_COMPILER_INPUTCONVERSION_TMTENSOR_PASSDETAIL_H_
#define IREE_COMPILER_INPUTCONVERSION_TMTENSOR_PASSDETAIL_H_
#ifndef TORCH_IREE_INPUTCONVERSION_PASSDETAIL_H_
#define TORCH_IREE_INPUTCONVERSION_PASSDETAIL_H_

#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Pass/Pass.h"

namespace mlir {
namespace iree_compiler {
namespace TMTensor {
namespace TorchInput {

#define GEN_PASS_CLASSES
#include "iree/compiler/InputConversion/TMTensor/Passes.h.inc"
#include "torch-iree/InputConversion/Passes.h.inc"

} // namespace TMTensor
} // namespace TorchInput
} // namespace iree_compiler
} // namespace mlir

#endif // IREE_COMPILER_INPUTCONVERSION_TMTENSOR_PASSDETAIL_H_
#endif // TORCH_IREE_INPUTCONVERSION_PASSDETAIL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include "iree/compiler/InputConversion/TMTensor/Passes.h"
#include "torch-iree/InputConversion/Passes.h"

namespace mlir {
namespace iree_compiler {
namespace TMTensor {
namespace TorchInput {

namespace {
#define GEN_PASS_REGISTRATION
#include "iree/compiler/InputConversion/TMTensor/Passes.h.inc" // IWYU pragma: export
#include "torch-iree/InputConversion/Passes.h.inc" // IWYU pragma: export
} // namespace

void registerTMTensorConversionPasses() {
// Generated.
registerPasses();
}

} // namespace TMTensor
} // namespace TorchInput
} // namespace iree_compiler
} // namespace mlir
Loading