Skip to content

Commit 68f25f2

Browse files
committed
Edited PR based on comments from Tung
Signed-off-by: Paramvir Sran <[email protected]>
1 parent 3c015f0 commit 68f25f2

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

src/Compiler/CompilerUtils.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,8 @@ std::string getTargetFilename(
333333
// Returns 0 on success, error code on failure.
334334
static int genLLVMBitcode(const mlir::OwningOpRef<ModuleOp> &module,
335335
std::string outputNameNoExt, std::string optimizedBitcodeNameWithExt) {
336-
auto llvmTiming =
337-
rootScope.nest("[onnx-mlir] Compiling to LLVM Optimized Bitcode");
338-
336+
auto llvmTiming = rootScope.nest(
337+
"[onnx-mlir] Compiling MLIR module to LLVM Optimized Bitcode");
339338
std::error_code error;
340339

341340
// Write bitcode to a file.
@@ -429,7 +428,6 @@ static int genModelObject(
429428
static int genJniObject(const mlir::OwningOpRef<ModuleOp> &module,
430429
std::string jniSharedLibPath, std::string jniObjPath) {
431430
auto jniTiming = rootScope.nest("[onnx-mlir] Compiling JNI Object File");
432-
433431
Command ar(/*exePath=*/getToolPath("ar", true));
434432
int rc = ar.appendStr("x")
435433
// old version of ar does not support --output so comment out
@@ -448,7 +446,6 @@ static int genJniObject(const mlir::OwningOpRef<ModuleOp> &module,
448446
static int genSharedLib(std::string sharedLibNameWithExt,
449447
std::vector<std::string> opts, std::vector<std::string> objs,
450448
std::vector<std::string> libs, std::vector<std::string> libDirs) {
451-
auto libraryTiming = rootScope.nest("[onnx-mlir] Linking Shared Library");
452449
#ifdef _WIN32
453450
std::vector<std::string> outputOpt = {"/Fe:" + sharedLibNameWithExt};
454451
// link has to be before libpath since they need to be passed through to the
@@ -499,7 +496,6 @@ static int genSharedLib(std::string sharedLibNameWithExt,
499496
static int genJniJar(const mlir::OwningOpRef<ModuleOp> &module,
500497
std::string modelSharedLibPath, std::string modelJniJarPath) {
501498
auto jniJarTiming = rootScope.nest("[onnx-mlir] Creating JNI Jar");
502-
503499
llvm::SmallString<8> libraryPath(getLibraryPath());
504500
llvm::sys::path::append(libraryPath, "javaruntime.jar");
505501
std::string javaRuntimeJarPath = llvm::StringRef(libraryPath).str();
@@ -522,7 +518,6 @@ static int genJniJar(const mlir::OwningOpRef<ModuleOp> &module,
522518
// Return 0 on success, error code on failure
523519
static int compileModuleToObject(const mlir::OwningOpRef<ModuleOp> &module,
524520
std::string outputNameWithoutExt, std::string &objectNameWithExt) {
525-
526521
std::string bitcodeNameWithExt = outputNameWithoutExt + ".bc";
527522
int rc = genLLVMBitcode(module, outputNameWithoutExt, bitcodeNameWithExt);
528523
if (rc != CompilerSuccess)
@@ -537,7 +532,6 @@ static int compileModuleToObject(const mlir::OwningOpRef<ModuleOp> &module,
537532
static int compileModuleToSharedLibrary(
538533
const mlir::OwningOpRef<ModuleOp> &module, std::string outputNameNoExt,
539534
std::string &libNameWithExt) {
540-
541535
std::string modelObjNameWithExt;
542536
int rc = compileModuleToObject(module, outputNameNoExt, modelObjNameWithExt);
543537
if (rc != CompilerSuccess)
@@ -584,8 +578,7 @@ static int compileModuleToJniJar(
584578
#define NOEXECSTACK \
585579
{}
586580
#else
587-
#define NOEXECSTACK \
588-
{ "-z", "noexecstack" }
581+
#define NOEXECSTACK {"-z", "noexecstack"}
589582
#endif
590583
std::string modelSharedLibPath = getTargetFilename(jniLibBase, EmitLib);
591584
rc = genSharedLib(modelSharedLibPath, NOEXECSTACK,

src/Dialect/ONNX/ElementsAttr/ElementsAttrBuilder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <algorithm>
2424
#include <numeric>
25+
2526
using namespace mlir;
2627

2728
namespace onnx_mlir {
@@ -216,8 +217,6 @@ ElementsAttr ElementsAttrBuilder::combine(ElementsAttr lhs, ElementsAttr rhs,
216217
WideNum *dst = dstNums.data();
217218
const WideNum *lhsSrc = lhsNums.get().data();
218219
const WideNum *rhsSrc = rhsNums.get().data();
219-
220-
221220
for (auto &idxoffs :
222221
StridesRange<2>(combinedShape, {xpLhsStrides, xpRhsStrides})) {
223222
dst[idxoffs.flattenedIndex] =
@@ -1074,8 +1073,8 @@ ElementsAttr ElementsAttrBuilder::nonZero(ElementsAttr elms) {
10741073
}
10751074

10761075
/*static*/
1077-
auto ElementsAttrBuilder::getElementsProperties(ElementsAttr elements)
1078-
-> ElementsProperties {
1076+
auto ElementsAttrBuilder::getElementsProperties(
1077+
ElementsAttr elements) -> ElementsProperties {
10791078
static Transformer nullTransformer = nullptr;
10801079
if (auto disposable = elements.dyn_cast<DisposableElementsAttr>()) {
10811080
ArrayRef<int64_t> strides = disposable.getStrides();

src/onnx-mlir.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ int main(int argc, char *argv[]) {
4444
}
4545
initCompilerConfig();
4646

47-
// timing manager reporting enabled via "--enable-timing" compiler flag
48-
// mlir::applyDefaultTimingManagerCLOptions(timingManager);
47+
// Timing manager reporting enabled via "--enable-timing" compiler flag
4948
timingManager.setEnabled(enableTiming);
5049
rootScope = timingManager.getRootScope();
51-
auto setupScope = rootScope.nest("[onnx-mlir] Preparing for Compilation");
50+
auto setupTiming = rootScope.nest("[onnx-mlir] Loading Dialects");
5251

5352
// Special handling of outputBaseName to derive output filename.
5453
// outputBaseName must specify a file, so ignore invalid values
@@ -74,8 +73,9 @@ int main(int argc, char *argv[]) {
7473
LLVM_DEBUG(llvm::dbgs() << "multithreading is disabled\n");
7574
}
7675
loadDialects(context);
77-
setupScope.stop();
78-
auto inputFileScope = rootScope.nest("[onnx-mlir] Processing of Input File");
76+
setupTiming.stop();
77+
auto inputFileTiming =
78+
rootScope.nest("[onnx-mlir] Importing Input Model to MLIR");
7979
mlir::OwningOpRef<mlir::ModuleOp> module;
8080
std::string errorMessage;
8181
int rc = processInputFile(inputFilename, context, module, &errorMessage);
@@ -84,6 +84,6 @@ int main(int argc, char *argv[]) {
8484
llvm::errs() << errorMessage << "\n";
8585
return 1;
8686
}
87-
inputFileScope.stop();
87+
inputFileTiming.stop();
8888
return compileModule(module, context, outputBaseName, emissionTarget);
8989
}

0 commit comments

Comments
 (0)