Skip to content

Commit ddc0cfe

Browse files
committed
DRAFT use onnx2circle for one-import-onnx
on-going draft to use onnx2circle for one-import-onnx and deprecate onnx-tf. Signed-off-by: SaeHie Park <saehie.park@gmail.com>
1 parent 353d0b4 commit ddc0cfe

5 files changed

Lines changed: 92 additions & 5 deletions

File tree

circle-mlir/Makefile.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ CIRCLEMLIR_EXTS_REL?=build/externals/release
2424
CIRCLEMLIR_PY3_ROOT?=$(PYTHON3_PATH)
2525
CIRCLEMLIR_BUILD_JOBS?=4
2626

27-
ONE_COMPILER_INSTALL?=$(CURDIR)/../build/install
27+
ONE_COMPILER_INSTALL?=build/install
2828

2929
.PHONY: help all overlay \
3030
prep cfg debug test clean \
@@ -44,7 +44,7 @@ help:
4444
@echo "make cfgr : configure circle-mlir for release build"
4545
@echo "make rel : build for release"
4646
@echo "make testr : test for release"
47-
@echo "make install : install release build to (ONE)/build/install"
47+
@echo "make install : install release build"
4848
@echo "make cleanr : clean release build"
4949
@echo "make prepcov : prepare submodules for coverage test (needed only once)"
5050
@echo "make cfgcov : configure circle-mlir for debug build with coverage test"

circle-mlir/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,10 @@ Test build
9999
make testr
100100
```
101101

102-
Install tools into `(ONE)/build/install`
102+
Install tools into `build/install`
103103
```
104104
make install
105105
```
106-
- `onnx2circle` is going to be the default converter of `one-import-onnx` tool
107-
- this will install `onnx2circle` to `build/install` of compiler
108106

109107
### Docker build
110108

compiler/one-cmds/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,26 @@ foreach(ONE_COMMAND IN ITEMS ${ONE_COMMAND_FILES})
9191

9292
endforeach(ONE_COMMAND)
9393

94+
# if ONE_ONNX2CIRCLE_PATH is set, install that file to bin folder
95+
if(DEFINED ENV{ONE_ONNX2CIRCLE_PATH})
96+
message(STATUS "ONNX2CIRCLE from env-var $ENV{ONE_ONNX2CIRCLE_PATH}")
97+
install(FILES $ENV{ONE_ONNX2CIRCLE_PATH}
98+
PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
99+
GROUP_READ GROUP_EXECUTE
100+
WORLD_READ WORLD_EXECUTE
101+
DESTINATION bin)
102+
else()
103+
set(ONNX2CIRCLE_PATH "${NNAS_PROJECT_SOURCE_DIR}/circle-mlir/build/install/bin/onnx2circle")
104+
if (EXISTS ${ONNX2CIRCLE_PATH})
105+
message(STATUS "ONNX2CIRCLE from ${ONNX2CIRCLE_PATH}")
106+
install(FILES ${ONNX2CIRCLE_PATH}
107+
PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
108+
GROUP_READ GROUP_EXECUTE
109+
WORLD_READ WORLD_EXECUTE
110+
DESTINATION bin)
111+
endif()
112+
endif()
113+
94114
set(ONE_UTILITY_FILES
95115
one-build.template.cfg
96116
onecc.template.cfg

compiler/one-cmds/one-import-onnx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,23 @@ def _check_ext():
288288
return None
289289

290290

291+
def _check_onnx2circle():
292+
# check if onnx2circle exist
293+
dir_path = os.path.dirname(os.path.realpath(__file__))
294+
o2c_path = os.path.join(dir_path, 'onnx2circle')
295+
if not os.path.isfile(o2c_path):
296+
o2c_path = '/usr/share/circletools/bin/onnx2circle'
297+
if not os.path.isfile(o2c_path):
298+
print("one-import-onnx: onnx2circle converter not found")
299+
sys.exit(1)
300+
return o2c_path
301+
302+
291303
def _convert(args):
292304
_apply_verbosity(args.verbose)
293305

306+
onnx2cicle_path = _check_onnx2circle()
307+
294308
# get file path to log
295309
dir_path = os.path.dirname(os.path.realpath(__file__))
296310
logfile_path = os.path.realpath(args.output_path) + '.log'

docs/howto/how-to-build-compiler.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,61 @@ $ NNCC_WORKSPACE=build/release ./nncc build
116116
```
117117
will build release version in `build/release` folder.
118118

119+
## Local install and command line tests
120+
121+
Local install test is to make an local installation in `build/install` path
122+
and check the build artifacts and run compiler command line test with `onecc`
123+
and others.
124+
125+
### How to make local installation
126+
```
127+
NNAS_BUILD_PREFIX=build/setup \
128+
BUILD_TYPE=Release \
129+
./nnas create-package --preset 20230907 --prefix build/install
130+
```
131+
This will configure and build necessary modules and install files in
132+
`build/install` path.
133+
134+
### Build and install onnx2circle
135+
136+
`one-import-onnx` tool now uses `onnx2circle` tool from `circle-mlir`.
137+
138+
Please read [README.md](../circle-mlir/README.md) for details.
139+
140+
As `circle-mlir` uses lots of storage(about 150~200GB) and time,
141+
developers may not want to build from source.
142+
For this case, we can install from Debian package from `launchpad.net`
143+
```
144+
sudo -E add-apt-repository ppa:circletools/nightly
145+
sudo apt update
146+
sudo apt install onnx2circle
147+
```
148+
- this will install `onnx2circle` tool to `/usr/share/circletools` folder
149+
- you can make a copy or let `one-import-onnx` use this if `onnx2circle` is not
150+
present in the same folder
151+
152+
### Command line tests
153+
154+
To run command line tests, python virtual envirnment is necessary with
155+
test models.
156+
157+
Prepare python virtual environment:
158+
```
159+
cd build/install/bin
160+
bash ./one-prepare-venv
161+
```
162+
163+
Download test models:
164+
```
165+
cd ../test
166+
bash ./prepare_test_materials.sh
167+
```
168+
169+
Run command line tests:
170+
```
171+
bash ./runtestall.sh
172+
```
173+
119174
## Build for Windows
120175

121176
To build for Windows, we use MinGW(Minimalist GNU for Windows). [Here](https://github.com/git-for-windows/build-extra/releases) you can download a tool that includes it.

0 commit comments

Comments
 (0)