From b1a99f27c796c19544d78d5b712065815aaf2322 Mon Sep 17 00:00:00 2001 From: Alexandre Eichenberger Date: Wed, 16 Nov 2022 17:27:46 -0500 Subject: [PATCH] fixes for mac (#1863) Template keyword for Mac clang compiler. Signed-off-by: Alexandre Eichenberger --- .../ONNXToKrnl/ONNXToKrnlCommon.hpp | 2 +- src/Dialect/Krnl/DialectBuilder.cpp | 8 +++++-- src/Dialect/Krnl/DialectBuilder.hpp | 4 ++-- src/Dialect/Mlir/DialectBuilder.hpp | 14 ++++++------- src/Dialect/Mlir/DialectBuilder.hpp.inc | 21 ++++++++++++------- src/Dialect/Mlir/IndexExprBuilder.hpp | 2 +- src/Dialect/ONNX/DialectBuilder.hpp | 4 ++-- test/modellib/ModelLib.hpp | 6 +++--- 8 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/Conversion/ONNXToKrnl/ONNXToKrnlCommon.hpp b/src/Conversion/ONNXToKrnl/ONNXToKrnlCommon.hpp index a273fdcc81..606e2929d8 100644 --- a/src/Conversion/ONNXToKrnl/ONNXToKrnlCommon.hpp +++ b/src/Conversion/ONNXToKrnl/ONNXToKrnlCommon.hpp @@ -58,7 +58,7 @@ struct OnnxToKrnlBuilder : public OnnxBuilder { OnnxToKrnlBuilder(mlir::OpBuilder &b, mlir::Location loc) : OnnxBuilder(b, loc) {} OnnxToKrnlBuilder(DialectBuilder &db) : OnnxBuilder(db) {} - ~OnnxToKrnlBuilder() {} + virtual ~OnnxToKrnlBuilder() {} // Generate an 'onnx.reshape' operation on the 'input' tensor, the new shape // is provided by 'shapeDims'. diff --git a/src/Dialect/Krnl/DialectBuilder.cpp b/src/Dialect/Krnl/DialectBuilder.cpp index 4738ead122..afa2cec2ce 100644 --- a/src/Dialect/Krnl/DialectBuilder.cpp +++ b/src/Dialect/Krnl/DialectBuilder.cpp @@ -107,7 +107,9 @@ Value KrnlBuilder::vectorTypeCast(Value sourceMemref, int64_t vectorLen) const { } ValueRange KrnlBuilder::defineLoops(int64_t originalLoopNum) const { - return b().create(loc(), originalLoopNum).getResults(); + return b() + .template create(loc(), originalLoopNum) + .getResults(); } ValueRange KrnlBuilder::block(Value loop, int64_t blockSize) const { @@ -119,7 +121,9 @@ void KrnlBuilder::permute(ValueRange loops, ArrayRef map) const { } ValueRange KrnlBuilder::getInductionVarValue(ValueRange loops) const { - return b().create(loc(), loops).getResults(); + return b() + .template create(loc(), loops) + .getResults(); } void KrnlBuilder::iterate(ValueRange originalLoops, ValueRange optimizedLoops, diff --git a/src/Dialect/Krnl/DialectBuilder.hpp b/src/Dialect/Krnl/DialectBuilder.hpp index 241af62308..d184a071c1 100644 --- a/src/Dialect/Krnl/DialectBuilder.hpp +++ b/src/Dialect/Krnl/DialectBuilder.hpp @@ -27,7 +27,7 @@ struct KrnlBuilder : public DialectBuilder { KrnlBuilder(mlir::OpBuilder &b, mlir::Location loc) : DialectBuilder(b, loc) {} KrnlBuilder(const DialectBuilder &db) : DialectBuilder(db) {} - ~KrnlBuilder() {} + virtual ~KrnlBuilder() {} mlir::Value load(mlir::Value memref, mlir::ValueRange indices = {}) const; // When ranks of offsets), we must add +// the "template" keyword before the "create" function to indicate what is being +// templated. +// //===----------------------------------------------------------------------===// // Implementation of GenericAffineBuilder template mlir::Value GenericAffineBuilder::load( mlir::Value memref, mlir::ValueRange indices) const { - return b().create(loc(), memref, indices); + return b().template create(loc(), memref, indices); } template @@ -36,7 +41,7 @@ mlir::Value GenericAffineBuilder::loadIE(mlir::Value memref, template inline void GenericAffineBuilder::store( mlir::Value val, mlir::Value memref, mlir::ValueRange indices) const { - b().create(loc(), val, memref, indices); + b().template create(loc(), val, memref, indices); } template @@ -70,8 +75,8 @@ inline void GenericAffineBuilder::forIE(IndexExpr lb, lb.getAffineMapAndOperands(lbMap, lbOperands); ub.getAffineMapAndOperands(ubMap, ubOperands); // Create affine for. - b().create(loc(), lbOperands, lbMap, ubOperands, ubMap, - step, mlir::ValueRange{}, + b().template create(loc(), lbOperands, lbMap, ubOperands, + ubMap, step, mlir::ValueRange{}, [&](mlir::OpBuilder &b, mlir::Location loc, mlir::Value index, mlir::ValueRange args) { GenericAffineBuilder createAffine(b, loc); @@ -120,8 +125,8 @@ inline void GenericAffineBuilder::ifThenElse( scope.getNumDims(), scope.getNumSymbols(), affineCond, isEq); llvm::SmallVector dimAndSymbolList; scope.getDimAndSymbolList(dimAndSymbolList); - auto ifOp = - b().create(loc(), inset, dimAndSymbolList, true); + auto ifOp = b().template create( + loc(), inset, dimAndSymbolList, true); mlir::Block *thenBlock = ifOp.getThenBlock(); mlir::Block *elseBlock = ifOp.getElseBlock(); if (!allFalse) { @@ -140,7 +145,7 @@ inline void GenericAffineBuilder::ifThenElse( template inline void GenericAffineBuilder::yield() const { - b().create(loc()); + b().template create(loc()); } // Support for multiple forIE loops. diff --git a/src/Dialect/Mlir/IndexExprBuilder.hpp b/src/Dialect/Mlir/IndexExprBuilder.hpp index a56d9ad533..a8b0c7a949 100644 --- a/src/Dialect/Mlir/IndexExprBuilder.hpp +++ b/src/Dialect/Mlir/IndexExprBuilder.hpp @@ -65,7 +65,7 @@ struct IndexExprBuilder : DialectBuilder { IndexExprBuilder(mlir::OpBuilder &b, mlir::Location loc) : DialectBuilder(b, loc) {} IndexExprBuilder(const DialectBuilder &db) : DialectBuilder(db) {} - ~IndexExprBuilder() {} + virtual ~IndexExprBuilder() {} using IndexExprList = llvm::SmallVectorImpl; diff --git a/src/Dialect/ONNX/DialectBuilder.hpp b/src/Dialect/ONNX/DialectBuilder.hpp index e7f87a3c4c..a9d2a99e8d 100644 --- a/src/Dialect/ONNX/DialectBuilder.hpp +++ b/src/Dialect/ONNX/DialectBuilder.hpp @@ -30,7 +30,7 @@ struct OnnxBuilder : onnx_mlir::DialectBuilder { OnnxBuilder(mlir::OpBuilder &b, mlir::Location loc) : DialectBuilder(b, loc) {} OnnxBuilder(const DialectBuilder &db) : DialectBuilder(db) {} - ~OnnxBuilder(){}; + virtual ~OnnxBuilder(){}; // ONNXAddOp mlir::Value add(mlir::Value A, mlir::Value B) const; @@ -145,7 +145,7 @@ struct IndexExprBuilderForAnalysis : IndexExprBuilder { : IndexExprBuilder(b, loc) {} IndexExprBuilderForAnalysis(const DialectBuilder &db) : IndexExprBuilder(db) {} - ~IndexExprBuilderForAnalysis() {} + virtual ~IndexExprBuilderForAnalysis() {} protected: mlir::DenseElementsAttr getConst(mlir::Value value) final; diff --git a/test/modellib/ModelLib.hpp b/test/modellib/ModelLib.hpp index 6b34eafda0..af14cc65b3 100644 --- a/test/modellib/ModelLib.hpp +++ b/test/modellib/ModelLib.hpp @@ -393,7 +393,7 @@ class LSTMLibBuilder : public RNNModelLibBuilder { const bool isDynamicB, const bool isNoneH = false, const bool isNoneC = false, const bool isNoneP = false, const int layout = 0); - ~LSTMLibBuilder(); + virtual ~LSTMLibBuilder(); bool build() final; bool prepareInputs() final; bool prepareInputs(float dataRangeLB, float dataRangeUB); @@ -415,7 +415,7 @@ class GRULibBuilder : public RNNModelLibBuilder { GRULibBuilder(const std::string &modelName, const int direction, const int S, const int B, const int I, const int H, const int linearBeforeReset, const bool isDynamicS, const bool isDynamicB, const int layout = 0); - ~GRULibBuilder(); + virtual ~GRULibBuilder(); bool build() final; bool prepareInputs() final; bool prepareInputs(float dataRangeLB, float dataRangeUB); @@ -436,7 +436,7 @@ class RNNLibBuilder : public RNNModelLibBuilder { RNNLibBuilder(const std::string &modelName, const int direction, const int S, const int B, const int I, const int H, const bool isDynamicS, const bool isDynamicB, const int layout = 0); - ~RNNLibBuilder(); + virtual ~RNNLibBuilder(); bool build() final; bool prepareInputs() final; bool prepareInputs(float dataRangeLB, float dataRangeUB);