-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tcp] Add boilerplate for TCP dialect (#1375)
* Initial boilerplate for TCP with a dummy op. * Conditional flag to enable TCP
- Loading branch information
Showing
21 changed files
with
247 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...-external-projects/torch-mlir-dialects/include/torch-mlir-dialects/Dialect/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
add_subdirectory(TMTensor) | ||
if(TORCH_MLIR_DIALECTS_ENABLE_TCP) | ||
add_subdirectory(Tcp) | ||
endif() | ||
|
1 change: 1 addition & 0 deletions
1
...ernal-projects/torch-mlir-dialects/include/torch-mlir-dialects/Dialect/Tcp/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(IR) |
11 changes: 11 additions & 0 deletions
11
...al-projects/torch-mlir-dialects/include/torch-mlir-dialects/Dialect/Tcp/IR/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function(_add_dialect) | ||
set(LLVM_TARGET_DEFINITIONS TcpOps.td) | ||
mlir_tablegen(TcpOps.h.inc -gen-op-decls) | ||
mlir_tablegen(TcpOps.cpp.inc -gen-op-defs) | ||
mlir_tablegen(TcpDialect.h.inc -gen-dialect-decls -dialect=tcp) | ||
mlir_tablegen(TcpDialect.cpp.inc -gen-dialect-defs -dialect=tcp) | ||
add_public_tablegen_target(TorchMLIRTcpOpsIncGen) | ||
add_dependencies(mlir-headers TorchMLIRTcpOpsIncGen) | ||
endfunction() | ||
|
||
_add_dialect() |
43 changes: 43 additions & 0 deletions
43
...ternal-projects/torch-mlir-dialects/include/torch-mlir-dialects/Dialect/Tcp/IR/TcpBase.td
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//===-------------------------------------------------------*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, 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. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef TORCH_MLIR_DIALECT_TCP_BASE | ||
#define TORCH_MLIR_DIALECT_TCP_BASE | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def Tcp_Dialect : Dialect { | ||
let name = "tcp"; | ||
let cppNamespace = "::mlir::tcp"; | ||
let description = [{ | ||
Tensor Compute Primitives (TCP) dialect. | ||
|
||
TCP is a mid-level transformation oriented IR for deep learning & similar | ||
applications. | ||
}]; | ||
|
||
let dependentDialects = []; | ||
} | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Tcp Type Definitions. | ||
//===----------------------------------------------------------------------===// | ||
|
||
def Tcp_Scalar : AnyTypeOf<[AnyFloat, AnySignlessInteger, AnyComplex]>; | ||
def Tcp_Tensor : RankedTensorOf<[Tcp_Scalar]>; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Tcp Ops Base. | ||
//===----------------------------------------------------------------------===// | ||
|
||
class Tcp_Op<string mnemonic, list<Trait> traits = []> : | ||
Op<Tcp_Dialect, mnemonic, traits> { | ||
} | ||
|
||
#endif // TORCH_MLIR_DIALECT_TCP_BASE |
18 changes: 18 additions & 0 deletions
18
...rnal-projects/torch-mlir-dialects/include/torch-mlir-dialects/Dialect/Tcp/IR/TcpDialect.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===------------------------------------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, 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. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef TORCH_MLIR_DIALECTS_DIALECT_TCP_IR_TCPDIALECT_H_ | ||
#define TORCH_MLIR_DIALECTS_DIALECT_TCP_IR_TCPDIALECT_H_ | ||
|
||
#include "mlir/IR/Dialect.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
|
||
#include "torch-mlir-dialects/Dialect/Tcp/IR/TcpDialect.h.inc" | ||
|
||
#endif // TORCH_MLIR_DIALECTS_DIALECT_TCP_IR_TCPDIALECT_H_ |
21 changes: 21 additions & 0 deletions
21
...external-projects/torch-mlir-dialects/include/torch-mlir-dialects/Dialect/Tcp/IR/TcpOps.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//===------------------------------------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, 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. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef TORCH_MLIR_DIALECTS_DIALECT_TCP_IR_TCPOPS_H_ | ||
#define TORCH_MLIR_DIALECTS_DIALECT_TCP_IR_TCPOPS_H_ | ||
|
||
#include "mlir/IR/Attributes.h" | ||
#include "mlir/IR/BuiltinTypes.h" | ||
#include "mlir/IR/Dialect.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
|
||
#define GET_OP_CLASSES | ||
#include "torch-mlir-dialects/Dialect/Tcp/IR/TcpOps.h.inc" | ||
|
||
#endif // TORCH_MLIR_DIALECTS_DIALECT_TCP_IR_TCPOPS_H_ |
35 changes: 35 additions & 0 deletions
35
...xternal-projects/torch-mlir-dialects/include/torch-mlir-dialects/Dialect/Tcp/IR/TcpOps.td
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//===-------------------------------------------------------*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, 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. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef TORCH_MLIR_DIALECT_TCP_OPS | ||
#define TORCH_MLIR_DIALECT_TCP_OPS | ||
|
||
include "torch-mlir-dialects/Dialect/Tcp/IR/TcpBase.td" | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def Tcp_DummyOp : Tcp_Op<"dummy", []> { | ||
let summary = "dummy op"; | ||
|
||
let description = [{ | ||
Dummy identity op that returns the input as output | ||
}]; | ||
|
||
let arguments = (ins | ||
Tcp_Tensor:$in | ||
); | ||
|
||
let results = (outs | ||
Tcp_Tensor:$out | ||
); | ||
|
||
let assemblyFormat = "$in attr-dict `:` type($in) `->` type($out)"; | ||
} | ||
|
||
#endif // TORCH_MLIR_DIALECT_TCP_OPS |
4 changes: 4 additions & 0 deletions
4
externals/llvm-external-projects/torch-mlir-dialects/lib/Dialect/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
add_subdirectory(TMTensor) | ||
if(TORCH_MLIR_DIALECTS_ENABLE_TCP) | ||
add_subdirectory(Tcp) | ||
endif() | ||
|
1 change: 1 addition & 0 deletions
1
externals/llvm-external-projects/torch-mlir-dialects/lib/Dialect/Tcp/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(IR) |
20 changes: 20 additions & 0 deletions
20
externals/llvm-external-projects/torch-mlir-dialects/lib/Dialect/Tcp/IR/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
add_mlir_library(TorchMLIRTcpDialect | ||
TcpDialect.cpp | ||
TcpOps.cpp | ||
|
||
ADDITIONAL_HEADER_DIRS | ||
${TORCH_MLIR_DIALECTS_SOURCE_DIR}/include | ||
|
||
DEPENDS | ||
TorchMLIRTcpOpsIncGen | ||
|
||
LINK_LIBS PUBLIC | ||
MLIRDialectUtils | ||
MLIRIR | ||
MLIRPass | ||
MLIRSideEffectInterfaces | ||
MLIRSupport | ||
MLIRViewLikeInterface | ||
) | ||
|
||
torch_mlir_dialects_target_includes(TorchMLIRTcpDialect) |
30 changes: 30 additions & 0 deletions
30
externals/llvm-external-projects/torch-mlir-dialects/lib/Dialect/Tcp/IR/TcpDialect.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===------------------------------------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, 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. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "torch-mlir-dialects/Dialect/Tcp/IR/TcpDialect.h" | ||
#include "torch-mlir-dialects/Dialect/Tcp/IR/TcpOps.h" | ||
|
||
#include "mlir/IR/Attributes.h" | ||
#include "mlir/IR/DialectImplementation.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
#include "mlir/IR/OpImplementation.h" | ||
#include "llvm/ADT/SmallVector.h" | ||
#include "llvm/Support/SourceMgr.h" | ||
|
||
using namespace mlir; | ||
using namespace mlir::tcp; | ||
|
||
void TcpDialect::initialize() { | ||
#define GET_OP_LIST | ||
addOperations< | ||
#include "torch-mlir-dialects/Dialect/Tcp/IR/TcpOps.cpp.inc" | ||
>(); | ||
} | ||
|
||
#include "torch-mlir-dialects/Dialect/Tcp/IR/TcpDialect.cpp.inc" |
18 changes: 18 additions & 0 deletions
18
externals/llvm-external-projects/torch-mlir-dialects/lib/Dialect/Tcp/IR/TcpOps.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===------------------------------------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, 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. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "torch-mlir-dialects/Dialect/Tcp/IR/TcpOps.h" | ||
|
||
#include "mlir/IR/Builders.h" | ||
#include "mlir/IR/OpImplementation.h" | ||
#include "mlir/IR/OperationSupport.h" | ||
#include "mlir/IR/Value.h" | ||
|
||
#define GET_OP_CLASSES | ||
#include "torch-mlir-dialects/Dialect/Tcp/IR/TcpOps.cpp.inc" |
2 changes: 2 additions & 0 deletions
2
externals/llvm-external-projects/torch-mlir-dialects/test/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
externals/llvm-external-projects/torch-mlir-dialects/test/Dialect/Tcp/dummy-op.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// RUN: torch-mlir-dialects-opt %s | torch-mlir-dialects-opt | FileCheck %s | ||
|
||
// CHECK-LABEL: func.func @test_dummy(%{{.*}}: tensor<10x20xf32>) -> tensor<10x20xf32> | ||
func.func @test_dummy(%arg0 : tensor<10x20xf32>) -> tensor<10x20xf32> { | ||
// CHECK: %{{.*}} = tcp.dummy %{{.*}} : tensor<10x20xf32> -> tensor<10x20xf32> | ||
%0 = tcp.dummy %arg0 : tensor<10x20xf32> -> tensor<10x20xf32> | ||
return %0 : tensor<10x20xf32> | ||
} |
2 changes: 2 additions & 0 deletions
2
externals/llvm-external-projects/torch-mlir-dialects/test/Dialect/Tcp/lit.local.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
if not config.enable_tcp: | ||
config.unsupported = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters