-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
325 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
USE_BAZEL_VERSION=6.4.0 |
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
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,56 @@ | ||
#ifndef PSCM_OPS | ||
#define PSCM_OPS | ||
|
||
def PSCM_Dialect : Dialect { | ||
let name = "pscm"; | ||
let cppNamespace = "::mlir::toy" | ||
let hasConstantMaterializer = 1; | ||
let useDefaultTypePrinterParser = 1; | ||
} | ||
|
||
class PSCM_Op<string mnemonic, list<Trait> traits = []> : | ||
Op<PSCM_Dialect, mnemonic, traits>; | ||
|
||
def PSCM_Type : AnyTypeOf<[F64Tensor]>; | ||
|
||
def ConstantOp : PSCM_Op<"constant", | ||
[ConstantLike, Pure]> { | ||
let summary = "constant"; | ||
let description = [{ | ||
Constant operation | ||
}] | ||
let arguments = (ins F64ElemetsAttr:$value); | ||
let results = (outs F64Tensor) | ||
|
||
let hasCustomAssemblyFormat = 1; | ||
|
||
let builders = [ | ||
OpBuilder<(ins "DenseElementAttr":$value), [{ | ||
build($_builder, $_state, value.getType(), value); | ||
}]>, | ||
OpBuilder<(ins "double":$value)> | ||
]; | ||
|
||
let hasVerifier = 1; | ||
|
||
let hasFolder = 1; | ||
} | ||
|
||
def AddOp : PSCM_Op<"add", | ||
[Pure]> { | ||
let summary = "addition operation"; | ||
let description = [{ | ||
The "add" operation performs addidtion | ||
}]; | ||
|
||
let arguments = (ins F64Tensor:$lhs, F64Tensor:$rhs); | ||
let results = (outs F64Tensor); | ||
|
||
let hasCustomAssemblyFormat = 1; | ||
|
||
let builders = [ | ||
OpBuilder<(ins "Value":$lhs, "Value":$rhs)> | ||
] | ||
|
||
} | ||
#endif |
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,131 @@ | ||
load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") | ||
|
||
licenses(["notice"]) | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
# td_library( | ||
# name = "ToyOpsTdFiles", | ||
# srcs = [ | ||
# "include/toy/Ops.td", | ||
# "include/toy/ShapeInferenceInterface.td", | ||
# ], | ||
# includes = ["include"], | ||
# deps = [ | ||
# "//mlir:CallInterfacesTdFiles", | ||
# "//mlir:CastInterfacesTdFiles", | ||
# "//mlir:FunctionInterfacesTdFiles", | ||
# "//mlir:OpBaseTdFiles", | ||
# "//mlir:SideEffectInterfacesTdFiles", | ||
# ], | ||
# ) | ||
|
||
# gentbl_cc_library( | ||
# name = "ToyInterfacesIncGen", | ||
# tbl_outs = [ | ||
# ( | ||
# ["-gen-op-interface-decls"], | ||
# "include/toy/ShapeInferenceOpInterfaces.h.inc", | ||
# ), | ||
# ( | ||
# ["-gen-op-interface-defs"], | ||
# "include/toy/ShapeInferenceOpInterfaces.cpp.inc", | ||
# ), | ||
# ], | ||
# tblgen = "//mlir:mlir-tblgen", | ||
# td_file = "include/toy/ShapeInferenceInterface.td", | ||
# deps = [":ToyOpsTdFiles"], | ||
# ) | ||
|
||
# gentbl_cc_library( | ||
# name = "ToyOpsIncGen", | ||
# tbl_outs = [ | ||
# ( | ||
# ["-gen-op-decls"], | ||
# "include/toy/Ops.h.inc", | ||
# ), | ||
# ( | ||
# ["-gen-op-defs"], | ||
# "include/toy/Ops.cpp.inc", | ||
# ), | ||
# ( | ||
# ["-gen-dialect-decls"], | ||
# "include/toy/Dialect.h.inc", | ||
# ), | ||
# ( | ||
# ["-gen-dialect-defs"], | ||
# "include/toy/Dialect.cpp.inc", | ||
# ), | ||
# ], | ||
# tblgen = "//mlir:mlir-tblgen", | ||
# td_file = "include/toy/Ops.td", | ||
# deps = [":ToyOpsTdFiles"], | ||
# ) | ||
|
||
# gentbl_cc_library( | ||
# name = "ToyCombineIncGen", | ||
# strip_include_prefix = "mlir", | ||
# tbl_outs = [ | ||
# ( | ||
# ["-gen-rewriters"], | ||
# "mlir/ToyCombine.inc", | ||
# ), | ||
# ], | ||
# tblgen = "//mlir:mlir-tblgen", | ||
# td_file = "mlir/ToyCombine.td", | ||
# deps = [":ToyOpsTdFiles"], | ||
# ) | ||
|
||
cc_binary( | ||
name = "toyc", | ||
# srcs = [ | ||
# "mlir/Dialect.cpp", | ||
# "mlir/LowerToAffineLoops.cpp", | ||
# "mlir/LowerToLLVM.cpp", | ||
# "mlir/MLIRGen.cpp", | ||
# "mlir/ShapeInferencePass.cpp", | ||
# "mlir/ToyCombine.cpp", | ||
# "parser/AST.cpp", | ||
# "toyc.cpp", | ||
# ] + glob(["include/toy/*.h"]), | ||
includes = ["include/"], | ||
deps = [ | ||
# ":ToyCombineIncGen", | ||
# ":ToyInterfacesIncGen", | ||
# ":ToyOpsIncGen", | ||
"@llvm-project//llvm:Core", | ||
"@llvm-project//llvm:OrcJIT", | ||
"@llvm-project//llvm:Support", | ||
"@llvm-project//mlir:AffineDialect", | ||
"@llvm-project//mlir:AffineToStandard", | ||
"@llvm-project//mlir:AffineTransforms", | ||
"@llvm-project//mlir:AllPassesAndDialects", | ||
"@llvm-project//mlir:Analysis", | ||
"@llvm-project//mlir:ArithDialect", | ||
"@llvm-project//mlir:ArithToLLVM", | ||
"@llvm-project//mlir:BuiltinToLLVMIRTranslation", | ||
"@llvm-project//mlir:CastInterfaces", | ||
"@llvm-project//mlir:ControlFlowToLLVM", | ||
"@llvm-project//mlir:ExecutionEngine", | ||
"@llvm-project//mlir:ExecutionEngineUtils", | ||
"@llvm-project//mlir:FuncDialect", | ||
"@llvm-project//mlir:FuncExtensions", | ||
"@llvm-project//mlir:FuncToLLVM", | ||
"@llvm-project//mlir:IR", | ||
"@llvm-project//mlir:LLVMCommonConversion", | ||
"@llvm-project//mlir:LLVMDialect", | ||
"@llvm-project//mlir:LLVMIRTransforms", | ||
"@llvm-project//mlir:LLVMToLLVMIRTranslation", | ||
"@llvm-project//mlir:MemRefDialect", | ||
"@llvm-project//mlir:MemRefToLLVM", | ||
"@llvm-project//mlir:Parser", | ||
"@llvm-project//mlir:Pass", | ||
"@llvm-project//mlir:SCFDialect", | ||
"@llvm-project//mlir:SCFToControlFlow", | ||
"@llvm-project//mlir:SideEffectInterfaces", | ||
"@llvm-project//mlir:Support", | ||
"@llvm-project//mlir:ToLLVMIRTranslation", | ||
"@llvm-project//mlir:TransformUtils", | ||
"@llvm-project//mlir:Transforms", | ||
], | ||
) |