Skip to content

Commit

Permalink
[NFC] Create include/mlir-tcp and move headers over (#12)
Browse files Browse the repository at this point in the history
This makes it idiomatic to upstream mlir/torch-mlir structure, and makes
downstream integrations less ambiguous in cases like these:
```
- #include "Conversion/Passes.h"
+ #include "mlir-tcp/Conversion/Passes.h"
```
  • Loading branch information
sjain-stanford authored Oct 24, 2023
1 parent 1852bea commit 4670cab
Show file tree
Hide file tree
Showing 43 changed files with 166 additions and 133 deletions.
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# 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
# Also available under a BSD-style license. See LICENSE.

BasedOnStyle: LLVM
66 changes: 33 additions & 33 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ package(
td_library(
name = "TcpTdFiles",
srcs = [
"include/Dialect/IR/TcpBase.td",
"include/Dialect/IR/TcpEnums.td",
"include/Dialect/IR/TcpOps.td",
"include/mlir-tcp/Dialect/IR/TcpBase.td",
"include/mlir-tcp/Dialect/IR/TcpEnums.td",
"include/mlir-tcp/Dialect/IR/TcpOps.td",
],
includes = ["include"],
deps = [
Expand All @@ -31,15 +31,15 @@ gentbl_cc_library(
tbl_outs = [
(
["-gen-enum-decls"],
"include/Dialect/IR/TcpEnums.h.inc",
"include/mlir-tcp/Dialect/IR/TcpEnums.h.inc",
),
(
["-gen-enum-defs"],
"include/Dialect/IR/TcpEnums.cpp.inc",
"include/mlir-tcp/Dialect/IR/TcpEnums.cpp.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "include/Dialect/IR/TcpOps.td",
td_file = "include/mlir-tcp/Dialect/IR/TcpOps.td",
deps = [
":TcpTdFiles",
],
Expand All @@ -51,15 +51,15 @@ gentbl_cc_library(
tbl_outs = [
(
["-gen-attrdef-decls"],
"include/Dialect/IR/TcpAttrs.h.inc",
"include/mlir-tcp/Dialect/IR/TcpAttrs.h.inc",
),
(
["-gen-attrdef-defs"],
"include/Dialect/IR/TcpAttrs.cpp.inc",
"include/mlir-tcp/Dialect/IR/TcpAttrs.cpp.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "include/Dialect/IR/TcpOps.td",
td_file = "include/mlir-tcp/Dialect/IR/TcpOps.td",
deps = [
":TcpTdFiles",
],
Expand All @@ -71,29 +71,29 @@ gentbl_cc_library(
tbl_outs = [
(
["-gen-op-decls"],
"include/Dialect/IR/TcpOps.h.inc",
"include/mlir-tcp/Dialect/IR/TcpOps.h.inc",
),
(
["-gen-op-defs"],
"include/Dialect/IR/TcpOps.cpp.inc",
"include/mlir-tcp/Dialect/IR/TcpOps.cpp.inc",
),
(
[
"-gen-dialect-decls",
"-dialect=tcp",
],
"include/Dialect/IR/TcpDialect.h.inc",
"include/mlir-tcp/Dialect/IR/TcpDialect.h.inc",
),
(
[
"-gen-dialect-defs",
"-dialect=tcp",
],
"include/Dialect/IR/TcpDialect.cpp.inc",
"include/mlir-tcp/Dialect/IR/TcpDialect.cpp.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "include/Dialect/IR/TcpOps.td",
td_file = "include/mlir-tcp/Dialect/IR/TcpOps.td",
deps = [
":TcpTdFiles",
],
Expand All @@ -106,8 +106,8 @@ cc_library(
"lib/Dialect/IR/TcpOps.cpp",
],
hdrs = [
"include/Dialect/IR/TcpDialect.h",
"include/Dialect/IR/TcpOps.h",
"include/mlir-tcp/Dialect/IR/TcpDialect.h",
"include/mlir-tcp/Dialect/IR/TcpOps.h",
],
strip_include_prefix = "include",
deps = [
Expand All @@ -124,7 +124,7 @@ cc_library(
td_library(
name = "TcpTransformsPassesTdFiles",
srcs = [
"include/Dialect/Transforms/Passes.td",
"include/mlir-tcp/Dialect/Transforms/Passes.td",
],
deps = [
"@llvm-project//mlir:OpBaseTdFiles",
Expand All @@ -138,11 +138,11 @@ gentbl_cc_library(
tbl_outs = [
(
["-gen-pass-decls"],
"include/Dialect/Transforms/Passes.h.inc",
"include/mlir-tcp/Dialect/Transforms/Passes.h.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "include/Dialect/Transforms/Passes.td",
td_file = "include/mlir-tcp/Dialect/Transforms/Passes.td",
deps = [
":TcpTransformsPassesTdFiles",
],
Expand All @@ -158,10 +158,10 @@ cc_library(
"lib/Dialect/Transforms/VerifyTcpBackendContractPass.cpp",
],
hdrs = [
"include/Dialect/Transforms/FuseTcpOpsPass.h",
"include/Dialect/Transforms/IsolateGroupOpsPass.h",
"include/Dialect/Transforms/Passes.h",
"include/Dialect/Transforms/VerifyTcpBackendContractPass.h",
"include/mlir-tcp/Dialect/Transforms/FuseTcpOpsPass.h",
"include/mlir-tcp/Dialect/Transforms/IsolateGroupOpsPass.h",
"include/mlir-tcp/Dialect/Transforms/Passes.h",
"include/mlir-tcp/Dialect/Transforms/VerifyTcpBackendContractPass.h",
],
strip_include_prefix = "include",
deps = [
Expand All @@ -176,7 +176,7 @@ cc_library(
td_library(
name = "TcpConversionPassesTdFiles",
srcs = [
"include/Conversion/Passes.td",
"include/mlir-tcp/Conversion/Passes.td",
],
includes = ["include"],
)
Expand All @@ -189,11 +189,11 @@ gentbl_cc_library(
[
"-gen-pass-decls",
],
"include/Conversion/Passes.h.inc",
"include/mlir-tcp/Conversion/Passes.h.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "include/Conversion/Passes.td",
td_file = "include/mlir-tcp/Conversion/Passes.td",
deps = [
":TcpConversionPassesTdFiles",
"@llvm-project//mlir:PassBaseTdFiles",
Expand All @@ -206,7 +206,7 @@ cc_library(
"lib/Conversion/Passes.cpp",
],
hdrs = [
"include/Conversion/Passes.h",
"include/mlir-tcp/Conversion/Passes.h",
],
strip_include_prefix = "include",
deps = [
Expand All @@ -224,7 +224,7 @@ cc_library(
"lib/Conversion/TorchToTcp/*.h",
"lib/Conversion/TorchToTcp/*.cpp",
]),
hdrs = glob(["include/Conversion/TorchToTcp/*.h"]),
hdrs = glob(["include/mlir-tcp/Conversion/TorchToTcp/*.h"]),
strip_include_prefix = "include",
deps = [
":TcpConversionPassesIncGen",
Expand All @@ -243,7 +243,7 @@ cc_library(
"lib/Conversion/StablehloToTcp/StablehloToTcp.cpp",
],
hdrs = [
"include/Conversion/StablehloToTcp/StablehloToTcp.h",
"include/mlir-tcp/Conversion/StablehloToTcp/StablehloToTcp.h",
],
strip_include_prefix = "include",
deps = [
Expand All @@ -267,7 +267,7 @@ cc_library(
"lib/Conversion/TcpToLinalg/TcpToLinalg.cpp",
],
hdrs = [
"include/Conversion/TcpToLinalg/TcpToLinalg.h",
"include/mlir-tcp/Conversion/TcpToLinalg/TcpToLinalg.h",
],
strip_include_prefix = "include",
deps = [
Expand All @@ -290,7 +290,7 @@ cc_library(
"lib/Conversion/TcpToArith/TcpToArith.cpp",
],
hdrs = [
"include/Conversion/TcpToArith/TcpToArith.h",
"include/mlir-tcp/Conversion/TcpToArith/TcpToArith.h",
],
strip_include_prefix = "include",
deps = [
Expand All @@ -311,7 +311,7 @@ cc_library(
"lib/InitAll.cpp",
],
hdrs = [
"include/InitAll.h",
"include/mlir-tcp/InitAll.h",
],
strip_include_prefix = "include",
deps = [
Expand All @@ -331,7 +331,7 @@ cc_library(
"lib/Pipeline/Pipeline.cpp",
],
hdrs = [
"include/Pipeline/Pipeline.h",
"include/mlir-tcp/Pipeline/Pipeline.h",
],
strip_include_prefix = "include",
deps = [
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

include "mlir/Pass/PassBase.td"

//===----------------------------------------------------------------------===//
// TorchToTcp
//===----------------------------------------------------------------------===//

def ConvertTorchToTcp : Pass<"convert-torch-to-tcp", "func::FuncOp"> {
let summary = "Convert Torch ops to Tcp ops";
let description = [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace mlir {

#define GEN_PASS_DECL_CONVERTSTABLEHLOTOTCP
#include "Conversion/Passes.h.inc"
#include "mlir-tcp/Conversion/Passes.h.inc"

namespace tcp {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace mlir {

#define GEN_PASS_DECL_CONVERTTCPTOARITH
#include "Conversion/Passes.h.inc"
#include "mlir-tcp/Conversion/Passes.h.inc"

namespace tcp {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace mlir {

#define GEN_PASS_DECL_CONVERTTCPTOLINALG
#include "Conversion/Passes.h.inc"
#include "mlir-tcp/Conversion/Passes.h.inc"

namespace tcp {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include "mlir/Pass/Pass.h"

namespace mlir {

#define GEN_PASS_DECL_CONVERTTORCHTOTCP
#include "mlir-tcp/Conversion/Passes.h.inc"

namespace tcp {

std::unique_ptr<OperationPass<func::FuncOp>> createConvertTorchToTcpPass();
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"

#include "Dialect/IR/TcpDialect.h.inc"
#include "mlir-tcp/Dialect/IR/TcpDialect.h.inc"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/TypeSwitch.h"

#include "Dialect/IR/TcpEnums.h.inc"
#include "mlir-tcp/Dialect/IR/TcpEnums.h.inc"
#define GET_ATTRDEF_CLASSES
#include "Dialect/IR/TcpAttrs.h.inc"
#include "mlir-tcp/Dialect/IR/TcpAttrs.h.inc"
#define GET_OP_CLASSES
#include "Dialect/IR/TcpOps.h.inc"
#include "mlir-tcp/Dialect/IR/TcpOps.h.inc"
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#ifndef TCP_OPS
#define TCP_OPS

include "Dialect/IR/TcpBase.td"
include "Dialect/IR/TcpEnums.td"
include "mlir-tcp/Dialect/IR/TcpBase.td"
include "mlir-tcp/Dialect/IR/TcpEnums.td"

include "mlir/IR/OpBase.td"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions lib/Conversion/PassDetail.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

#pragma once

#include "Dialect/IR/TcpDialect.h"
#include "mlir-tcp/Dialect/IR/TcpDialect.h"

#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
Expand All @@ -18,6 +19,6 @@
namespace mlir {

#define GEN_PASS_CLASSES
#include "Conversion/Passes.h.inc"
#include "mlir-tcp/Conversion/Passes.h.inc"

} // end namespace mlir
25 changes: 7 additions & 18 deletions lib/Conversion/Passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,20 @@
//
//===----------------------------------------------------------------------===//

#include "Conversion/Passes.h"
#include "mlir-tcp/Conversion/Passes.h"

#include "Conversion/StablehloToTcp/StablehloToTcp.h"
#include "Conversion/TcpToArith/TcpToArith.h"
#include "Conversion/TcpToLinalg/TcpToLinalg.h"
#include "Conversion/TorchToTcp/TorchToTcp.h"
#include "mlir-tcp/Conversion/StablehloToTcp/StablehloToTcp.h"
#include "mlir-tcp/Conversion/TcpToArith/TcpToArith.h"
#include "mlir-tcp/Conversion/TcpToLinalg/TcpToLinalg.h"
#include "mlir-tcp/Conversion/TorchToTcp/TorchToTcp.h"

//===----------------------------------------------------------------------===//
// Pass registration
//===----------------------------------------------------------------------===//

namespace {
#define GEN_PASS_REGISTRATION
#include "Conversion/Passes.h.inc"
#include "mlir-tcp/Conversion/Passes.h.inc"
} // end namespace

void mlir::tcp::registerConversionPasses() {
::registerPasses();
::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
return mlir::tcp::createConvertStablehloToTcpPass();
});
::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
return mlir::tcp::createConvertTcpToLinalgPass();
});
::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
return mlir::tcp::createConvertTcpToArithPass();
});
}
void mlir::tcp::registerConversionPasses() { ::registerPasses(); }
8 changes: 4 additions & 4 deletions lib/Conversion/StablehloToTcp/StablehloToTcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//

#include "Conversion/StablehloToTcp/StablehloToTcp.h"
#include "mlir-tcp/Conversion/StablehloToTcp/StablehloToTcp.h"

#include "Dialect/IR/TcpDialect.h"
#include "Dialect/IR/TcpOps.h"
#include "mlir-tcp/Dialect/IR/TcpDialect.h"
#include "mlir-tcp/Dialect/IR/TcpOps.h"

#include "../PassDetail.h"
#include "mlir/IR/PatternMatch.h"
Expand All @@ -23,7 +23,7 @@
namespace mlir {

#define GEN_PASS_DEF_CONVERTTCPTOLINALG
#include "Conversion/Passes.h.inc"
#include "mlir-tcp/Conversion/Passes.h.inc"

namespace tcp {

Expand Down
Loading

0 comments on commit 4670cab

Please sign in to comment.