Skip to content

Commit 7243bf8

Browse files
committed
add function
Signed-off-by: chentong319 <[email protected]>
1 parent e20ce14 commit 7243bf8

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/Compiler/CompilerOptions.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ std::vector<std::string> onnxConstPropDisablePatterns; // common for both
4141
bool enableONNXHybridPass; // common for both
4242
std::vector<std::string> functionsToDecompose; // common for both
4343
std::string opsForCall; // common for both
44+
bool disableKrnlOpFusion; // common for both
4445
EmissionTargetType emissionTarget; // onnx-mlir only
4546
bool invokeOnnxVersionConverter; // onnx-mlir only
4647
bool preserveLocations; // onnx-mlir only
@@ -200,6 +201,12 @@ static llvm::cl::list<std::string, std::vector<std::string>>
200201
llvm::cl::location(functionsToDecompose),
201202
llvm::cl::cat(OnnxMlirCommonOptions));
202203

204+
static llvm::cl::opt<bool, true> disableKrnlOpFusionOpt("disable-krnl-op-fusion",
205+
llvm::cl::desc("disable op fusion in onnx-to-krnl pass (default=false)\n"
206+
"Set to 'true' if you want to disable fusion."),
207+
llvm::cl::location(disableKrnlOpFusion), llvm::cl::init(false),
208+
llvm::cl::cat(OnnxMlirCommonOptions));
209+
203210
static llvm::cl::opt<bool, true> disableRecomposeOptionOpt("disable-recompose",
204211
llvm::cl::desc("Disable recomposition of ONNX operations."),
205212
llvm::cl::location(disableRecomposeOption), llvm::cl::init(false),

src/Compiler/CompilerOptions.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ extern std::vector<std::string> onnxConstPropDisablePatterns; // common for both
8484
extern bool enableONNXHybridPass; // common for both
8585
extern std::vector<std::string> functionsToDecompose; // common for both
8686
extern std::string opsForCall; // common for both
87+
extern bool disableKrnlOpFusion; // common for both
8788
extern EmissionTargetType emissionTarget; // onnx-mlir only
8889
extern bool invokeOnnxVersionConverter; // onnx-mlir only
8990
extern bool preserveLocations; // onnx-mlir only

src/Conversion/ONNXToKrnl/Math/Elementwise.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "llvm/Support/Debug.h"
1919

20+
#include "src/Compiler/CompilerOptions.hpp"
2021
#include "src/Conversion/ONNXToKrnl/ONNXToKrnlCommon.hpp"
2122
#include "src/Dialect/Krnl/DialectBuilder.hpp"
2223
#include "src/Dialect/ONNX/ONNXOps/ShapeHelper.hpp"
@@ -1884,6 +1885,9 @@ bool OpFusionHelper::areInputsValidForFusion(
18841885
// A successor op (user) is fusible if it is the only user, it is in the
18851886
// fusible elementwise op list, and its inputs are valid for fusion.
18861887
void OpFusionHelper::findFusibleOps() {
1888+
// Direct return if fusion is disabled
1889+
if (disableKrnlOpFusion)
1890+
return;
18871891
Operation *defOp = rootOp;
18881892
while (defOp->hasOneUse()) {
18891893
// the possible ONNX Ops.

0 commit comments

Comments
 (0)