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
# Use cached mlir installation if possible.
- restore_cache:
key: V11-LLVM-PROJECT-{{ arch }}
key: V13-LLVM-PROJECT-{{ arch }}
- run:
name: Install MLIR
command: |
@ -29,7 +29,7 @@ jobs:
source onnx-mlir/utils/install-mlir.sh
fi
- save_cache:
key: V11-LLVM-PROJECT-{{ arch }}
key: V13-LLVM-PROJECT-{{ arch }}
paths:
- llvm-project
- run:

View File

@ -144,16 +144,16 @@ find_mlir_lib(MLIRExecutionEngine)
find_mlir_lib(MLIRIR)
find_mlir_lib(MLIRLLVMIR)
find_mlir_lib(MLIRLoopAnalysis)
find_mlir_lib(MLIRLoopToStandard)
find_mlir_lib(MLIRLoopOps)
find_mlir_lib(MLIRSCFToStandard)
find_mlir_lib(MLIRLoopLikeInterface)
find_mlir_lib(MLIRSCF)
find_mlir_lib(MLIRLLVMIRTransforms)
find_mlir_lib(MLIRMlirOptMain)
find_mlir_lib(MLIRParser)
find_mlir_lib(MLIRPass)
find_mlir_lib(MLIRStandardOps)
find_mlir_lib(MLIRStandardToLLVM)
find_mlir_lib(MLIRSideEffects)
find_mlir_lib(MLIRSideEffectInterfaces)
find_mlir_lib(MLIRTargetLLVMIR)
find_mlir_lib(MLIRTransforms)
find_mlir_lib(MLIRTransformUtils)
@ -205,13 +205,13 @@ set(MLIRLibs
${MLIRExecutionEngine}
${MLIRIR}
${MLIRLLVMIRTransforms}
${MLIRLoopToStandard}
${MLIRLoopOps}
${MLIRSCFToStandard}
${MLIRSCF}
${MLIRLoopAnalysis}
${MLIRLoopLikeInterface}
${MLIROpenMP}
${MLIRMlirOptMain}
${MLIRSideEffects}
${MLIRSideEffectInterfaces}
${MLIRStandardOps}
${MLIRStandardToLLVM}
${MLIRSupport}
@ -251,9 +251,9 @@ set(MLIRWholeArchiveLibs
MLIRStandardOps
MLIRStandardToLLVM
MLIRTransforms
MLIRLoopToStandard
MLIRSCFToStandard
MLIRVector
MLIRLoopOps
MLIRSCF
MLIRIR)
# 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
git clone https://github.com/llvm/llvm-project.git
# 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)
@ -114,7 +114,7 @@ Install MLIR (as a part of LLVM-Project):
```shell
git clone https://github.com/llvm/llvm-project.git
# 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)

View File

@ -20,7 +20,7 @@ Firstly, install MLIR (as a part of LLVM-Project):
``` bash
git clone https://github.com/llvm/llvm-project.git
# 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)
@ -110,7 +110,7 @@ Install MLIR (as a part of LLVM-Project):
```shell
git clone https://github.com/llvm/llvm-project.git
# 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)

View File

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

View File

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

View File

@ -29,7 +29,7 @@ def KrnlDefineLoopsOp : Op<Krnl_Dialect, "define_loops"> {
let arguments = (ins);
let results = (outs Variadic<AnyType>);
let skipDefaultBuilders = 1;
let builders = [ OpBuilder<"Builder *builder, OperationState &result,"
let builders = [ OpBuilder<"OpBuilder &builder, OperationState &result,"
"int64_t num_loops"> ];
let printer = [{ return ::print(p, *this); }];
@ -67,7 +67,7 @@ def KrnlOptimizeLoopsOp : Op<Krnl_Dialect, "optimize_loops"> {
let skipDefaultBuilders = 1;
let builders = [ OpBuilder<"Builder *builder, OperationState &result, "
let builders = [ OpBuilder<"OpBuilder &builder, OperationState &result, "
"int timestamp_space_rank"> ];
let printer = [{ return ::print(p, *this); }];
@ -100,7 +100,7 @@ def KrnlIterateOp : Op<Krnl_Dialect, "iterate", [ImplicitKrnlTerminator]> {
let arguments = (ins Variadic<AnyType>);
let regions = (region SizedRegion<1>:$bodyRegion);
let skipDefaultBuilders = 1;
let builders = [ OpBuilder<"Builder *builder, OperationState &result, "
let builders = [ OpBuilder<"OpBuilder &builder, OperationState &result, "
"KrnlIterateOperandPack operandPack"> ];
let extraClassDeclaration = [{
@ -165,7 +165,7 @@ def KrnlEntryPointOp : Op<Krnl_Dialect, "entry_point"> {
let summary = "Indicate ONNX entry point";
let description = [{The "krnl.entry_point" function indicates the main entry
point of ONNX model.}];
let builders = [ OpBuilder<"Builder *builder, OperationState &result, "
let builders = [ OpBuilder<"OpBuilder &builder, OperationState &result, "
"SymbolRefAttr funcAttr, IntegerAttr numInputs, "
"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
// 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"
#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,
int numOutputs) {
state.addAttribute(ONNXEntryPointOp::getEntryPointFuncAttrName(),
builder->getSymbolRefAttr(function));
builder.getSymbolRefAttr(function));
state.addAttribute(ONNXEntryPointOp::getNumInputsAttrName(),
builder->getI32IntegerAttr(numInputs));
builder.getI32IntegerAttr(numInputs));
state.addAttribute(ONNXEntryPointOp::getNumOutputsAttrName(),
builder->getI32IntegerAttr(numOutputs));
builder.getI32IntegerAttr(numOutputs));
}
ONNXEntryPointOp ONNXEntryPointOp::create(mlir::Location location,
mlir::FuncOp &func, int numInputs, int numOutputs) {
mlir::OperationState state(location, "onnx.EntryPoint");
Builder builder(location->getContext());
mlir::ONNXEntryPointOp::build(&builder, state, func, numInputs, numOutputs);
OpBuilder builder(location->getContext());
mlir::ONNXEntryPointOp::build(builder, state, func, numInputs, numOutputs);
Operation *op = mlir::Operation::create(state);
auto onnxEntryOp = llvm::cast<mlir::ONNXEntryPointOp>(op);
return onnxEntryOp;
@ -1573,7 +1573,7 @@ bool ONNXPadConstantValuePadOp::inferShapes() {
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) {
Type outputType = padShapeInferenceHelper(data, pads);
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
// 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"
// 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.
}];
let builders = [OpBuilder<[{Builder *builder, OperationState &state,
let builders = [OpBuilder<[{OpBuilder &builder, OperationState &state,
FuncOp function, int numInputs, int numOutputs}]>];
let extraClassDeclaration = [{
@ -183,7 +183,7 @@ def ONNXPadConstantValuePadOp : ONNX_Op<"PadConstantValuePad",
DefaultValuedAttr<StrAttr, "constant">:$mode);
let results = (outs AnyTypeOf<[AnyMemRef, AnyTensor]>:$output);
// 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, "
"FloatAttr constant_value, StringAttr mode">];
}

View File

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

View File

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

View File

@ -25,7 +25,7 @@
#include "src/Dialect/ONNX/ONNXOps.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/OptUtils.h"
#include "mlir/IR/MLIRContext.h"

View File

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

View File

@ -9,12 +9,12 @@
//===----------------------------------------------------------------------===//
#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/ConvertStandardToLLVMPass.h"
#include "mlir/Dialect/Affine/IR/AffineOps.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/Pass/Pass.h"
#include "mlir/Target/LLVMIR/ModuleTranslation.h"

View File

@ -1,3 +1,3 @@
git clone https://github.com/llvm/llvm-project.git
# 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
custom_definition_misc = dict([ ('Constant',
''' let builders = [
OpBuilder<"Builder *builder, OperationState &state, Attribute sparse_value, Attribute value", [{
OpBuilder<"OpBuilder &builder, OperationState &state, Attribute sparse_value, Attribute value", [{
if (value) {
auto tensorType = value.getType();
build(builder, state, tensorType, sparse_value, value);
@ -430,9 +430,9 @@ def gen_op_def(schema):
else:
s += indent + 'let builders = [\n'
# 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)
s += indent + 'OpBuilder<"Builder *builder, OperationState &state'
s += indent + 'OpBuilder<"OpBuilder &builder, OperationState &state'
operands_dict = get_operands_or_results(schema, is_input=True)
for name, ty in operands_dict.items():
s += ', {} {}'.format(tblgen_operand_type_to_cpp_type(ty),
@ -454,8 +454,8 @@ def gen_op_def(schema):
s += indent + '}]>,\n'
# Custom builders with all operands and attributes having aggregate parameters.
# E.g. OpBuilder<"Builder *builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{}]>'
s += indent + 'OpBuilder<"Builder *builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{\n'
# E.g. OpBuilder<"OpBuilder &builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{}]>'
s += indent + 'OpBuilder<"OpBuilder &builder, OperationState &state, ValueRange operands, ArrayRef<NamedAttribute> attributes", [{\n'
indent = inc_indent(indent)
s += indent + 'auto elementType = operands[0].getType().cast<TensorType>().getElementType();\n'
s += indent + 'std::vector<mlir::Type> outputTypes;\n'