[NFC] Breakdown CMake Build Scripts to Smaller Parts (#39)

* 1.Break down CMake scripts to smaller libraries per-directory.
2. Move some transformations and interfaces to the right folder.
3. Fix minor merge failure of the patch renaming files to use LLVM convention.

* Link OMBuilder with OMONNXOps.

* 1. Update the src location of generated ONNX dialect definition.
2. Link OMONNXRewrite with OMONNXOps.

* Fix path to tablegen for add_onnx_mlir_dialect_doc.

* Update build script for onnx_mlir_transform.

* 1. Remove comment code.
2. onnx_mlir_attribute_promotion -> OMAttributePromotion.

* Name tablegen generated files with LLVM convention.

* Nit: reorder libraries to link against.

* Nit: Link against MLIR first.
This commit is contained in:
Tian Jin 2020-03-20 22:40:51 +08:00 committed by GitHub
parent 0aafb3e72f
commit febee542ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 235 additions and 184 deletions

View File

@ -200,7 +200,8 @@ function(onnx_mlir_tablegen ofn)
tablegen(MLIR tablegen(MLIR
${ARGV} ${ARGV}
"-I${MLIR_SRC_INCLUDE_PATH}" "-I${MLIR_SRC_INCLUDE_PATH}"
"-I${MLIR_BIN_INCLUDE_PATH}") "-I${MLIR_BIN_INCLUDE_PATH}"
"-I${ONNX_MLIR_SRC_ROOT}")
set(TABLEGEN_OUTPUT set(TABLEGEN_OUTPUT
${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn} ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
PARENT_SCOPE) PARENT_SCOPE)

View File

@ -1,15 +1,20 @@
add_library(builder add_library(OMBuilder
FrontendDialectHelper.cpp FrontendDialectHelper.cpp
FrontendDialectHelper.hpp FrontendDialectHelper.hpp
FrontendDialectTransformer.cpp FrontendDialectTransformer.cpp
FrontendDialectTransformer.hpp FrontendDialectTransformer.hpp
OpBuildTable.inc) OpBuildTable.inc)
target_include_directories(builder PRIVATE ${CMAKE_SOURCE_DIR}) target_include_directories(OMBuilder PRIVATE ${CMAKE_SOURCE_DIR})
target_include_directories(builder PRIVATE ${CMAKE_BINARY_DIR}) target_include_directories(OMBuilder PRIVATE ${CMAKE_BINARY_DIR})
target_link_libraries(builder compiler onnx ${MLIRLibs} curses mpark_variant) target_link_libraries(OMBuilder
target_include_directories(builder OMONNXOps
onnx
${MLIRLibs}
curses
mpark_variant)
target_include_directories(OMBuilder
PUBLIC PUBLIC
${CMAKE_SOURCE_DIR}/third_party/onnx ${CMAKE_SOURCE_DIR}/third_party/onnx
${CMAKE_SOURCE_DIR}/third_party/variant ${CMAKE_SOURCE_DIR}/third_party/variant

View File

@ -1,127 +1,25 @@
add_library(compiler
Dialect/Krnl/KrnlOps.cpp
Dialect/Krnl/KrnlOps.hpp
Dialect/Krnl/KrnlTypes.cpp
Dialect/Krnl/KrnlTypes.hpp
Dialect/ONNX/ONNXOps.cpp
Dialect/ONNX/ONNXOps.hpp
Dialect/Krnl/KrnlHelper.cpp
Dialect/Krnl/KrnlHelper.hpp
Pass/ShapeInferenceInterface.hpp
Pass/ONNXCombine.cpp
Pass/ONNXRewrite.cpp
Pass/ONNXDecompose.cpp
Pass/Passes.hpp)
# Include root src directory.
target_include_directories(compiler PRIVATE ${ONNX_MLIR_SRC_ROOT})
# Include tablegen generated header files.
target_include_directories(compiler PRIVATE ${ONNX_MLIR_BIN_ROOT})
target_link_libraries(compiler
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS}
${MLIRLibs}
curses)
set(LLVM_TARGET_DEFINITIONS Pass/ONNXDecompose.td)
onnx_mlir_tablegen(onnx_decompose.inc -gen-rewriters)
add_public_tablegen_target(gen_onnx_decompose)
add_dependencies(compiler gen_onnx_decompose)
set(LLVM_TARGET_DEFINITIONS Pass/ShapeInferenceInterface.td)
onnx_mlir_tablegen(shape_inference.hpp.inc -gen-op-interface-decls)
onnx_mlir_tablegen(shape_inference.cpp.inc -gen-op-interface-defs)
add_public_tablegen_target(gen_shape_inference)
add_dependencies(compiler gen_shape_inference)
set(LLVM_TARGET_DEFINITIONS Pass/ONNXCombine.td)
onnx_mlir_tablegen(onnx_combine.inc -gen-rewriters)
add_public_tablegen_target(gen_onnx_combine)
add_dependencies(compiler gen_onnx_combine)
set(LLVM_TARGET_DEFINITIONS Pass/ONNXRewrite.td)
onnx_mlir_tablegen(onnx_rewrite.inc -gen-rewriters)
add_public_tablegen_target(gen_onnx_rewrite)
add_dependencies(compiler gen_onnx_rewrite)
add_subdirectory(Interface) add_subdirectory(Interface)
add_subdirectory(Dialect)
set(LLVM_TARGET_DEFINITIONS Dialect/ONNX/ONNXOps.td) add_subdirectory(Conversion)
onnx_mlir_tablegen(onnx.hpp.inc -gen-op-decls "-I${CMAKE_SOURCE_DIR}/compiler/pass")
onnx_mlir_tablegen(onnx.cpp.inc -gen-op-defs "-I${CMAKE_SOURCE_DIR}/compiler/pass")
set(GEN_DOC_FILE ${CMAKE_BINARY_DIR}/docs/Dialects/onnx.md)
add_public_tablegen_target(gen_onnx)
add_dependencies(gen_onnx gen_shape_inference)
add_dependencies(compiler gen_onnx)
# TODO: onnx_mlir_gen_promotable_const_operands_op_interface is really a
# dependency of the onnx dialect library, which is currently part of `compiler`.
add_dependencies(compiler onnx_mlir_gen_promotable_const_operands_op_interface)
add_onnx_mlir_dialect_doc(onnx Dialect/ONNX/ONNXOps.td)
set(LLVM_TARGET_DEFINITIONS Dialect/Krnl/KrnlOps.td)
onnx_mlir_tablegen(krnl.hpp.inc -gen-op-decls)
onnx_mlir_tablegen(krnl.cpp.inc -gen-op-defs)
add_public_tablegen_target(gen_krnl_ops)
add_dependencies(compiler gen_krnl_ops)
add_library(onnx_mlir_onnx_decompose Pass/ONNXDecompose.cpp)
target_include_directories(onnx_mlir_onnx_decompose
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT})
target_link_libraries(onnx_mlir_onnx_decompose ${MLIRLibs})
add_dependencies(onnx_mlir_onnx_decompose gen_onnx)
add_library(onnx_mlir_shape_inference Pass/ShapeInferencePass.cpp)
target_include_directories(onnx_mlir_shape_inference
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT})
target_link_libraries(onnx_mlir_shape_inference ${MLIRLibs})
add_dependencies(onnx_mlir_shape_inference gen_onnx)
add_library(onnx_mlir_lower_frontend
Conversion/ONNXToKrnl/ONNXToKrnlCommon.cpp
Conversion/ONNXToKrnl/ONNXToKrnlCommon.hpp
Conversion/ONNXToKrnl/Math/Elementwise.cpp
Conversion/ONNXToKrnl/Math/Gemm.cpp
Conversion/ONNXToKrnl/Math/MatMul.cpp
Conversion/ONNXToKrnl/Math/Reduction.cpp
Conversion/ONNXToKrnl/Math/Softmax.cpp
Conversion/ONNXToKrnl/NN/Conv.cpp
Conversion/ONNXToKrnl/NN/Normalization.cpp
Conversion/ONNXToKrnl/NN/Pooling.cpp
Conversion/ONNXToKrnl/Tensor/Identity.cpp
Conversion/ONNXToKrnl/Tensor/Reshape.cpp
Conversion/ONNXToKrnl/Tensor/PadConstantValuePad.cpp
Conversion/ONNXToKrnl/Tensor/Transpose.cpp
Conversion/ONNXToKrnl/Tensor/Unsqueeze.cpp
Conversion/ONNXToKrnl/Tensor/Constant.cpp
Conversion/ONNXToKrnl/ConvertONNXToKrnl.cpp)
target_include_directories(onnx_mlir_lower_frontend
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT})
target_link_libraries(onnx_mlir_lower_frontend ${MLIRLibs})
add_dependencies(onnx_mlir_lower_frontend gen_krnl_ops)
add_subdirectory(Transform) add_subdirectory(Transform)
add_subdirectory(Tool) add_subdirectory(Tool)
add_subdirectory(Builder) add_subdirectory(Builder)
add_subdirectory(Runtime) add_subdirectory(Runtime)
add_executable(onnx-mlir main.cpp) add_executable(onnx-mlir main.cpp)
target_link_libraries(onnx-mlir target_link_libraries(onnx-mlir
builder
${MLIRLibs} ${MLIRLibs}
onnx_mlir_transform OMBuilder
onnx_mlir_onnx_decompose OMKrnlOps
onnx_mlir_shape_inference OMONNXOps
onnx_mlir_lower_frontend OMKrnlToAffine
onnx_mlir_attribute_promotion) OMKrnlToLLVM
OMShapeInference
OMONNXToKrnl
OMONNXRewrite
OMAttributePromotion
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS})
whole_archive_link_mlir(onnx-mlir whole_archive_link_mlir(onnx-mlir
${MLIRWholeArchiveLibs}) ${MLIRWholeArchiveLibs})

View File

@ -0,0 +1 @@
add_subdirectory(ONNXToKrnl)

View File

@ -0,0 +1,26 @@
add_library(OMONNXToKrnl
ONNXToKrnlCommon.cpp
ONNXToKrnlCommon.hpp
Math/Elementwise.cpp
Math/Gemm.cpp
Math/MatMul.cpp
Math/Reduction.cpp
Math/Softmax.cpp
NN/Conv.cpp
NN/Normalization.cpp
NN/Pooling.cpp
Tensor/Identity.cpp
Tensor/Reshape.cpp
Tensor/PadConstantValuePad.cpp
Tensor/Transpose.cpp
Tensor/Unsqueeze.cpp
Tensor/Constant.cpp
ConvertONNXToKrnl.cpp)
target_include_directories(OMONNXToKrnl
PRIVATE
${ONNX_MLIR_SRC_ROOT}
${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT})
target_link_libraries(OMONNXToKrnl
${MLIRLibs}
OMKrnlOps)

View File

@ -0,0 +1,2 @@
add_subdirectory(Krnl)
add_subdirectory(ONNX)

View File

@ -0,0 +1,18 @@
set(LLVM_TARGET_DEFINITIONS KrnlOps.td)
onnx_mlir_tablegen(KrnlOps.hpp.inc -gen-op-decls)
onnx_mlir_tablegen(KrnlOps.cpp.inc -gen-op-defs)
add_public_tablegen_target(OMKrnlOpsIncGen)
add_library(OMKrnlOps
KrnlOps.hpp
KrnlOps.cpp
KrnlTypes.hpp
KrnlTypes.cpp
KrnlHelper.hpp
KrnlHelper.cpp)
target_include_directories(OMKrnlOps
PRIVATE
${ONNX_MLIR_SRC_ROOT}
${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT})
add_dependencies(OMKrnlOps OMKrnlOpsIncGen)

View File

@ -37,7 +37,7 @@ KrnlOpsDialect::KrnlOpsDialect(MLIRContext *context)
: Dialect(getDialectNamespace(), context) { : Dialect(getDialectNamespace(), context) {
addOperations< addOperations<
#define GET_OP_LIST #define GET_OP_LIST
#include "src/krnl.cpp.inc" #include "src/Dialect/Krnl/KrnlOps.cpp.inc"
>(); >();
addTypes<LoopType>(); addTypes<LoopType>();
} }
@ -375,5 +375,5 @@ void KrnlEntryPointOp::build(mlir::Builder *builder, OperationState &state,
} }
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "src/krnl.cpp.inc" #include "src/Dialect/Krnl/KrnlOps.cpp.inc"
} // namespace mlir } // namespace mlir

View File

@ -45,5 +45,5 @@ public:
}; };
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "src/krnl.hpp.inc" #include "src/Dialect/Krnl/KrnlOps.hpp.inc"
} // namespace mlir } // namespace mlir

View File

@ -0,0 +1,20 @@
set(LLVM_TARGET_DEFINITIONS ONNXOps.td)
onnx_mlir_tablegen(ONNXOps.hpp.inc -gen-op-decls "-I${CMAKE_SOURCE_DIR}/compiler/pass")
onnx_mlir_tablegen(ONNXOps.cpp.inc -gen-op-defs "-I${CMAKE_SOURCE_DIR}/compiler/pass")
set(GEN_DOC_FILE ${CMAKE_BINARY_DIR}/docs/Dialects/onnx.md)
add_public_tablegen_target(OMONNXOpsIncGen)
add_library(OMONNXOps
ONNXOps.cpp
ONNXOps.hpp)
target_include_directories(OMONNXOps
PRIVATE
${ONNX_MLIR_SRC_ROOT}
${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT})
add_dependencies(OMONNXOps OMONNXOpsIncGen)
target_link_libraries(OMONNXOps
OMPromotableConstOperandsOpInterface
OMShapeInferenceOpInterface)
add_onnx_mlir_dialect_doc(onnx ONNXOps.td)

View File

@ -310,7 +310,7 @@ ONNXOpsDialect::ONNXOpsDialect(mlir::MLIRContext *ctx)
: mlir::Dialect(getDialectNamespace(), ctx) { : mlir::Dialect(getDialectNamespace(), ctx) {
addOperations< addOperations<
#define GET_OP_LIST #define GET_OP_LIST
#include "src/onnx.cpp.inc" #include "src/Dialect/ONNX/ONNXOps.cpp.inc"
>(); >();
} }
@ -1325,4 +1325,4 @@ void ONNXConstantOp::inferShapes() {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "src/onnx.cpp.inc" #include "src/Dialect/ONNX/ONNXOps.cpp.inc"

View File

@ -19,7 +19,7 @@
#include "mlir/IR/OpDefinition.h" #include "mlir/IR/OpDefinition.h"
#include "mlir/IR/StandardTypes.h" #include "mlir/IR/StandardTypes.h"
#include "src/Pass/ShapeInferenceInterface.hpp" #include "src/Interface/ShapeInferenceInterface.hpp"
#include "src/Interface/PromotableConstOperandsOpInterface.hpp" #include "src/Interface/PromotableConstOperandsOpInterface.hpp"
namespace mlir { namespace mlir {
@ -36,7 +36,7 @@ class ONNXOpsDialect : public Dialect {
/// Include the auto-generated header file containing the declarations of the /// Include the auto-generated header file containing the declarations of the
/// ONNX operations. /// ONNX operations.
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "src/onnx.hpp.inc" #include "src/Dialect/ONNX/ONNXOps.hpp.inc"
} // end namespace mlir } // end namespace mlir

View File

@ -19,12 +19,12 @@ include "mlir/IR/OpBase.td"
#ifdef SHAPE_INFERENCE_INTERFACE #ifdef SHAPE_INFERENCE_INTERFACE
#else #else
include "Pass/ShapeInferenceInterface.td" include "src/Interface/ShapeInferenceInterface.td"
#endif // SHAPE_INFERENCE_INTERFACE #endif // SHAPE_INFERENCE_INTERFACE
#ifdef PROMOTABLE_CONST_OPERANDS_OP_INTERFACE #ifdef PROMOTABLE_CONST_OPERANDS_OP_INTERFACE
#else #else
include "Interface/PromotableConstOperandsOpInterface.td" include "src/Interface/PromotableConstOperandsOpInterface.td"
#endif // PROMOTABLE_CONST_OPERANDS_OP_INTERFACE #endif // PROMOTABLE_CONST_OPERANDS_OP_INTERFACE
def ONNX_Dialect : Dialect { def ONNX_Dialect : Dialect {
@ -61,7 +61,7 @@ class ONNX_Op<string mnemonic, list<OpTrait> traits = []> :
// 4. type of string, complex64 and complex128 for input/output are ignored // 4. type of string, complex64 and complex128 for input/output are ignored
// 5. unsigned int are treated as signed one // 5. unsigned int are treated as signed one
include "Dialect/ONNX/ONNXOps.td.inc" include "src/Dialect/ONNX/ONNXOps.td.inc"
// Indicate entry point functions of ONNX graph. // Indicate entry point functions of ONNX graph.
def ONNXEntryPointOp: ONNX_Op<"EntryPoint"> { def ONNXEntryPointOp: ONNX_Op<"EntryPoint"> {

View File

@ -1,14 +1,27 @@
set(LLVM_TARGET_DEFINITIONS PromotableConstOperandsOpInterface.td) set(LLVM_TARGET_DEFINITIONS PromotableConstOperandsOpInterface.td)
onnx_mlir_tablegen(promotable_const_operands_op_interface.hpp.inc -gen-op-interface-decls) onnx_mlir_tablegen(PromotableConstOperandsOpInterface.hpp.inc -gen-op-interface-decls)
onnx_mlir_tablegen(promotable_const_operands_op_interface.cpp.inc -gen-op-interface-defs) onnx_mlir_tablegen(PromotableConstOperandsOpInterface.cpp.inc -gen-op-interface-defs)
add_public_tablegen_target(onnx_mlir_gen_promotable_const_operands_op_interface) add_public_tablegen_target(OMPromotableConstOperandsOpInterfaceIncGen)
add_library(onnx_mlir_promotable_const_operands_op_interface add_library(OMPromotableConstOperandsOpInterface
PromotableConstOperandsOpInterface.hpp PromotableConstOperandsOpInterface.hpp
PromotableConstOperandsOpInterface.cpp) PromotableConstOperandsOpInterface.cpp)
target_include_directories(onnx_mlir_promotable_const_operands_op_interface target_include_directories(OMPromotableConstOperandsOpInterface
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT} PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT}) ${ONNX_MLIR_SRC_ROOT})
add_dependencies(OMPromotableConstOperandsOpInterface
OMPromotableConstOperandsOpInterfaceIncGen)
add_dependencies(onnx_mlir_promotable_const_operands_op_interface
onnx_mlir_gen_promotable_const_operands_op_interface) set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)
onnx_mlir_tablegen(ShapeInference.hpp.inc -gen-op-interface-decls)
onnx_mlir_tablegen(ShapeInference.cpp.inc -gen-op-interface-defs)
add_public_tablegen_target(ShapeInferenceOpInterfaceIncGen)
add_library(OMShapeInferenceOpInterface
ShapeInferenceInterface.hpp
ShapeInferenceInterface.cpp)
target_include_directories(OMShapeInferenceOpInterface
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT})
add_dependencies(OMShapeInferenceOpInterface ShapeInferenceOpInterfaceIncGen)

View File

@ -1,4 +1,4 @@
//===------------ promotable_const_operands_op_interface.cpp --------------===// //===------------ PromotableConstOperandsOpInterface.cpp --------------===//
//===-------- Promotable Const Operands Op Interface Definition -----------===// //===-------- Promotable Const Operands Op Interface Definition -----------===//
// //
// Copyright 2020 The IBM Research Authors. // Copyright 2020 The IBM Research Authors.
@ -19,5 +19,5 @@ using namespace mlir;
// Promotable Const Operands Op Interface // Promotable Const Operands Op Interface
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "src/Interface/promotable_const_operands_op_interface.cpp.inc" #include "src/Interface/PromotableConstOperandsOpInterface.cpp.inc"

View File

@ -1,4 +1,4 @@
//===------------ promotable_const_operands_op_interface.cpp --------------===// //===------------ PromotableConstOperandsOpInterface.hpp --------------===//
//===-------- Promotable Const Operands Op Interface Definition -----------===// //===-------- Promotable Const Operands Op Interface Definition -----------===//
// //
// Copyright 2020 The IBM Research Authors. // Copyright 2020 The IBM Research Authors.
@ -20,6 +20,6 @@
namespace mlir { namespace mlir {
/// Include the auto-generated declarations. /// Include the auto-generated declarations.
#include "src/Interface/promotable_const_operands_op_interface.hpp.inc" #include "src/Interface/PromotableConstOperandsOpInterface.hpp.inc"
} // end namespace mlir } // end namespace mlir

View File

@ -1,4 +1,4 @@
//===------------- promotable_const_operands_op_interface.td --------------===// //===------------- PromotableConstOperandsOpInterface.td --------------===//
//===---- Promotable Const Operands Op Interface TableGen Definition ------===// //===---- Promotable Const Operands Op Interface TableGen Definition ------===//
// //
// Copyright 2020 The IBM Research Authors. // Copyright 2020 The IBM Research Authors.

View File

@ -0,0 +1,19 @@
//===---- ShapeInferenceInterface.cpp - Definition for ShapeInference -----===//
//
// Copyright 2019-2020 The IBM Research Authors.
//
// =============================================================================
//
// This file contains the implementations of the shape inference interfaces
// defined in ShapeInferenceInterface.td.
//
//===----------------------------------------------------------------------===//
#include "src/Interface/ShapeInferenceInterface.hpp"
namespace mlir {
/// Include the auto-generated declarations.
#include "src/Interface/ShapeInference.cpp.inc"
} // end namespace mlir

View File

@ -16,6 +16,6 @@
namespace mlir { namespace mlir {
/// Include the auto-generated declarations. /// Include the auto-generated declarations.
#include "src/shape_inference.hpp.inc" #include "src/Interface/ShapeInference.hpp.inc"
} // end namespace mlir } // end namespace mlir

View File

@ -1,22 +1,25 @@
add_executable(onnx-mlir-opt ONNXMLIROpt.cpp) add_executable(onnx-mlir-opt ONNXMLIROpt.cpp)
add_dependencies(onnx-mlir-opt gen_krnl_ops) add_dependencies(onnx-mlir-opt OMKrnlOpsIncGen)
target_include_directories(onnx-mlir-opt PRIVATE ${ONNX_MLIR_SRC_ROOT}) target_include_directories(onnx-mlir-opt PRIVATE ${ONNX_MLIR_SRC_ROOT})
target_include_directories(onnx-mlir-opt PRIVATE ${ONNX_MLIR_BIN_ROOT}) target_include_directories(onnx-mlir-opt PRIVATE ${ONNX_MLIR_BIN_ROOT})
target_link_libraries(onnx-mlir-opt target_link_libraries(onnx-mlir-opt
builder
${MLIRLibs} ${MLIRLibs}
onnx_mlir_transform OMBuilder
onnx_mlir_shape_inference OMKrnlOps
onnx_mlir_lower_frontend OMKrnlToAffine
onnx_mlir_promotable_const_operands_op_interface OMKrnlToLLVM
OMShapeInference
OMONNXToKrnl
OMPromotableConstOperandsOpInterface
curses) curses)
whole_archive_link_mlir(onnx-mlir-opt whole_archive_link_mlir(onnx-mlir-opt
${MLIRWholeArchiveLibs}) ${MLIRWholeArchiveLibs})
whole_archive_link_onnx_mlir(onnx-mlir-opt whole_archive_link_onnx_mlir(onnx-mlir-opt
compiler OMKrnlToAffine
onnx_mlir_transform OMKrnlToLLVM
onnx_mlir_lower_frontend OMONNXToKrnl
onnx_mlir_shape_inference OMONNXRewrite
onnx_mlir_attribute_promotion) OMShapeInference
OMAttributePromotion)

View File

@ -1,11 +1,25 @@
add_library(onnx_mlir_transform add_library(OMKrnlToAffine
LowerKrnl.cpp LowerKrnl.cpp)
target_include_directories(OMKrnlToAffine
PRIVATE
${ONNX_MLIR_SRC_ROOT}
${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT})
target_link_libraries(OMKrnlToAffine
${MLIRLibs}
OMKrnlOps
OMONNXOps)
add_library(OMKrnlToLLVM
LowerToLLVM.cpp) LowerToLLVM.cpp)
target_include_directories(OMKrnlToLLVM
PRIVATE
${ONNX_MLIR_SRC_ROOT}
${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT})
target_link_libraries(OMKrnlToLLVM
${MLIRLibs}
OMKrnlOps
OMONNXOps)
target_include_directories(onnx_mlir_transform add_subdirectory(ONNX)
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT})
target_link_libraries(onnx_mlir_transform ${MLIRLibs})
add_dependencies(onnx_mlir_transform gen_krnl_ops)
add_subdirectory(onnx)

View File

@ -0,0 +1,42 @@
add_library(OMAttributePromotion
AttributePromotion.cpp)
target_include_directories(OMAttributePromotion
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
${ONNF_MLIR_SRC_ROOT})
target_link_libraries(OMAttributePromotion
OMPromotableConstOperandsOpInterface)
set(LLVM_TARGET_DEFINITIONS ONNXRewrite.td)
onnx_mlir_tablegen(ONNXRewrite.inc -gen-rewriters)
add_public_tablegen_target(OMONNXRewriteIncGen)
set(LLVM_TARGET_DEFINITIONS ONNXCombine.td)
onnx_mlir_tablegen(ONNXCombine.inc -gen-rewriters)
add_public_tablegen_target(OMONNXCombineIncGen)
set(LLVM_TARGET_DEFINITIONS ONNXDecompose.td)
onnx_mlir_tablegen(ONNXDecompose.inc -gen-rewriters)
add_public_tablegen_target(OMONNXDecomposeIncGen)
add_library(OMONNXRewrite
ONNXRewrite.cpp
ONNXCombine.cpp
ONNXDecompose.cpp)
target_include_directories(OMONNXRewrite
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
${ONNF_MLIR_SRC_ROOT})
target_link_libraries(OMONNXRewrite
OMONNXOps)
add_dependencies(OMONNXRewrite
OMONNXRewriteIncGen
OMONNXDecomposeIncGen
OMONNXCombineIncGen)
add_library(OMShapeInference ShapeInferencePass.cpp)
target_include_directories(OMShapeInference
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT})
target_link_libraries(OMShapeInference
${MLIRLibs}
OMShapeInferenceOpInterface)
add_dependencies(OMShapeInference ShapeInferenceOpInterfaceIncGen)

View File

@ -19,7 +19,7 @@ using namespace mlir;
namespace { namespace {
/// Include the patterns defined in the Declarative Rewrite framework. /// Include the patterns defined in the Declarative Rewrite framework.
#include "src/onnx_combine.inc" #include "src/Transform/ONNX/ONNXCombine.inc"
} // end anonymous namespace } // end anonymous namespace
/// Register optimization patterns as "canonicalization" patterns /// Register optimization patterns as "canonicalization" patterns

View File

@ -13,7 +13,7 @@
#define ONNX_COMBINE #define ONNX_COMBINE
#ifndef OP_BASE #ifndef OP_BASE
include "Dialect/ONNX/ONNXOps.td" include "src/Dialect/ONNX/ONNXOps.td"
#endif // OP_BASE #endif // OP_BASE
/// Note: The DRR definition used for defining patterns is shown below: /// Note: The DRR definition used for defining patterns is shown below:

View File

@ -19,13 +19,13 @@
#include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/DialectConversion.h"
#include "src/Dialect/ONNX/ONNXOps.hpp" #include "src/Dialect/ONNX/ONNXOps.hpp"
#include "Passes.hpp" #include "src/Pass/Passes.hpp"
using namespace mlir; using namespace mlir;
namespace { namespace {
/// Include the patterns defined in the Declarative Rewrite framework. /// Include the patterns defined in the Declarative Rewrite framework.
#include "src/onnx_decompose.inc" #include "src/Transform/ONNX/ONNXDecompose.inc"
struct DecomposeONNXToONNXPass : public FunctionPass<DecomposeONNXToONNXPass> { struct DecomposeONNXToONNXPass : public FunctionPass<DecomposeONNXToONNXPass> {
void runOnFunction() final; void runOnFunction() final;

View File

@ -13,7 +13,7 @@
#define ONNX_DECOMPOSE #define ONNX_DECOMPOSE
#ifndef OP_BASE #ifndef OP_BASE
include "Dialect/ONNX/ONNXOps.td" include "src/Dialect/ONNX/ONNXOps.td"
#endif // OP_BASE #endif // OP_BASE
/// Note: The DRR definition used for defining patterns is shown below: /// Note: The DRR definition used for defining patterns is shown below:

View File

@ -68,7 +68,7 @@ ArrayAttr insertZerosForNonPaddedDims(
} }
/// Include the patterns defined in the Declarative Rewrite framework. /// Include the patterns defined in the Declarative Rewrite framework.
#include "src/onnx_rewrite.inc" #include "src/Transform/ONNX/ONNXRewrite.inc"
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Rewrite: // Rewrite:

View File

@ -13,7 +13,7 @@
#define ONNX_REWRITE #define ONNX_REWRITE
#ifndef OP_BASE #ifndef OP_BASE
include "Dialect/ONNX/ONNXOps.td" include "src/Dialect/ONNX/ONNXOps.td"
#endif // OP_BASE #endif // OP_BASE
/// Note: The DRR definition used for defining patterns is shown below: /// Note: The DRR definition used for defining patterns is shown below:

View File

@ -14,15 +14,11 @@
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "mlir/IR/StandardTypes.h" #include "mlir/IR/StandardTypes.h"
#include "ShapeInferenceInterface.hpp" #include "src/Interface/ShapeInferenceInterface.hpp"
#include "src/Pass/Passes.hpp"
#include "Passes.hpp"
using namespace mlir; using namespace mlir;
// Include the auto-generated definitions for the shape inference interfaces.
#include "src/shape_inference.cpp.inc"
namespace { namespace {
/*! /*!
* FunctionPass that performs shape inference by iterating over a list of * FunctionPass that performs shape inference by iterating over a list of

View File

@ -1,7 +0,0 @@
add_library(onnx_mlir_attribute_promotion
attribute_promotion.cpp)
target_include_directories(onnx_mlir_attribute_promotion
PRIVATE ${ONNX_MLIR_SRC_ROOT} ${ONNX_MLIR_BIN_ROOT}
${ONNF_MLIR_SRC_ROOT})
target_link_libraries(onnx_mlir_attribute_promotion
onnx_mlir_promotable_const_operands_op_interface)