52
52
using namespace mlir ;
53
53
using namespace onnx_mlir ;
54
54
55
- extern mlir::DefaultTimingManager timingManager;
55
+ mlir::DefaultTimingManager timingManager;
56
+ mlir::TimingScope rootScope;
56
57
57
58
namespace onnx_mlir {
58
59
@@ -151,7 +152,8 @@ int Command::exec(std::string wdir) const {
151
152
llvm::errs () << llvm::join (argsRef, " " ) << " \n "
152
153
<< " Error message: " << errMsg << " \n "
153
154
<< " Program path: " << _path << " \n "
154
- << " Command execution failed." << " \n " ;
155
+ << " Command execution failed."
156
+ << " \n " ;
155
157
return rc;
156
158
}
157
159
@@ -331,7 +333,6 @@ std::string getTargetFilename(
331
333
// Returns 0 on success, error code on failure.
332
334
static int genLLVMBitcode (const mlir::OwningOpRef<ModuleOp> &module,
333
335
std::string outputNameNoExt, std::string optimizedBitcodeNameWithExt) {
334
- auto rootScope = timingManager.getRootScope ();
335
336
auto llvmScope =
336
337
rootScope.nest (" [onnx-mlir] Compiling to LLVM Optimized Bitcode" );
337
338
@@ -405,7 +406,6 @@ static int genLLVMBitcode(const mlir::OwningOpRef<ModuleOp> &module,
405
406
// Return 0 on success, error code on failure.
406
407
static int genModelObject (
407
408
std::string bitcodeNameWithExt, std::string &modelObjNameWithExt) {
408
- auto rootScope = timingManager.getRootScope ();
409
409
auto objectScope =
410
410
rootScope.nest (" [onnx-mlir] Compiling LLVM Bitcode to Object File" );
411
411
std::string llcPath = getToolPath (" llc" );
@@ -428,7 +428,6 @@ static int genModelObject(
428
428
// Return 0 on success, error code on failure.
429
429
static int genJniObject (const mlir::OwningOpRef<ModuleOp> &module,
430
430
std::string jniSharedLibPath, std::string jniObjPath) {
431
- auto rootScope = timingManager.getRootScope ();
432
431
auto jniScope = rootScope.nest (" [onnx-mlir] Compiling JNI Object File" );
433
432
434
433
Command ar (/* exePath=*/ getToolPath (" ar" , true ));
@@ -449,7 +448,6 @@ static int genJniObject(const mlir::OwningOpRef<ModuleOp> &module,
449
448
static int genSharedLib (std::string sharedLibNameWithExt,
450
449
std::vector<std::string> opts, std::vector<std::string> objs,
451
450
std::vector<std::string> libs, std::vector<std::string> libDirs) {
452
- auto rootScope = timingManager.getRootScope ();
453
451
auto libraryScope = rootScope.nest (" [onnx-mlir] Linking Shared Library" );
454
452
#ifdef _WIN32
455
453
std::vector<std::string> outputOpt = {" /Fe:" + sharedLibNameWithExt};
@@ -500,7 +498,6 @@ static int genSharedLib(std::string sharedLibNameWithExt,
500
498
// Return 0 on success, error code on failure.
501
499
static int genJniJar (const mlir::OwningOpRef<ModuleOp> &module,
502
500
std::string modelSharedLibPath, std::string modelJniJarPath) {
503
- auto rootScope = timingManager.getRootScope ();
504
501
auto jniJarScope = rootScope.nest (" [onnx-mlir] Creating JNI Jar" );
505
502
506
503
llvm::SmallString<8 > libraryPath (getLibraryPath ());
@@ -898,8 +895,8 @@ static int emitOutput(mlir::OwningOpRef<ModuleOp> &module,
898
895
int compileModule (mlir::OwningOpRef<ModuleOp> &module,
899
896
mlir::MLIRContext &context, std::string outputNameNoExt,
900
897
EmissionTargetType emissionTarget) {
901
- auto rootScope = timingManager. getRootScope ();
902
- auto compileModuleScope = rootScope.nest (" [onnx-mlir] Compile Module Setup " );
898
+ auto compileModuleScope =
899
+ rootScope.nest (" [onnx-mlir] Compiling Module using MLIR " );
903
900
904
901
int rc = setupModule (module, context, outputNameNoExt);
905
902
if (rc != CompilerSuccess)
@@ -928,12 +925,12 @@ int compileModule(mlir::OwningOpRef<ModuleOp> &module,
928
925
(void )mlir::applyPassManagerCLOptions (pm);
929
926
930
927
if (enableTiming) {
931
- pm.enableTiming (rootScope );
928
+ pm.enableTiming (compileModuleScope );
932
929
}
933
- compileModuleScope.stop ();
934
930
935
931
if (mlir::failed (pm.run (*module)))
936
932
return CompilerFailure;
933
+ compileModuleScope.stop ();
937
934
return emitOutput (module, context, outputNameNoExt, pm, emissionTarget);
938
935
}
939
936
0 commit comments