Move to more recent LLVM commit ID (#131)

* Move to more recent LLVM ID (May 15)

* clang-format

* Bump cache version up

* Update readme

* Fix doc check

* Move to a newer commit id

* Update LoopToStandard -> SCFToStandard

* Change MLIRSideEffects to MLIRSideEffectInterfaces

Co-authored-by: Tian Jin <tjingrant@gmail.com>
This commit is contained in:
Tung D. Le 2020-05-20 16:45:42 +09:00 committed by GitHub
parent 5d85843be4
commit ad61eee908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 66 additions and 67 deletions

View File

@ -18,7 +18,7 @@ jobs:
git submodule update --init --recursive git submodule update --init --recursive
# Use cached mlir installation if possible. # Use cached mlir installation if possible.
- restore_cache: - restore_cache:
key: V11-LLVM-PROJECT-{{ arch }} key: V13-LLVM-PROJECT-{{ arch }}
- run: - run:
name: Install MLIR name: Install MLIR
command: | command: |
@ -29,7 +29,7 @@ jobs:
source onnx-mlir/utils/install-mlir.sh source onnx-mlir/utils/install-mlir.sh
fi fi
- save_cache: - save_cache:
key: V11-LLVM-PROJECT-{{ arch }} key: V13-LLVM-PROJECT-{{ arch }}
paths: paths:
- llvm-project - llvm-project
- run: - run:

View File

@ -144,16 +144,16 @@ find_mlir_lib(MLIRExecutionEngine)
find_mlir_lib(MLIRIR) find_mlir_lib(MLIRIR)
find_mlir_lib(MLIRLLVMIR) find_mlir_lib(MLIRLLVMIR)
find_mlir_lib(MLIRLoopAnalysis) find_mlir_lib(MLIRLoopAnalysis)
find_mlir_lib(MLIRLoopToStandard) find_mlir_lib(MLIRSCFToStandard)
find_mlir_lib(MLIRLoopOps)
find_mlir_lib(MLIRLoopLikeInterface) find_mlir_lib(MLIRLoopLikeInterface)
find_mlir_lib(MLIRSCF)
find_mlir_lib(MLIRLLVMIRTransforms) find_mlir_lib(MLIRLLVMIRTransforms)
find_mlir_lib(MLIRMlirOptMain) find_mlir_lib(MLIRMlirOptMain)
find_mlir_lib(MLIRParser) find_mlir_lib(MLIRParser)
find_mlir_lib(MLIRPass) find_mlir_lib(MLIRPass)
find_mlir_lib(MLIRStandardOps) find_mlir_lib(MLIRStandardOps)
find_mlir_lib(MLIRStandardToLLVM) find_mlir_lib(MLIRStandardToLLVM)
find_mlir_lib(MLIRSideEffects) find_mlir_lib(MLIRSideEffectInterfaces)
find_mlir_lib(MLIRTargetLLVMIR) find_mlir_lib(MLIRTargetLLVMIR)
find_mlir_lib(MLIRTransforms) find_mlir_lib(MLIRTransforms)
find_mlir_lib(MLIRTransformUtils) find_mlir_lib(MLIRTransformUtils)
@ -205,13 +205,13 @@ set(MLIRLibs
${MLIRExecutionEngine} ${MLIRExecutionEngine}
${MLIRIR} ${MLIRIR}
${MLIRLLVMIRTransforms} ${MLIRLLVMIRTransforms}
${MLIRLoopToStandard} ${MLIRSCFToStandard}
${MLIRLoopOps} ${MLIRSCF}
${MLIRLoopAnalysis} ${MLIRLoopAnalysis}
${MLIRLoopLikeInterface} ${MLIRLoopLikeInterface}
${MLIROpenMP} ${MLIROpenMP}
${MLIRMlirOptMain} ${MLIRMlirOptMain}
${MLIRSideEffects} ${MLIRSideEffectInterfaces}
${MLIRStandardOps} ${MLIRStandardOps}
${MLIRStandardToLLVM} ${MLIRStandardToLLVM}
${MLIRSupport} ${MLIRSupport}
@ -251,9 +251,9 @@ set(MLIRWholeArchiveLibs
MLIRStandardOps MLIRStandardOps
MLIRStandardToLLVM MLIRStandardToLLVM
MLIRTransforms MLIRTransforms
MLIRLoopToStandard MLIRSCFToStandard
MLIRVector MLIRVector
MLIRLoopOps MLIRSCF
MLIRIR) MLIRIR)
# ONNX MLIR libraries that must be linked with --whole-archive for static build or # ONNX MLIR libraries that must be linked with --whole-archive for static build or

View File

@ -24,7 +24,7 @@ Firstly, install MLIR (as a part of LLVM-Project):
``` bash ``` bash
git clone https://github.com/llvm/llvm-project.git git clone https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX MLIR. # Check out a specific branch that is known to work with ONNX MLIR.
cd llvm-project && git checkout 3ce0ad1b336e67a76d78ae7ff7d66fe127586620 && cd .. cd llvm-project && git checkout 0dc91bfd11e6cced0c46c1a25cc96edea0d8fc22 && cd ..
``` ```
[same-as-file]: <> (utils/build-mlir.sh) [same-as-file]: <> (utils/build-mlir.sh)
@ -114,7 +114,7 @@ Install MLIR (as a part of LLVM-Project):
```shell ```shell
git clone https://github.com/llvm/llvm-project.git git clone https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX MLIR. # Check out a specific branch that is known to work with ONNX MLIR.
cd llvm-project && git checkout 3ce0ad1b336e67a76d78ae7ff7d66fe127586620 && cd .. cd llvm-project && git checkout 0dc91bfd11e6cced0c46c1a25cc96edea0d8fc22 && cd ..
``` ```
[same-as-file]: <> (utils/build-mlir.cmd) [same-as-file]: <> (utils/build-mlir.cmd)

View File

@ -20,7 +20,7 @@ Firstly, install MLIR (as a part of LLVM-Project):
``` bash ``` bash
git clone https://github.com/llvm/llvm-project.git git clone https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX MLIR. # Check out a specific branch that is known to work with ONNX MLIR.
cd llvm-project && git checkout 3ce0ad1b336e67a76d78ae7ff7d66fe127586620 && cd .. cd llvm-project && git checkout 0dc91bfd11e6cced0c46c1a25cc96edea0d8fc22 && cd ..
``` ```
[same-as-file]: <> (utils/build-mlir.sh) [same-as-file]: <> (utils/build-mlir.sh)
@ -110,7 +110,7 @@ Install MLIR (as a part of LLVM-Project):
```shell ```shell
git clone https://github.com/llvm/llvm-project.git git clone https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX MLIR. # Check out a specific branch that is known to work with ONNX MLIR.
cd llvm-project && git checkout 3ce0ad1b336e67a76d78ae7ff7d66fe127586620 && cd .. cd llvm-project && git checkout 0dc91bfd11e6cced0c46c1a25cc96edea0d8fc22 && cd ..
``` ```
[same-as-file]: <> (utils/build-mlir.cmd) [same-as-file]: <> (utils/build-mlir.cmd)

View File

@ -14,7 +14,6 @@
#include <regex> #include <regex>
#include <tuple> #include <tuple>
#include "mlir/Analysis/Verifier.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/IR/Attributes.h" #include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h" #include "mlir/IR/Builders.h"
@ -26,6 +25,7 @@
#include "mlir/IR/PatternMatch.h" #include "mlir/IR/PatternMatch.h"
#include "mlir/IR/StandardTypes.h" #include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Types.h" #include "mlir/IR/Types.h"
#include "mlir/IR/Verifier.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopedHashTable.h" #include "llvm/ADT/ScopedHashTable.h"

View File

@ -47,12 +47,12 @@ KrnlOpsDialect::KrnlOpsDialect(MLIRContext *context)
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
void KrnlDefineLoopsOp::build( void KrnlDefineLoopsOp::build(
Builder *builder, OperationState &result, int64_t num_loops) { OpBuilder &builder, OperationState &result, int64_t num_loops) {
// Create the same number of dimension handlers as the number of // Create the same number of dimension handlers as the number of
// dimensions in the associated integer set. // dimensions in the associated integer set.
result.types.append(num_loops, LoopType::get(builder->getContext())); result.types.append(num_loops, LoopType::get(builder.getContext()));
result.addAttribute( result.addAttribute(
getNumLoopsAttrName(), builder->getI32IntegerAttr(num_loops)); getNumLoopsAttrName(), builder.getI32IntegerAttr(num_loops));
} }
void print(OpAsmPrinter &p, KrnlDefineLoopsOp &op) { void print(OpAsmPrinter &p, KrnlDefineLoopsOp &op) {
@ -83,9 +83,8 @@ ParseResult parseKrnlDefineLoopsOp(
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
void KrnlOptimizeLoopsOp::build( void KrnlOptimizeLoopsOp::build(
Builder *builder, OperationState &result, int num_optimized_loops) { OpBuilder &builder, OperationState &result, int num_optimized_loops) {
result.types.append( result.types.append(num_optimized_loops, LoopType::get(builder.getContext()));
num_optimized_loops, LoopType::get(builder->getContext()));
// Create a region and a block for the body. // Create a region and a block for the body.
// Schedule intrinsics will be placed into this region. // Schedule intrinsics will be placed into this region.
Region *region = result.addRegion(); Region *region = result.addRegion();
@ -145,7 +144,7 @@ ParseResult parseKrnlOptimizeLoopsOp(
* Then the bounds will be parsed as: * Then the bounds will be parsed as:
* %i0 = 10 to N : %i1 = M to 20 * %i0 = 10 to N : %i1 = M to 20
*/ */
void KrnlIterateOp::build(Builder *builder, OperationState &result, void KrnlIterateOp::build(OpBuilder &builder, OperationState &result,
KrnlIterateOperandPack operandPack) { KrnlIterateOperandPack operandPack) {
// Record optimized loops and the number of such loops. // Record optimized loops and the number of such loops.
result.addOperands(operandPack.getOperands()); result.addOperands(operandPack.getOperands());
@ -153,7 +152,7 @@ void KrnlIterateOp::build(Builder *builder, OperationState &result,
KrnlIterateOp::getBoundsAttrName(), operandPack.getAttributes()); KrnlIterateOp::getBoundsAttrName(), operandPack.getAttributes());
result.addAttribute(getNumOptimizedLoopsAttrName(), result.addAttribute(getNumOptimizedLoopsAttrName(),
builder->getI64IntegerAttr(operandPack.getNumOptimizedLoops())); builder.getI64IntegerAttr(operandPack.getNumOptimizedLoops()));
// Create a region and a block for the body. The arguments of the region are // Create a region and a block for the body. The arguments of the region are
// the loop induction variables; there can be multiple induction variables // the loop induction variables; there can be multiple induction variables
@ -161,11 +160,11 @@ void KrnlIterateOp::build(Builder *builder, OperationState &result,
Region *bodyRegion = result.addRegion(); Region *bodyRegion = result.addRegion();
auto *body = new Block(); auto *body = new Block();
auto body_args = llvm::SmallVector<Type, 4>( auto body_args = llvm::SmallVector<Type, 4>(
operandPack.getNumInputLoops(), IndexType::get(builder->getContext())); operandPack.getNumInputLoops(), IndexType::get(builder.getContext()));
body->addArguments(body_args); body->addArguments(body_args);
bodyRegion->push_back(body); bodyRegion->push_back(body);
ensureTerminator(*bodyRegion, *builder, result.location); ensureTerminator(*bodyRegion, builder, result.location);
} }
void print(OpAsmPrinter &p, KrnlIterateOp &op) { void print(OpAsmPrinter &p, KrnlIterateOp &op) {
@ -247,7 +246,7 @@ ParseResult parseKrnlIterateOp(OpAsmParser &parser, OperationState &result) {
// Get the attribute location. // Get the attribute location.
llvm::SMLoc attrLoc = parser.getCurrentLocation(); llvm::SMLoc attrLoc = parser.getCurrentLocation();
Attribute boundAttr; Attribute boundAttr;
llvm::SmallVector<NamedAttribute, 1> tempBoundAttrContainer; NamedAttrList tempBoundAttrContainer;
if (parser.parseAttribute( if (parser.parseAttribute(
boundAttr, builder.getIndexType(), "temp", tempBoundAttrContainer)) boundAttr, builder.getIndexType(), "temp", tempBoundAttrContainer))
return failure(); return failure();
@ -361,7 +360,7 @@ ParseResult parseKrnlReturnLoopsOp(
return success(); return success();
} }
void KrnlEntryPointOp::build(mlir::Builder *builder, OperationState &state, void KrnlEntryPointOp::build(mlir::OpBuilder &builder, OperationState &state,
SymbolRefAttr funcAttr, IntegerAttr numInputs, IntegerAttr numOutputs) { SymbolRefAttr funcAttr, IntegerAttr numInputs, IntegerAttr numOutputs) {
state.addAttribute(KrnlEntryPointOp::getEntryPointFuncAttrName(), funcAttr); state.addAttribute(KrnlEntryPointOp::getEntryPointFuncAttrName(), funcAttr);
state.addAttribute(KrnlEntryPointOp::getNumInputsAttrName(), numInputs); state.addAttribute(KrnlEntryPointOp::getNumInputsAttrName(), numInputs);

View File

@ -29,7 +29,7 @@ def KrnlDefineLoopsOp : Op<Krnl_Dialect, "define_loops"> {
let arguments = (ins); let arguments = (ins);
let results = (outs Variadic<AnyType>); let results = (outs Variadic<AnyType>);
let skipDefaultBuilders = 1; let skipDefaultBuilders = 1;
let builders = [ OpBuilder<"Builder *builder, OperationState &result," let builders = [ OpBuilder<"OpBuilder &builder, OperationState &result,"
"int64_t num_loops"> ]; "int64_t num_loops"> ];
let printer = [{ return ::print(p, *this); }]; let printer = [{ return ::print(p, *this); }];
@ -67,7 +67,7 @@ def KrnlOptimizeLoopsOp : Op<Krnl_Dialect, "optimize_loops"> {
let skipDefaultBuilders = 1; let skipDefaultBuilders = 1;
let builders = [ OpBuilder<"Builder *builder, OperationState &result, " let builders = [ OpBuilder<"OpBuilder &builder, OperationState &result, "
"int timestamp_space_rank"> ]; "int timestamp_space_rank"> ];
let printer = [{ return ::print(p, *this); }]; let printer = [{ return ::print(p, *this); }];
@ -100,7 +100,7 @@ def KrnlIterateOp : Op<Krnl_Dialect, "iterate", [ImplicitKrnlTerminator]> {
let arguments = (ins Variadic<AnyType>); let arguments = (ins Variadic<AnyType>);
let regions = (region SizedRegion<1>:$bodyRegion); let regions = (region SizedRegion<1>:$bodyRegion);
let skipDefaultBuilders = 1; let skipDefaultBuilders = 1;
let builders = [ OpBuilder<"Builder *builder, OperationState &result, " let builders = [ OpBuilder<"OpBuilder &builder, OperationState &result, "
"KrnlIterateOperandPack operandPack"> ]; "KrnlIterateOperandPack operandPack"> ];
let extraClassDeclaration = [{ let extraClassDeclaration = [{
@ -165,7 +165,7 @@ def KrnlEntryPointOp : Op<Krnl_Dialect, "entry_point"> {
let summary = "Indicate ONNX entry point"; let summary = "Indicate ONNX entry point";
let description = [{The "krnl.entry_point" function indicates the main entry let description = [{The "krnl.entry_point" function indicates the main entry
point of ONNX model.}]; point of ONNX model.}];
let builders = [ OpBuilder<"Builder *builder, OperationState &result, " let builders = [ OpBuilder<"OpBuilder &builder, OperationState &result, "
"SymbolRefAttr funcAttr, IntegerAttr numInputs, " "SymbolRefAttr funcAttr, IntegerAttr numInputs, "
"IntegerAttr numOutputs"> ]; "IntegerAttr numOutputs"> ];

View File

@ -61,7 +61,7 @@ class MLONNX_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 "mlir/Interfaces/SideEffects.td" include "mlir/Interfaces/SideEffectInterfaces.td"
include "src/Dialect/MLONNX/MLONNXOps.td.inc" include "src/Dialect/MLONNX/MLONNXOps.td.inc"
#endif // MLONNX_OPS #endif // MLONNX_OPS

View File

@ -438,22 +438,22 @@ ONNXOpsDialect::ONNXOpsDialect(mlir::MLIRContext *ctx)
>(); >();
} }
void ONNXEntryPointOp::build(mlir::Builder *builder, void ONNXEntryPointOp::build(mlir::OpBuilder &builder,
mlir::OperationState &state, mlir::FuncOp function, int numInputs, mlir::OperationState &state, mlir::FuncOp function, int numInputs,
int numOutputs) { int numOutputs) {
state.addAttribute(ONNXEntryPointOp::getEntryPointFuncAttrName(), state.addAttribute(ONNXEntryPointOp::getEntryPointFuncAttrName(),
builder->getSymbolRefAttr(function)); builder.getSymbolRefAttr(function));
state.addAttribute(ONNXEntryPointOp::getNumInputsAttrName(), state.addAttribute(ONNXEntryPointOp::getNumInputsAttrName(),
builder->getI32IntegerAttr(numInputs)); builder.getI32IntegerAttr(numInputs));
state.addAttribute(ONNXEntryPointOp::getNumOutputsAttrName(), state.addAttribute(ONNXEntryPointOp::getNumOutputsAttrName(),
builder->getI32IntegerAttr(numOutputs)); builder.getI32IntegerAttr(numOutputs));
} }
ONNXEntryPointOp ONNXEntryPointOp::create(mlir::Location location, ONNXEntryPointOp ONNXEntryPointOp::create(mlir::Location location,
mlir::FuncOp &func, int numInputs, int numOutputs) { mlir::FuncOp &func, int numInputs, int numOutputs) {
mlir::OperationState state(location, "onnx.EntryPoint"); mlir::OperationState state(location, "onnx.EntryPoint");
Builder builder(location->getContext()); OpBuilder builder(location->getContext());
mlir::ONNXEntryPointOp::build(&builder, state, func, numInputs, numOutputs); mlir::ONNXEntryPointOp::build(builder, state, func, numInputs, numOutputs);
Operation *op = mlir::Operation::create(state); Operation *op = mlir::Operation::create(state);
auto onnxEntryOp = llvm::cast<mlir::ONNXEntryPointOp>(op); auto onnxEntryOp = llvm::cast<mlir::ONNXEntryPointOp>(op);
return onnxEntryOp; return onnxEntryOp;
@ -1573,7 +1573,7 @@ bool ONNXPadConstantValuePadOp::inferShapes() {
return false; return false;
} }
void ONNXPadConstantValuePadOp::build(Builder *builder, OperationState &state, void ONNXPadConstantValuePadOp::build(OpBuilder &builder, OperationState &state,
Value data, ArrayAttr pads, FloatAttr constant_value, StringAttr mode) { Value data, ArrayAttr pads, FloatAttr constant_value, StringAttr mode) {
Type outputType = padShapeInferenceHelper(data, pads); Type outputType = padShapeInferenceHelper(data, pads);
if (!outputType) { if (!outputType) {

View File

@ -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 "mlir/Interfaces/SideEffects.td" include "mlir/Interfaces/SideEffectInterfaces.td"
include "src/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.
@ -71,7 +71,7 @@ def ONNXEntryPointOp: ONNX_Op<"EntryPoint"> {
The "onnx.EntryPoint" function indicates the main entry point of ONNX model. The "onnx.EntryPoint" function indicates the main entry point of ONNX model.
}]; }];
let builders = [OpBuilder<[{Builder *builder, OperationState &state, let builders = [OpBuilder<[{OpBuilder &builder, OperationState &state,
FuncOp function, int numInputs, int numOutputs}]>]; FuncOp function, int numInputs, int numOutputs}]>];
let extraClassDeclaration = [{ let extraClassDeclaration = [{
@ -183,7 +183,7 @@ def ONNXPadConstantValuePadOp : ONNX_Op<"PadConstantValuePad",
DefaultValuedAttr<StrAttr, "constant">:$mode); DefaultValuedAttr<StrAttr, "constant">:$mode);
let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$output); let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$output);
// A build method with the result type deduction. // A build method with the result type deduction.
let builders = [OpBuilder<"Builder *builder, OperationState &state, " let builders = [OpBuilder<"OpBuilder &builder, OperationState &state, "
"Value data, ArrayAttr pads, " "Value data, ArrayAttr pads, "
"FloatAttr constant_value, StringAttr mode">]; "FloatAttr constant_value, StringAttr mode">];
} }

View File

@ -15,11 +15,11 @@ def ONNXAbsOp:ONNX_Op<"Abs",
let arguments = (ins AnyTypeOf<[AnyMemRef, AnyTensor]>:$X); let arguments = (ins AnyTypeOf<[AnyMemRef, AnyTensor]>:$X);
let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$Y); let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$Y);
let builders = [ let builders = [
OpBuilder<"Builder *builder, OperationState &state, Value X", [{ OpBuilder<"OpBuilder &builder, OperationState &state, Value X", [{
auto elementType = X.getType().cast<TensorType>().getElementType(); auto elementType = X.getType().cast<TensorType>().getElementType();
build(builder, state, UnrankedTensorType::get(elementType), X); build(builder, state, UnrankedTensorType::get(elementType), X);
}]>, }]>,
OpBuilder<"Builder *builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{ OpBuilder<"OpBuilder &builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{
auto elementType = operands[0].getType().cast<TensorType>().getElementType(); auto elementType = operands[0].getType().cast<TensorType>().getElementType();
std::vector<mlir::Type> outputTypes; std::vector<mlir::Type> outputTypes;
outputTypes.emplace_back(UnrankedTensorType::get(elementType)); outputTypes.emplace_back(UnrankedTensorType::get(elementType));
@ -349,7 +349,7 @@ def ONNXConstantOp:ONNX_Op<"Constant",
OptionalAttr<AnyAttr>:$value); OptionalAttr<AnyAttr>:$value);
let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$output); let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$output);
let builders = [ let builders = [
OpBuilder<"Builder *builder, OperationState &state, Attribute sparse_value, Attribute value", [{ OpBuilder<"OpBuilder &builder, OperationState &state, Attribute sparse_value, Attribute value", [{
if (value) { if (value) {
auto tensorType = value.getType(); auto tensorType = value.getType();
build(builder, state, tensorType, sparse_value, value); build(builder, state, tensorType, sparse_value, value);
@ -673,11 +673,11 @@ def ONNXExpOp:ONNX_Op<"Exp",
let arguments = (ins AnyTypeOf<[AnyMemRef, AnyTensor]>:$input); let arguments = (ins AnyTypeOf<[AnyMemRef, AnyTensor]>:$input);
let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$output); let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$output);
let builders = [ let builders = [
OpBuilder<"Builder *builder, OperationState &state, Value input", [{ OpBuilder<"OpBuilder &builder, OperationState &state, Value input", [{
auto elementType = input.getType().cast<TensorType>().getElementType(); auto elementType = input.getType().cast<TensorType>().getElementType();
build(builder, state, UnrankedTensorType::get(elementType), input); build(builder, state, UnrankedTensorType::get(elementType), input);
}]>, }]>,
OpBuilder<"Builder *builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{ OpBuilder<"OpBuilder &builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{
auto elementType = operands[0].getType().cast<TensorType>().getElementType(); auto elementType = operands[0].getType().cast<TensorType>().getElementType();
std::vector<mlir::Type> outputTypes; std::vector<mlir::Type> outputTypes;
outputTypes.emplace_back(UnrankedTensorType::get(elementType)); outputTypes.emplace_back(UnrankedTensorType::get(elementType));
@ -1780,11 +1780,11 @@ def ONNXMulOp:ONNX_Op<"Mul",
AnyTypeOf<[AnyMemRef, AnyTensor]>:$B); AnyTypeOf<[AnyMemRef, AnyTensor]>:$B);
let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$C); let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$C);
let builders = [ let builders = [
OpBuilder<"Builder *builder, OperationState &state, Value A, Value B", [{ OpBuilder<"OpBuilder &builder, OperationState &state, Value A, Value B", [{
auto elementType = A.getType().cast<TensorType>().getElementType(); auto elementType = A.getType().cast<TensorType>().getElementType();
build(builder, state, UnrankedTensorType::get(elementType), A, B); build(builder, state, UnrankedTensorType::get(elementType), A, B);
}]>, }]>,
OpBuilder<"Builder *builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{ OpBuilder<"OpBuilder &builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{
auto elementType = operands[0].getType().cast<TensorType>().getElementType(); auto elementType = operands[0].getType().cast<TensorType>().getElementType();
std::vector<mlir::Type> outputTypes; std::vector<mlir::Type> outputTypes;
outputTypes.emplace_back(UnrankedTensorType::get(elementType)); outputTypes.emplace_back(UnrankedTensorType::get(elementType));
@ -2014,11 +2014,11 @@ def ONNXPadOp:ONNX_Op<"Pad",
DefaultValuedAttr<StrAttr, "constant">:$mode); DefaultValuedAttr<StrAttr, "constant">:$mode);
let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$output); let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$output);
let builders = [ let builders = [
OpBuilder<"Builder *builder, OperationState &state, Value data, Value pads, Value constant_value, StringAttr mode", [{ OpBuilder<"OpBuilder &builder, OperationState &state, Value data, Value pads, Value constant_value, StringAttr mode", [{
auto elementType = data.getType().cast<TensorType>().getElementType(); auto elementType = data.getType().cast<TensorType>().getElementType();
build(builder, state, UnrankedTensorType::get(elementType), data, pads, constant_value, mode); build(builder, state, UnrankedTensorType::get(elementType), data, pads, constant_value, mode);
}]>, }]>,
OpBuilder<"Builder *builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{ OpBuilder<"OpBuilder &builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{
auto elementType = operands[0].getType().cast<TensorType>().getElementType(); auto elementType = operands[0].getType().cast<TensorType>().getElementType();
std::vector<mlir::Type> outputTypes; std::vector<mlir::Type> outputTypes;
outputTypes.emplace_back(UnrankedTensorType::get(elementType)); outputTypes.emplace_back(UnrankedTensorType::get(elementType));
@ -2473,11 +2473,11 @@ def ONNXReduceSumOp:ONNX_Op<"ReduceSum",
DefaultValuedAttr<I64Attr, "1">:$keepdims); DefaultValuedAttr<I64Attr, "1">:$keepdims);
let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$reduced); let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$reduced);
let builders = [ let builders = [
OpBuilder<"Builder *builder, OperationState &state, Value data, ArrayAttr axes, IntegerAttr keepdims", [{ OpBuilder<"OpBuilder &builder, OperationState &state, Value data, ArrayAttr axes, IntegerAttr keepdims", [{
auto elementType = data.getType().cast<TensorType>().getElementType(); auto elementType = data.getType().cast<TensorType>().getElementType();
build(builder, state, UnrankedTensorType::get(elementType), data, axes, keepdims); build(builder, state, UnrankedTensorType::get(elementType), data, axes, keepdims);
}]>, }]>,
OpBuilder<"Builder *builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{ OpBuilder<"OpBuilder &builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{
auto elementType = operands[0].getType().cast<TensorType>().getElementType(); auto elementType = operands[0].getType().cast<TensorType>().getElementType();
std::vector<mlir::Type> outputTypes; std::vector<mlir::Type> outputTypes;
outputTypes.emplace_back(UnrankedTensorType::get(elementType)); outputTypes.emplace_back(UnrankedTensorType::get(elementType));
@ -2502,11 +2502,11 @@ def ONNXReduceSumSquareOp:ONNX_Op<"ReduceSumSquare",
DefaultValuedAttr<I64Attr, "1">:$keepdims); DefaultValuedAttr<I64Attr, "1">:$keepdims);
let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$reduced); let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$reduced);
let builders = [ let builders = [
OpBuilder<"Builder *builder, OperationState &state, Value data, ArrayAttr axes, IntegerAttr keepdims", [{ OpBuilder<"OpBuilder &builder, OperationState &state, Value data, ArrayAttr axes, IntegerAttr keepdims", [{
auto elementType = data.getType().cast<TensorType>().getElementType(); auto elementType = data.getType().cast<TensorType>().getElementType();
build(builder, state, UnrankedTensorType::get(elementType), data, axes, keepdims); build(builder, state, UnrankedTensorType::get(elementType), data, axes, keepdims);
}]>, }]>,
OpBuilder<"Builder *builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{ OpBuilder<"OpBuilder &builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{
auto elementType = operands[0].getType().cast<TensorType>().getElementType(); auto elementType = operands[0].getType().cast<TensorType>().getElementType();
std::vector<mlir::Type> outputTypes; std::vector<mlir::Type> outputTypes;
outputTypes.emplace_back(UnrankedTensorType::get(elementType)); outputTypes.emplace_back(UnrankedTensorType::get(elementType));

View File

@ -79,7 +79,7 @@ void compileModuleToSharedLibrary(
void registerDialects() { void registerDialects() {
mlir::registerDialect<mlir::AffineDialect>(); mlir::registerDialect<mlir::AffineDialect>();
mlir::registerDialect<mlir::LLVM::LLVMDialect>(); mlir::registerDialect<mlir::LLVM::LLVMDialect>();
mlir::registerDialect<mlir::loop::LoopOpsDialect>(); mlir::registerDialect<mlir::scf::SCFDialect>();
mlir::registerDialect<mlir::StandardOpsDialect>(); mlir::registerDialect<mlir::StandardOpsDialect>();
mlir::registerDialect<mlir::ONNXOpsDialect>(); mlir::registerDialect<mlir::ONNXOpsDialect>();
mlir::registerDialect<mlir::KrnlOpsDialect>(); mlir::registerDialect<mlir::KrnlOpsDialect>();

View File

@ -25,7 +25,7 @@
#include "src/Dialect/ONNX/ONNXOps.hpp" #include "src/Dialect/ONNX/ONNXOps.hpp"
#include "src/Pass/Passes.hpp" #include "src/Pass/Passes.hpp"
#include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" #include "mlir/Conversion/SCFToStandard/SCFToStandard.h"
#include "mlir/ExecutionEngine/ExecutionEngine.h" #include "mlir/ExecutionEngine/ExecutionEngine.h"
#include "mlir/ExecutionEngine/OptUtils.h" #include "mlir/ExecutionEngine/OptUtils.h"
#include "mlir/IR/MLIRContext.h" #include "mlir/IR/MLIRContext.h"
@ -70,4 +70,4 @@ void outputCode(
void emitOutputFiles(std::string outputBaseName, void emitOutputFiles(std::string outputBaseName,
EmissionTargetType emissionTarget, mlir::MLIRContext &context, EmissionTargetType emissionTarget, mlir::MLIRContext &context,
mlir::OwningModuleRef &module); mlir::OwningModuleRef &module);

View File

@ -57,7 +57,7 @@ static llvm::cl::opt<bool> allowUnregisteredDialects(
int main(int argc, char **argv) { int main(int argc, char **argv) {
mlir::registerDialect<mlir::AffineDialect>(); mlir::registerDialect<mlir::AffineDialect>();
mlir::registerDialect<mlir::LLVM::LLVMDialect>(); mlir::registerDialect<mlir::LLVM::LLVMDialect>();
mlir::registerDialect<mlir::loop::LoopOpsDialect>(); mlir::registerDialect<mlir::scf::SCFDialect>();
mlir::registerDialect<mlir::StandardOpsDialect>(); mlir::registerDialect<mlir::StandardOpsDialect>();
// Register transformation passes. // Register transformation passes.

View File

@ -9,12 +9,12 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "mlir/Conversion/AffineToStandard/AffineToStandard.h" #include "mlir/Conversion/AffineToStandard/AffineToStandard.h"
#include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" #include "mlir/Conversion/SCFToStandard/SCFToStandard.h"
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/SCF/SCF.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/Pass/Pass.h" #include "mlir/Pass/Pass.h"
#include "mlir/Target/LLVMIR/ModuleTranslation.h" #include "mlir/Target/LLVMIR/ModuleTranslation.h"

View File

@ -1,3 +1,3 @@
git clone https://github.com/llvm/llvm-project.git git clone https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX MLIR. # Check out a specific branch that is known to work with ONNX MLIR.
cd llvm-project && git checkout 3ce0ad1b336e67a76d78ae7ff7d66fe127586620 && cd .. cd llvm-project && git checkout 0dc91bfd11e6cced0c46c1a25cc96edea0d8fc22 && cd ..

View File

@ -94,7 +94,7 @@ custom_builder_ops_list = ['Abs', 'Mul', 'Exp', 'ReduceSum', 'ReduceSumSquare',
#a dictionary to add any special definition for an operation #a dictionary to add any special definition for an operation
custom_definition_misc = dict([ ('Constant', custom_definition_misc = dict([ ('Constant',
''' let builders = [ ''' let builders = [
OpBuilder<"Builder *builder, OperationState &state, Attribute sparse_value, Attribute value", [{ OpBuilder<"OpBuilder &builder, OperationState &state, Attribute sparse_value, Attribute value", [{
if (value) { if (value) {
auto tensorType = value.getType(); auto tensorType = value.getType();
build(builder, state, tensorType, sparse_value, value); build(builder, state, tensorType, sparse_value, value);
@ -430,9 +430,9 @@ def gen_op_def(schema):
else: else:
s += indent + 'let builders = [\n' s += indent + 'let builders = [\n'
# Custom builders with operands and attributes having a seperate parameter. # Custom builders with operands and attributes having a seperate parameter.
# E.g. OpBuilder<"Builder *builder, OperationState &state, Value X, Value, Y, Attribute A", [{}]> # E.g. OpBuilder<"OpBuilder &builder, OperationState &state, Value X, Value, Y, Attribute A", [{}]>
indent = inc_indent(indent) indent = inc_indent(indent)
s += indent + 'OpBuilder<"Builder *builder, OperationState &state' s += indent + 'OpBuilder<"OpBuilder &builder, OperationState &state'
operands_dict = get_operands_or_results(schema, is_input=True) operands_dict = get_operands_or_results(schema, is_input=True)
for name, ty in operands_dict.items(): for name, ty in operands_dict.items():
s += ', {} {}'.format(tblgen_operand_type_to_cpp_type(ty), s += ', {} {}'.format(tblgen_operand_type_to_cpp_type(ty),
@ -454,8 +454,8 @@ def gen_op_def(schema):
s += indent + '}]>,\n' s += indent + '}]>,\n'
# Custom builders with all operands and attributes having aggregate parameters. # Custom builders with all operands and attributes having aggregate parameters.
# E.g. OpBuilder<"Builder *builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{}]>' # E.g. OpBuilder<"OpBuilder &builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{}]>'
s += indent + 'OpBuilder<"Builder *builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{\n' s += indent + 'OpBuilder<"OpBuilder &builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{\n'
indent = inc_indent(indent) indent = inc_indent(indent)
s += indent + 'auto elementType = operands[0].getType().cast<TensorType>().getElementType();\n' s += indent + 'auto elementType = operands[0].getType().cast<TensorType>().getElementType();\n'
s += indent + 'std::vector<mlir::Type> outputTypes;\n' s += indent + 'std::vector<mlir::Type> outputTypes;\n'