From cf73875a50a2334644f2199cceb5050491251179 Mon Sep 17 00:00:00 2001 From: Alexandre Eichenberger Date: Mon, 17 Jul 2023 10:26:03 -0400 Subject: [PATCH] use fopen/fclose for windows Signed-off-by: Alexandre Eichenberger --- docs/mnist_example/mnist-compile.py | 2 +- src/Runtime/PyOMCompileExecutionSession.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) 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;