diff --git a/docs/mnist_example/mnist-compile.py b/docs/mnist_example/mnist-compile.py index 9290ff2a10..5c408b64e5 100755 --- a/docs/mnist_example/mnist-compile.py +++ b/docs/mnist_example/mnist-compile.py @@ -7,7 +7,7 @@ file = './mnist.onnx' compiler = OMCompileSession(file) # Generate the library file. Success when rc == 0 while set the opt as "-O3" -rc = compiler.compile("-O3 -o bibi") +rc = compiler.compile("-O3 -o mnist") # Get the output file name model = compiler.get_compiled_file_name() if rc: diff --git a/src/Runtime/PyOMCompileExecutionSession.cpp b/src/Runtime/PyOMCompileExecutionSession.cpp index a46df6bff1..86e0e34271 100644 --- a/src/Runtime/PyOMCompileExecutionSession.cpp +++ b/src/Runtime/PyOMCompileExecutionSession.cpp @@ -39,11 +39,13 @@ PyOMCompileExecutionSession::PyOMCompileExecutionSession( if (reuseCompiledModel) { // see if there is a model to reuse. outputName = omCompileOutputFileName(inputFileName.c_str(), flags.c_str()); - bool fileExists = access(outputName, F_OK) != -1; - if (!fileExists) { - fprintf(stderr, "file `%s' does not exists, compile.\n", outputName); + FILE *file = fopen(outputName, "r"); + if (file) + // File exists, we are ok. + fclose(file); + else + // File does not exist, cannot reuse compilation. reuseCompiledModel = false; - } } if (!reuseCompiledModel) { int64_t rc;