From a7c39a4f12802c9760e2a4339cdf6a57b1c8ddec Mon Sep 17 00:00:00 2001 From: chentong319 Date: Wed, 2 Oct 2024 08:29:40 -0400 Subject: [PATCH] implement Signed-off-by: chentong319 --- src/Compiler/CompilerOptions.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Compiler/CompilerOptions.cpp b/src/Compiler/CompilerOptions.cpp index 139cbd1847..595a77d8ed 100644 --- a/src/Compiler/CompilerOptions.cpp +++ b/src/Compiler/CompilerOptions.cpp @@ -1246,6 +1246,13 @@ void initCompilerConfig() { addCompilerConfig(CCM_SHARED_LIB_DEPS, extraLibs); addCompilerConfig(CCM_SHARED_LIB_PATH_DEPS, extraLibPaths); } + + // Enable aggressive optimization for NNPA with -O3 + if (OptimizationLevel == OptLevel::O3 && + getTargetAccel().find("NNPA") != std::string::npos && + getLLVMOption().find("enable-unsafe-fp-math") == std::string::npos) { + setLLVMOption(getLLVMOption() + " --enable-unsafe-fp-math"); + } } } // namespace onnx_mlir