add bazel support

This commit is contained in:
colin 2020-10-13 17:19:49 +08:00
parent 1b2fae016f
commit a0f2513706
16 changed files with 491 additions and 41 deletions

18
include/BUILD Normal file
View File

@ -0,0 +1,18 @@
package(
default_visibility = ["//visibility:public"],
)
cc_library(
name = "include",
srcs = [],
hdrs = [
"OnnxMlirRuntime.h",
"onnx-mlir/Runtime/OMTensor.h",
"onnx-mlir/Runtime/OMTensorList.h",
"onnx-mlir/Runtime/OnnxDataType.h",
"onnx-mlir/Runtime/OnnxDataTypeMetaData.inc",
],
strip_include_prefix = "//include",
# visibility = ["//visibility:public"],
deps = [],
)

View File

@ -1,35 +1,53 @@
package(
default_visibility = ["//visibility:public"],
)
cc_binary( genrule(
name = "MainUtils", name = "ExternalUtil",
srcs = ["MainUtils.hpp","MainUtils.cpp"], srcs = [
copts = [], "ExternalUtil.hpp.in",
deps = [ ],
"@onnx", outs = [
"//Builder:OMBuilder", "ExternalUtil.hpp",
OMKrnlOps ],
OMONNXOps cmd = "cp $(location :ExternalUtil.hpp.in) $(location :ExternalUtil.hpp)",
OMKrnlToAffine )
OMKrnlToLLVM
OMONNXToKrnl cc_library(
OMONNXRewrite name = "MainUtils",
OMShapeInference srcs = ["MainUtils.cpp"],
OMShapeInferenceOpInterface hdrs = [
OMAttributePromotion "MainUtils.hpp",
OMPromotableConstOperandsOpInterface ":ExternalUtil",
OMResultTypeInferenceOpInterface ],
OMElideConstants deps = [
OMElideKrnlGlobalConstants "//src/Builder:OMBuilder",
OMPackKrnlGlobalConstants "//src/Dialect/Krnl:OMKrnlOps",
OMEnableMemoryPool "//src/Dialect/ONNX:OMONNXOps",
OMBundleMemoryPools "//src/Pass:Passes",
OMDisconnectKrnlDimFromAlloc "@llvm-project//mlir:AllPassesAndDialectsNoRegistration",
OMLowerKrnlShape "@onnx",
], ],
) )
cc_binary( cc_binary(
name = "onnx-mlir", name = "onnx-mlir",
srcs = ["main.cpp"], srcs = ["main.cpp"],
copts = [], copts = [],
deps = [":MainUtils"], deps = [
":MainUtils",
"//src/Conversion/KrnlToAffine:OMKrnlToAffine",
"//src/Conversion/KrnlToLLVM:OMKrnlToLLVM",
"//src/Conversion/ONNXToKrnl:OMONNXToKrnl",
"//src/Transform:OMBundleMemoryPools",
"//src/Transform:OMDisconnectKrnlDimFromAlloc",
"//src/Transform:OMElideKrnlGlobalConstants",
"//src/Transform:OMEnableMemoryPool",
"//src/Transform:OMLowerKrnlShape",
"//src/Transform:OMPackKrnlGlobalConstants",
"//src/Transform/ONNX:OMAttributePromotion",
"//src/Transform/ONNX:OMElideConstants",
"//src/Transform/ONNX:OMONNXRewrite",
"//src/Transform/ONNX:OMShapeInference",
],
) )

View File

@ -1,11 +1,24 @@
package(
default_visibility = ["//visibility:public"],
)
cc_library( cc_library(
name = "OMBuilder", name = "OMBuilder",
srcs = [ srcs = [
"FrontendDialectHelper.cpp", "FrontendDialectHelper.cpp",
"FrontendDialectHelper.hpp",
"FrontendDialectTransformer.cpp", "FrontendDialectTransformer.cpp",
"FrontendDialectTransformer.hpp",
], ],
hdrs = ["header files"], hdrs = [
deps = ["header files"], "FrontendDialectHelper.hpp",
"FrontendDialectTransformer.hpp",
"OpBuildTable.inc",
],
deps = [
"@llvm-project//llvm:Support",
"@onnx",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:StandardOps",
"//src/Dialect/ONNX:OMONNXOps",
],
) )

View File

@ -0,0 +1,16 @@
package(
default_visibility = ["//visibility:public"],
)
cc_library(
name = "OMKrnlToAffine",
srcs = [
"KrnlToAffine.cpp",
],
hdrs = [
],
deps = [
"//src/Dialect/Krnl:OMKrnlOps",
"//src/Pass:Passes",
],
)

View File

@ -0,0 +1,23 @@
package(
default_visibility = ["//visibility:public"],
)
cc_library(
name = "OMKrnlToLLVM",
srcs = [
"KrnlToLLVM.cpp",
],
hdrs = [
"KrnlToLLVM.hpp",
],
deps = [
"//src/Conversion/ONNXToKrnl:OMONNXToKrnl",
"//src/Dialect/Krnl:OMKrnlOps",
"//src/Dialect/ONNX:OMONNXOps",
"//src/Pass:Passes",
"@llvm-project//llvm:FrontendOpenMP",
"@llvm-project//mlir:OpenMPToLLVM",
"@llvm-project//mlir:Shape",
"@onnx",
],
)

View File

@ -0,0 +1,46 @@
package(
default_visibility = ["//visibility:public"],
)
cc_library(
name = "OMONNXToKrnl",
srcs = [
"ConvertONNXToKrnl.cpp",
"Math/Elementwise.cpp",
"Math/Gemm.cpp",
"Math/MatMul.cpp",
"Math/Reduction.cpp",
"Math/Softmax.cpp",
"NN/Conv.cpp",
"NN/Normalization.cpp",
"NN/Pooling.cpp",
"ONNXToKrnlCommon.cpp",
"ONNXToKrnlCommon.hpp",
"RNN/LSTM.cpp",
"RNN/RNNBase.cpp",
"RNN/RNNBase.hpp",
"Tensor/Concat.cpp",
"Tensor/Constant.cpp",
"Tensor/ConstantOfShape.cpp",
"Tensor/Gather.cpp",
"Tensor/Identity.cpp",
"Tensor/Pad.cpp",
"Tensor/PadConstantValuePad.cpp",
"Tensor/Reshape.cpp",
"Tensor/Size.cpp",
"Tensor/Split.cpp",
"Tensor/Squeeze.cpp",
"Tensor/Tile.cpp",
"Tensor/Transpose.cpp",
"Tensor/Unsqueeze.cpp",
],
hdrs = [
],
deps = [
"//src/Dialect/Krnl:OMKrnlOps",
"//src/Dialect/ONNX:OMONNXOps",
"//src/Pass:Passes",
"@llvm-project//mlir:ConversionPasses",
"@onnx",
],
)

View File

@ -1,3 +1,7 @@
package(
default_visibility = ["//visibility:public"],
)
load("@llvm-project//mlir:tblgen.bzl", "gentbl") load("@llvm-project//mlir:tblgen.bzl", "gentbl")
gentbl( gentbl(

View File

@ -31,11 +31,9 @@ cc_library(
]), ]),
deps = [ deps = [
":OMONNXOpsIncGen", ":OMONNXOpsIncGen",
"//src/Interface:OMPromotableConstOperandsOpInterface",
"@//src/Interface:OMPromotableConstOperandsOpInterface", "//src/Interface:OMShapeInferenceOpInterface",
"@//src/Interface:OMShapeInferenceOpInterface", "//src/Interface:OMResultTypeInferenceOpInterface",
"@//src/Interface:OMResultTypeInferenceOpInterface",
"@onnx", "@onnx",
# "@onnx//:onnx_proto_genproto", # "@onnx//:onnx_proto_genproto",
# "@llvm-project//mlir:Affine", # "@llvm-project//mlir:Affine",
@ -57,3 +55,22 @@ cc_library(
# "@llvm-project//mlir:TableGen", # "@llvm-project//mlir:TableGen",
], ],
) )
# "@llvm-project//llvm:core",
# "@llvm-project//llvm:dtu_asm_parser",
# "@llvm-project//llvm:dtu_code_gen",
# "@llvm-project//llvm:dtu_desc",
# "@llvm-project//llvm:orc_jit",
# "@llvm-project//llvm:passes",
# "@llvm-project//llvm:x86_asm_parser",
# "@llvm-project//llvm:x86_code_gen",
# "@llvm-project//mlir:AffineOps",
# "@llvm-project//mlir:Dialect",
# "@llvm-project//mlir:ExecutionEngine",
# "@llvm-project//mlir:LLVMDialect",
# "@llvm-project//mlir:LoopOps",
# "@llvm-project//mlir:MlirOptLib",
# "@llvm-project//mlir:Parser",
# "@llvm-project//mlir:StandardOps",
# "@llvm-project//mlir:Support",
# "@llvm-project//mlir:VectorOps",

10
src/Pass/BUILD Normal file
View File

@ -0,0 +1,10 @@
package(
default_visibility = ["//visibility:public"],
)
cc_library(
name = "Passes",
srcs = [],
hdrs = ["Passes.hpp"],
deps = [],
)

View File

@ -0,0 +1,73 @@
package(
default_visibility = ["//visibility:public"],
)
cc_library(
name = "cruntime",
srcs = [
"OMTensor.c",
"OMTensor.inc",
"OMTensorList.c",
"OMTensorList.inc",
"OnnxDataType.cpp",
],
hdrs = [],
deps = [
"//include",
],
alwayslink = 1,
)
cc_library(
name = "OMTensorUtils",
srcs = [
"OMTensor.cpp",
"OMTensor.inc",
"OMTensorList.cpp",
"OMTensorList.inc",
"OnnxDataType.cpp",
],
hdrs = ["OMTensorHelper.h"],
deps = [
"//include",
],
)
cc_library(
name = "ExecutionSession",
srcs = [
"ExecutionSession.cpp",
],
hdrs = ["ExecutionSession.hpp"],
deps = [
"//include",
],
)
cc_binary(
name = "PyRuntime.so",
srcs = [
"PyExecutionSession.cpp",
"PyExecutionSession.hpp",
],
copts = ["-I/usr/include/python3.6"],
linkshared = True,
deps = [
":ExecutionSession",
":OMTensorUtils",
"@onnx",
"@pybind11",
],
)
cc_library(
name = "EmbeddedDataLoader",
srcs = [
"GetEmbeddedConstPool.cpp",
],
hdrs = ["GetEmbeddedConstPool.h"],
deps = [
"//include",
],
alwayslink = 1,
)

View File

@ -0,0 +1,13 @@
package(
default_visibility = ["//visibility:public"],
)
cc_binary(
name = "binary-decoder",
srcs = ["BinaryDecoder.cpp"],
copts = [],
deps = [
"@llvm-project//llvm:Core",
"@onnx",
],
)

View File

@ -0,0 +1,16 @@
package(
default_visibility = ["//visibility:public"],
)
cc_binary(
name = "onnx-mlir-opt",
srcs = ["ONNXMLIROpt.cpp"],
copts = [],
deps = [
"@llvm-project//llvm:Core",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:mlir-opt",
"//src/Dialect/Krnl:OMKrnlOps",
"@onnx",
],
)

View File

@ -0,0 +1,60 @@
package(
default_visibility = ["//visibility:public"],
)
cc_library(
name = "OMElideKrnlGlobalConstants",
srcs = ["ElideKrnlGlobalConstants.cpp"],
hdrs = ["ElideKrnlGlobalConstants.hpp"],
deps = [
"//src/Dialect/Krnl:OMKrnlOps",
"//src/Pass:Passes",
# "@onnx",
],
)
cc_library(
name = "OMPackKrnlGlobalConstants",
srcs = ["PackKrnlGlobalConstants.cpp"],
deps = [
"//src/Dialect/Krnl:OMKrnlOps",
"//src/Pass:Passes",
":OMElideKrnlGlobalConstants",
# "@onnx",
],
)
cc_library(
name = "OMEnableMemoryPool",
srcs = ["EnableMemoryPool.cpp"],
deps = [
"//src/Conversion/ONNXToKrnl:OMONNXToKrnl",
# "@onnx",
],
)
cc_library(
name = "OMBundleMemoryPools",
srcs = ["BundleMemoryPools.cpp"],
deps = [
"//src/Conversion/ONNXToKrnl:OMONNXToKrnl",
# "@onnx",
],
)
cc_library(
name = "OMDisconnectKrnlDimFromAlloc",
srcs = ["DisconnectKrnlDimFromAlloc.cpp"],
deps = [
"//src/Conversion/ONNXToKrnl:OMONNXToKrnl",
# "@onnx",
],
)
cc_library(
name = "OMLowerKrnlShape",
srcs = ["LowerKrnlShape.cpp"],
deps = [
"//src/Conversion/ONNXToKrnl:OMONNXToKrnl",
],
)

116
src/Transform/ONNX/BUILD Normal file
View File

@ -0,0 +1,116 @@
package(
default_visibility = ["//visibility:public"],
)
cc_library(
name = "OMAttributePromotion",
srcs = ["AttributePromotion.cpp"],
copts = [],
deps = [
"//src/Dialect/ONNX:OMONNXOps",
"//src/Pass:Passes",
"@llvm-project//mlir:StandardOps",
"@onnx",
],
)
cc_library(
name = "OMElideConstants",
srcs = ["ElideConstants.cpp"],
copts = [],
deps = [
"//src/Dialect/ONNX:OMONNXOps",
"//src/Pass:Passes",
"@llvm-project//mlir:StandardOps",
"@onnx",
],
)
load("@llvm-project//mlir:tblgen.bzl", "gentbl")
gentbl(
name = "OMONNXRewriteIncGen",
tbl_outs = [
("-gen-rewriters", "ONNXRewrite.inc"),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "Rewrite.td",
td_includes = ["."],
td_srcs = [
"@llvm-project//mlir:TdFiles",
],
)
gentbl(
name = "OMONNXCombineIncGen",
tbl_outs = [
("-gen-rewriters", "ONNXCombine.inc"),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "Combine.td",
td_includes = ["."],
td_srcs = [
"@llvm-project//mlir:TdFiles",
],
)
gentbl(
name = "OMONNXDecomposeIncGen",
tbl_outs = [
("-gen-rewriters", "ONNXDecompose.inc"),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "Decompose.td",
td_includes = ["."],
td_srcs = [
"@llvm-project//mlir:TdFiles",
],
)
gentbl(
name = "OMONNXConstPropIncGen",
tbl_outs = [
("-gen-rewriters", "ONNXConstProp.inc"),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "ConstProp.td",
td_includes = ["."],
td_srcs = [
"@llvm-project//mlir:TdFiles",
],
)
cc_library(
name = "OMONNXRewrite",
srcs = [
"Combine.cpp",
"ConstProp.cpp",
"Decompose.cpp",
"Rewrite.cpp",
],
copts = [],
deps = [
":OMONNXCombineIncGen",
":OMONNXConstPropIncGen",
":OMONNXDecomposeIncGen",
":OMONNXRewriteIncGen",
"//src/Dialect/ONNX:OMONNXOps",
"//src/Pass:Passes",
"@llvm-project//mlir:StandardOps",
"@onnx",
],
alwayslink = 1,
)
cc_library(
name = "OMShapeInference",
srcs = [
"ShapeInferencePass.cpp",
],
copts = [],
deps = [
"//src/Interface:OMShapeInferenceOpInterface",
"//src/Pass:Passes",
"@llvm-project//mlir:StandardOps",
],
)

@ -1 +0,0 @@
Subproject commit 1d01fc100bb5bef5f5eaf92520b2e52f64ee1d6e

8
third_party/pybind11.BUILD vendored Normal file
View File

@ -0,0 +1,8 @@
package(default_visibility = ["//visibility:public"])
cc_library(
name = "pybind11",
hdrs = glob(["include/**/*."]),
includes = ["include"],
)