28 lines
706 B
C++
28 lines
706 B
C++
#include "llvm/Support/raw_os_ostream.h"
|
|
|
|
#include <fstream>
|
|
|
|
#include "src/Accelerators/PIM/Common/Support/DebugDump.hpp"
|
|
#include "src/Accelerators/PIM/Common/Support/FileSystemUtils.hpp"
|
|
|
|
namespace onnx_mlir {
|
|
|
|
void dumpModule(mlir::ModuleOp moduleOp, const std::string& name) {
|
|
std::string outputDir = getOutputDir();
|
|
if (outputDir.empty())
|
|
return;
|
|
|
|
std::string dialectsDir = outputDir + "/dialects";
|
|
createDirectory(dialectsDir);
|
|
|
|
std::fstream file(dialectsDir + "/" + name + ".mlir", std::ios::out);
|
|
llvm::raw_os_ostream os(file);
|
|
mlir::OpPrintingFlags flags;
|
|
flags.elideLargeElementsAttrs();
|
|
moduleOp.print(os, flags);
|
|
os.flush();
|
|
file.close();
|
|
}
|
|
|
|
} // namespace onnx_mlir
|