Skip to content

Commit

Permalink
use fopen/fclose for windows
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Eichenberger <[email protected]>
  • Loading branch information
AlexandreEichenberger committed Jul 17, 2023
1 parent 570116c commit cf73875
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/mnist_example/mnist-compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 6 additions & 4 deletions src/Runtime/PyOMCompileExecutionSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cf73875

Please sign in to comment.