From 3769401d449732197a1c4cf13e5ed62463b55de5 Mon Sep 17 00:00:00 2001 From: Aleks Knezevic Date: Wed, 15 Jan 2025 00:01:01 +0000 Subject: [PATCH] Optionally disable debug strings in flatbuffer, greatly reduces compile time --- CMakeLists.txt | 5 +++++ include/ttmlir/Target/Utils/FuncOpToProgram.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 448f0e3937..e16ab3f192 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,11 @@ option(TTMLIR_ENABLE_RUNTIME "Enable runtime" OFF) option(TTMLIR_ENABLE_STABLEHLO "Enable StableHLO support" OFF) option(TTMLIR_ENABLE_OPMODEL "Enable OpModel support" OFF) option(TTMLIR_ENABLE_SHARED_LIB "Enable Shared lib building" ON) +option(TTMLIR_ENABLE_DEBUG_STRINGS "Enable debug strings in flatbuffer" ON) + +if (TTMLIR_ENABLE_DEBUG_STRINGS) + add_compile_definitions(TTMLIR_ENABLE_DEBUG_STRINGS) +endif() if (NOT TTMLIR_ENABLE_RUNTIME) set (TTMLIR_ENABLE_SHARED_LIB OFF) diff --git a/include/ttmlir/Target/Utils/FuncOpToProgram.h b/include/ttmlir/Target/Utils/FuncOpToProgram.h index a28f2f5e9a..8072ed0cad 100644 --- a/include/ttmlir/Target/Utils/FuncOpToProgram.h +++ b/include/ttmlir/Target/Utils/FuncOpToProgram.h @@ -25,10 +25,14 @@ struct Program { inline std::string getOpDebugString(mlir::Operation *op, OpPrintingFlags printFlags) { +#ifdef TTMLIR_ENABLE_DEBUG_STRINGS std::string str; llvm::raw_string_ostream os(str); op->print(os, printFlags); return str; +#else + return ""; +#endif }; inline std::string getOpLocInfo(mlir::Operation *op) {