Enable Build on Windows again and Update CI badge (#115)

* Use && instead of and for Windows

* Simulate fork on Windows by redirecting stderr

* Use exisiting onnx-mlir instead of cloning from master
This commit is contained in:
Chun-Wei Chen 2020-05-12 08:00:19 -07:00 committed by GitHub
parent da80e67bfe
commit 41b595fc1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 9 deletions

View File

@ -2,7 +2,7 @@
The Open Neural Network Exchange implementation in MLIR. The Open Neural Network Exchange implementation in MLIR.
[![CircleCI](https://circleci.com/gh/onnx/onnx-mlir/tree/master.svg?style=svg)](https://circleci.com/gh/onnx/onnx-mlir/tree/master) [![CircleCI](https://circleci.com/gh/onnx/onnx-mlir/tree/master.svg?style=svg)](https://circleci.com/gh/onnx/onnx-mlir/tree/master)
[![Build Status](https://dev.azure.com/onnx-pipelines/onnx/_apis/build/status/jacky82226.onnx-mlir?branchName=master)](https://dev.azure.com/onnx-pipelines/onnx/_build/latest?definitionId=8&branchName=master) [![Build Status](https://dev.azure.com/onnx-pipelines/onnx/_apis/build/status/MLIR-Windows-CI?branchName=master)](https://dev.azure.com/onnx-pipelines/onnx/_build/latest?definitionId=9&branchName=master)
## Prerequisites ## Prerequisites
@ -144,7 +144,7 @@ This project uses lit ([LLVM's Integrated Tester](http://llvm.org/docs/CommandGu
To build ONNX MLIR, use the following command: To build ONNX MLIR, use the following command:
[same-as-file]: <> (utils/install-onnx-mlir.cmd) [same-as-file]: <> ({"ref": "utils/install-onnx-mlir.cmd", "skip-doc": 2})
```shell ```shell
git clone --recursive https://github.com/onnx/onnx-mlir.git git clone --recursive https://github.com/onnx/onnx-mlir.git

View File

@ -143,7 +143,7 @@ This project uses lit ([LLVM's Integrated Tester](http://llvm.org/docs/CommandGu
To build ONNX MLIR, use the following command: To build ONNX MLIR, use the following command:
[same-as-file]: <> (utils/install-onnx-mlir.cmd) [same-as-file]: <> ({"ref": "utils/install-onnx-mlir.cmd", "skip-doc": 2})
```shell ```shell
git clone --recursive https://github.com/onnx/onnx-mlir.git git clone --recursive https://github.com/onnx/onnx-mlir.git

View File

@ -61,7 +61,7 @@ std::vector<int64_t> getDilations<ONNXMaxPoolSingleOutOp>(
bool isDefaultDilations = true; bool isDefaultDilations = true;
for (auto dilation : dilationsAttribute.getValue()) { for (auto dilation : dilationsAttribute.getValue()) {
int64_t dilationValue = dilation.cast<IntegerAttr>().getInt(); int64_t dilationValue = dilation.cast<IntegerAttr>().getInt();
if (dilationValue > 1 and isDefaultDilations) if (dilationValue > 1 && isDefaultDilations)
isDefaultDilations = false; isDefaultDilations = false;
dilations.emplace_back(dilationValue); dilations.emplace_back(dilationValue);
} }

View File

@ -11,7 +11,12 @@
#include "src/MainUtils.hpp" #include "src/MainUtils.hpp"
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h> #include <unistd.h>
#endif
using namespace std; using namespace std;
using namespace onnx_mlir; using namespace onnx_mlir;
@ -106,13 +111,23 @@ void outputCode(
mlir::OwningModuleRef &module, string filename, string extension) { mlir::OwningModuleRef &module, string filename, string extension) {
// Start a separate process to redirect the model output. I/O redirection // Start a separate process to redirect the model output. I/O redirection
// changes will not be visible to the parent process. // changes will not be visible to the parent process.
string tempFilename = filename + extension;
#ifdef _WIN32
// copy original stderr file number
int stderrOrigin = _dup(_fileno(stderr));
freopen(tempFilename.c_str(), "w", stderr);
module->dump();
fflush(stderr);
// set modified stderr as original stderr
_dup2(stderrOrigin, _fileno( stderr ));
#else
if (fork() == 0) { if (fork() == 0) {
string tempFilename = filename + extension;
freopen(tempFilename.c_str(), "w", stderr); freopen(tempFilename.c_str(), "w", stderr);
module->dump(); module->dump();
fclose(stderr); fclose(stderr);
exit(0); exit(0);
} }
#endif
} }
void emitOutputFiles(string outputBaseName, EmissionTargetType emissionTarget, void emitOutputFiles(string outputBaseName, EmissionTargetType emissionTarget,

View File

@ -1,5 +1,3 @@
git clone --recursive https://github.com/onnx/onnx-mlir.git
REM Export environment variables pointing to LLVM-Projects. REM Export environment variables pointing to LLVM-Projects.
set root_dir=%cd% set root_dir=%cd%
set CURSES_LIB_PATH=%root_dir%/PDCurses set CURSES_LIB_PATH=%root_dir%/PDCurses

View File

@ -7,6 +7,11 @@ call conda create --yes --quiet --name onnx-mlir -c conda-forge python=3.7 libpr
call activate.bat onnx-mlir call activate.bat onnx-mlir
call "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 call "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
REM Copy original repo directory to onnx-mlir
git submodule update --init --recursive
set onnx-mlir_dir=%cd%
cd ..
cp -r %onnx-mlir_dir% onnx-mlir
set root_dir=%cd% set root_dir=%cd%
REM Build PDcurses REM Build PDcurses
@ -18,8 +23,8 @@ call nmake -f wincon/Makefile.vc
REM Build LLVM REM Build LLVM
cd /d %root_dir% cd /d %root_dir%
call utils/install-mlir.cmd call onnx-mlir/utils/install-mlir.cmd
REM Build onnx-mlir REM Build onnx-mlir
cd /d %root_dir% cd /d %root_dir%
call utils/install-onnx-mlir.cmd call onnx-mlir/utils/install-onnx-mlir.cmd