Skip to content

Commit 5740df7

Browse files
committed
DRAFT upgrade to python 3.10
on-going draft to use upgrade to python 3.10. Signed-off-by: SaeHie Park <[email protected]>
1 parent 1e4468d commit 5740df7

File tree

7 files changed

+123
-43
lines changed

7 files changed

+123
-43
lines changed

.github/workflows/run-onecc-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ jobs:
4949
include:
5050
- ubuntu_code: focal
5151
ubuntu_ver: 20.04
52+
python_exec: python3.10
5253
- ubuntu_code: jammy
5354
ubuntu_ver: 22.04
55+
python_exec: python3
5456
runs-on: one-x64-linux
5557
container:
5658
image: samsungonedev.azurecr.io/nnfw/one-devtools:${{ matrix.ubuntu_code }}

compiler/common-artifacts/CMakeLists.txt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
#[[ Generate common python virtual enviornment ]]
2-
# NOTE find_package try to use at least python3.8 as follows depending on platform version
3-
# Ubuntu18.04; explictly installed python3.8 (default is python3.6)
4-
# Ubuntu20.04; default python3.8
2+
# NOTE find_package try to use at least python3.10 as follows depending on platform version
3+
# Ubuntu20.04; explictly installed python3.10 (default is python3.8)
54
# Ubuntu22.04; default python3.10
65
# Ubuntu24.04; default python3.12
76
# refer https://github.com/Samsung/ONE/issues/9962
8-
# find python 3.8 or above
9-
find_package(Python 3.8 EXACT COMPONENTS Interpreter QUIET)
7+
# refer https://github.com/Samsung/ONE/issues/15226
8+
# find python 3.10 or above
9+
find_package(Python 3.10 EXACT COMPONENTS Interpreter QUIET)
1010
if(NOT Python_FOUND)
11-
find_package(Python 3.8 COMPONENTS Interpreter QUIET)
11+
find_package(Python 3.10 COMPONENTS Interpreter QUIET)
1212
endif()
1313

1414
if(NOT Python_Interpreter_FOUND)
1515
message(STATUS "Build common-artifacts: FAILED (Python3 is missing)")
1616
return()
1717
endif()
1818

19-
# NOTE assume only use 3.8.x or 3.10.x or 3.12.x
20-
if((Python_VERSION VERSION_GREATER_EQUAL 3.8) AND (Python_VERSION VERSION_LESS 3.9))
21-
set(PYTHON_VERSION_MINOR 8)
22-
elseif((Python_VERSION VERSION_GREATER_EQUAL 3.10) AND (Python_VERSION VERSION_LESS 3.11))
19+
# NOTE assume only use 3.10.x or 3.12.x
20+
if((Python_VERSION VERSION_GREATER_EQUAL 3.10) AND (Python_VERSION VERSION_LESS 3.11))
2321
set(PYTHON_VERSION_MINOR 10)
2422
elseif((Python_VERSION VERSION_GREATER_EQUAL 3.12) AND (Python_VERSION VERSION_LESS 3.13))
2523
set(PYTHON_VERSION_MINOR 12)
@@ -48,8 +46,8 @@ set(REQUIREMENTS_FILE "requirements.txt")
4846
set(REQUIREMENTS_OVERLAY_PATH "${VIRTUALENV_OVERLAY}/${REQUIREMENTS_FILE}")
4947

5048
set(PYTHON_OVERLAY python3)
51-
if(PYTHON_EXECUTABLE MATCHES python3.8)
52-
set(PYTHON_OVERLAY python3.8)
49+
if(PYTHON_EXECUTABLE MATCHES python3.10)
50+
set(PYTHON_OVERLAY python3.10)
5351
endif()
5452

5553
# NOTE when using behind proxy with self signed certificate, need to set '--trusted-host' options

compiler/dalgona/CMakeLists.txt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
# NOTE find_package will try to use at least python3.8 as follows depending on platform version
2-
# Ubuntu18.04; explictly installed python3.8 (default is python3.6)
3-
# Ubuntu20.04; default python3.8
1+
# NOTE find_package will try to use at least python3.10 as follows depending on platform version
2+
# Ubuntu20.04; explictly installed python3.10 (default is python3.8)
43
# Ubuntu22.04; default python3.10
54
# Ubuntu24.04; default python3.12
65
# refer https://github.com/Samsung/ONE/issues/9962
6+
# refer https://github.com/Samsung/ONE/issues/15226
77
# NOTE Require same python version of common-artifacts
8-
# find python 3.8 or above
9-
find_package(Python 3.8 EXACT COMPONENTS Interpreter Development QUIET)
8+
# find python 3.10 or above
9+
find_package(Python 3.10 EXACT COMPONENTS Interpreter Development QUIET)
1010
if(NOT Python_FOUND)
11-
find_package(Python 3.8 COMPONENTS Interpreter Development QUIET)
11+
find_package(Python 3.10 COMPONENTS Interpreter Development QUIET)
1212
endif()
1313

1414
if(NOT Python_Development_FOUND)
1515
message(STATUS "Build dalgona: FAILED (Python3 development package is missing)")
1616
return()
1717
endif()
1818

19-
# NOTE assume only use 3.8.x or 3.10.x or 3.12.x
20-
if((Python_VERSION VERSION_GREATER_EQUAL 3.8) AND (Python_VERSION VERSION_LESS 3.9))
21-
set(PYTHON_VERSION_MINOR 8)
22-
elseif((Python_VERSION VERSION_GREATER_EQUAL 3.10) AND (Python_VERSION VERSION_LESS 3.11))
19+
# NOTE assume only use 3.10.x or 3.12.x
20+
if((Python_VERSION VERSION_GREATER_EQUAL 3.10) AND (Python_VERSION VERSION_LESS 3.11))
2321
set(PYTHON_VERSION_MINOR 10)
2422
elseif((Python_VERSION VERSION_GREATER_EQUAL 3.12) AND (Python_VERSION VERSION_LESS 3.13))
2523
set(PYTHON_VERSION_MINOR 12)

compiler/one-cmds/CMakeLists.txt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
# NOTE find_package try to use at least python3.8 as follows depending on platform version
2-
# Ubuntu18.04; explictly installed python3.8 (default is python3.6)
3-
# Ubuntu20.04; default python3.8
1+
# NOTE find_package will try to use at least python3.10 as follows depending on platform version
2+
# Ubuntu20.04; explictly installed python3.10 (default is python3.8)
43
# Ubuntu22.04; default python3.10
54
# Ubuntu24.04; explicitly installed python3.8 (default is python3.12)
65
# refer https://github.com/Samsung/ONE/issues/9962
7-
find_package(Python 3.8 EXACT COMPONENTS Interpreter QUIET)
6+
# refer https://github.com/Samsung/ONE/issues/15226
7+
find_package(Python 3.10 EXACT COMPONENTS Interpreter QUIET)
88
if(NOT Python_FOUND)
9-
find_package(Python 3.8 COMPONENTS Interpreter QUIET)
9+
find_package(Python 3.10 COMPONENTS Interpreter QUIET)
1010
endif()
1111

1212
if(NOT Python_Interpreter_FOUND)
1313
message(STATUS "Build one-cmds: FAILED (Python3 is missing)")
1414
return()
1515
endif()
1616

17-
# NOTE assume only use 3.8.x or 3.10.x or 3.12.x
17+
# NOTE assume only use 3.10.x or 3.12.x
1818
# NOTE PYTHON_VERSION_MINOR is not used but added for consistancy with common-artifacts and dalgona
19-
if((Python_VERSION VERSION_GREATER_EQUAL 3.8) AND (Python_VERSION VERSION_LESS 3.9))
20-
set(PYTHON_VERSION_MINOR 8)
21-
elseif((Python_VERSION VERSION_GREATER_EQUAL 3.10) AND (Python_VERSION VERSION_LESS 3.11))
19+
if((Python_VERSION VERSION_GREATER_EQUAL 3.10) AND (Python_VERSION VERSION_LESS 3.11))
2220
set(PYTHON_VERSION_MINOR 10)
2321
elseif((Python_VERSION VERSION_GREATER_EQUAL 3.12) AND (Python_VERSION VERSION_LESS 3.13))
2422
set(PYTHON_VERSION_MINOR 12)

compiler/one-cmds/one-prepare-venv

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,26 @@ VER_PROTOBUF=4.23.3
6969
VER_NUMPY=1.24.3
7070

7171
PYTHON_VER=$(${PYTHON3_EXEC} -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" )
72-
echo "Setting package version for python $PYTHON_VER"
73-
if [[ "$PYTHON_VER" == "3.8" ]]; then
74-
: # use as is
75-
elif [[ "$PYTHON_VER" == "3.10" ]]; then
76-
: # TODO change vesions
72+
if [[ "$PYTHON_VER" == "3.10" ]]; then
73+
VER_TENSORFLOW=2.19.0
74+
VER_ONNX=1.18.0
75+
VER_ONNXRUNTIME=1.21.1
76+
VER_TORCH="2.7.0+cpu"
77+
VER_NUMPY="1.26.4"
78+
VER_PROTOBUF="5.29.4"
79+
VER_TF_PROB=0
80+
VER_TF_ADON=0
81+
VER_ONNX_TF=0
7782
elif [[ "$PYTHON_VER" == "3.12" ]]; then
78-
: # TODO change vesions
83+
VER_TENSORFLOW=2.19.0
84+
VER_ONNX=1.18.0
85+
VER_ONNXRUNTIME=1.21.1
86+
VER_TORCH="2.7.0+cpu"
87+
VER_NUMPY="1.26.4"
88+
VER_PROTOBUF="5.29.4"
89+
VER_TF_PROB=0
90+
VER_TF_ADON=0
91+
VER_ONNX_TF=0
7992
else
8093
echo "Error one-prepare-venv: Unsupported python $PYTHON_VER"
8194
exit 1
@@ -110,15 +123,22 @@ ${VENV_PYTHON} -m pip ${PIP_OPTIONS} install --upgrade pip setuptools
110123

111124
PYTHON_PACKAGES="tensorflow-cpu==${VER_TENSORFLOW} "
112125
PYTHON_PACKAGES+="Pillow "
113-
PYTHON_PACKAGES+="tensorflow_probability==${VER_TF_PROB} "
114-
PYTHON_PACKAGES+="tensorflow_addons==${VER_TF_ADON} "
115126
PYTHON_PACKAGES+="torch==${VER_TORCH} "
116127
PYTHON_PACKAGES+="onnx==${VER_ONNX} "
117128
PYTHON_PACKAGES+="onnxruntime==${VER_ONNXRUNTIME} "
118-
PYTHON_PACKAGES+="onnx-tf==${VER_ONNX_TF} "
119129
PYTHON_PACKAGES+="protobuf==${VER_PROTOBUF} "
120130
PYTHON_PACKAGES+="fsspec==2024.6.1 "
121131
PYTHON_PACKAGES+="pydot==${VER_PYDOT} "
122132
PYTHON_PACKAGES+="numpy==${VER_NUMPY} "
123133

134+
if [[ "${VER_TF_PROB}" != "0" ]]; then
135+
PYTHON_PACKAGES+="tensorflow_probability==${VER_TF_PROB} "
136+
fi
137+
if [[ "${VER_TF_ADON}" != "0" ]]; then
138+
PYTHON_PACKAGES+="tensorflow_addons==${VER_TF_ADON} "
139+
fi
140+
if [[ "${VER_ONNX_TF}" != "0" ]]; then
141+
PYTHON_PACKAGES+="onnx-tf==${VER_ONNX_TF} "
142+
fi
143+
124144
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install --upgrade ${PYTHON_PACKAGES} ${TORCH_SOURCE_OPTION}

compiler/tf2tfliteV2/tf2tfliteV2.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,8 @@ def _convert(flags):
263263
_apply_verbosity(flags.verbose)
264264

265265
if (flags.v1):
266-
_v1_convert(flags)
267-
else:
268-
_v2_convert(flags)
266+
print("tf2tfliteV2: v1 not supported anymore. convert with v2.")
267+
_v2_convert(flags)
269268

270269

271270
"""

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

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,71 @@ $ 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+
check the build artifacts and run compiler command line tests of `onecc`
123+
and others.
124+
125+
### Prepare onnx2circle
126+
127+
`one-import-onnx` tool now uses `onnx2circle` tool from `circle-mlir`.
128+
129+
`onnx2cicle` tool can be prepared with (1) build from source or (2) install
130+
from [launchpad.net](https://launchpad.net/~circletools).
131+
132+
Please read [README.md](../circle-mlir/README.md) for details how to build.
133+
134+
As `circle-mlir/externals` uses lots of storage(about 150~200GB) and time,
135+
we recommand to use build with Docker image as described in above README file.
136+
137+
To use Debian package from [launchpad.net](https://launchpad.net/~circletools),
138+
```
139+
sudo apt-get update
140+
sudo apt-get install software-properties-common
141+
sudo -E add-apt-repository ppa:circletools/nightly
142+
sudo apt-get install onnx2circle
143+
```
144+
- this will install `onnx2circle` tool to `/usr/share/circletools` folder
145+
146+
`one-cmds/CMakeLists.txt` will install `onnx2circle` from (1) or (2) to
147+
`buid/install` as conversion tool of `one-import-onnx` command.
148+
149+
### How to make local installation
150+
```
151+
NNAS_BUILD_PREFIX=build/setup \
152+
BUILD_TYPE=Release \
153+
./nnas create-package --preset 20230907 --prefix build/install
154+
```
155+
This will configure and build necessary modules and install files in
156+
`build/install` path.
157+
158+
### Local command line tests
159+
160+
To run local command line tests, python virtual envirnment is necessary with
161+
test models.
162+
163+
Prepare python virtual environment:
164+
```
165+
pushd build/install/bin
166+
bash ./one-prepare-venv
167+
popd
168+
```
169+
170+
Download test models:
171+
```
172+
pushd build/install/test
173+
bash ./prepare_test_materials.sh
174+
popd
175+
```
176+
177+
Run command line tests:
178+
```
179+
pushd build/install/test
180+
bash ./runtestall.sh
181+
popd
182+
```
183+
119184
## Build for Windows
120185

121186
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)