Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/run-onecc-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ jobs:
include:
- ubuntu_code: focal
ubuntu_ver: 20.04
python_exec: python3.10
- ubuntu_code: jammy
ubuntu_ver: 22.04
python_exec: python3
runs-on: one-x64-linux
container:
image: samsungonedev.azurecr.io/nnfw/one-devtools:${{ matrix.ubuntu_code }}
Expand Down Expand Up @@ -78,12 +80,6 @@ jobs:
apt-get -qqy install python3.10 python3.10-dev python3.10-venv
python3.10 -m ensurepip --upgrade

# dalgona uses pybind11, but pybind11 cannot bind packages in virtualenv.
# So we need to install packages for dalgona-test globally.
- name: Install required packages
run: |
python3 -m pip install numpy h5py==3.11.0 flatbuffers==23.5.26

- name: Caching externals
uses: actions/cache@v4
with:
Expand Down
28 changes: 12 additions & 16 deletions compiler/common-artifacts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
#[[ Generate common python virtual enviornment ]]
# NOTE find_package try to use at least python3.8 as follows depending on platform version
# Ubuntu18.04; explictly installed python3.8 (default is python3.6)
# Ubuntu20.04; default python3.8
# NOTE find_package try to use at least python3.10 as follows depending on platform version
# Ubuntu20.04; explictly installed python3.10 (default is python3.8)
# Ubuntu22.04; default python3.10
# Ubuntu24.04; default python3.12
# refer https://github.com/Samsung/ONE/issues/9962
# find python 3.8 or above
find_package(Python 3.8 COMPONENTS Interpreter QUIET)
# refer https://github.com/Samsung/ONE/issues/15226
# find python 3.10 or above
find_package(Python 3.10 EXACT COMPONENTS Interpreter QUIET)
if(NOT Python_FOUND)
find_package(Python 3 COMPONENTS Interpreter QUIET)
endif()

if(NOT Python_Interpreter_FOUND)
message(STATUS "Build common-artifacts: FAILED (Python3 is missing)")
return()
endif()

if(Python_VERSION VERSION_LESS 3.8)
message(STATUS "Build common-artifacts: FAILED (Need Python version 3.8 or higher)")
return()
endif()

# NOTE assume only use 3.8.x or 3.10.x or 3.12.x
if((Python_VERSION VERSION_GREATER_EQUAL 3.8) AND (Python_VERSION VERSION_LESS 3.9))
set(PYTHON_VERSION_MINOR 8)
elseif((Python_VERSION VERSION_GREATER_EQUAL 3.10) AND (Python_VERSION VERSION_LESS 3.11))
# NOTE assume only use 3.10.x or 3.12.x
if((Python_VERSION VERSION_GREATER_EQUAL 3.10) AND (Python_VERSION VERSION_LESS 3.11))
set(PYTHON_VERSION_MINOR 10)
elseif((Python_VERSION VERSION_GREATER_EQUAL 3.12) AND (Python_VERSION VERSION_LESS 3.13))
set(PYTHON_VERSION_MINOR 12)
Expand All @@ -46,8 +42,8 @@ set(REQUIREMENTS_FILE "requirements.txt")
set(REQUIREMENTS_OVERLAY_PATH "${VIRTUALENV_OVERLAY}/${REQUIREMENTS_FILE}")

set(PYTHON_OVERLAY python3)
if(PYTHON_EXECUTABLE MATCHES python3.8)
set(PYTHON_OVERLAY python3.8)
if(PYTHON_EXECUTABLE MATCHES python3.10)
set(PYTHON_OVERLAY python3.10)
endif()

# NOTE when using behind proxy with self signed certificate, need to set '--trusted-host' options
Expand Down
23 changes: 16 additions & 7 deletions compiler/dalgona/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
# NOTE find_package will try to use at least python3.8 as follows depending on platform version
# Ubuntu18.04; explictly installed python3.8 (default is python3.6)
# Ubuntu20.04; default python3.8
# NOTE find_package will try to use at least python3.10 as follows depending on platform version
# Ubuntu20.04; explictly installed python3.10 (default is python3.8)
# Ubuntu22.04; default python3.10
# Ubuntu24.04; default python3.12
# refer https://github.com/Samsung/ONE/issues/9962
# refer https://github.com/Samsung/ONE/issues/15226
# NOTE Require same python version of common-artifacts
# find python 3.8 or above
find_package(Python 3.8 COMPONENTS Development QUIET)
# find python 3.10 or above
find_package(Python 3.10 EXACT COMPONENTS Interpreter Development QUIET)
if(NOT Python_FOUND)
find_package(Python 3 COMPONENTS Interpreter Development QUIET)
endif()

if(NOT Python_Development_FOUND)
message(STATUS "Build dalgona: FAILED (Python3 development package is missing)")
return()
endif()

if(Python_VERSION VERSION_LESS 3.8)
message(STATUS "Build dalgona: FAILED (Need Python version 3.8 or higher)")
# NOTE assume only use 3.10.x or 3.12.x
if((Python_VERSION VERSION_GREATER_EQUAL 3.10) AND (Python_VERSION VERSION_LESS 3.11))
set(PYTHON_VERSION_MINOR 10)
elseif((Python_VERSION VERSION_GREATER_EQUAL 3.12) AND (Python_VERSION VERSION_LESS 3.13))
set(PYTHON_VERSION_MINOR 12)
else()
# TODO support more
message(STATUS "Build dalgona: FAILED (Unsupported python: ${Python_VERSION})")
return()
endif()

Expand Down
29 changes: 15 additions & 14 deletions compiler/one-cmds/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# NOTE find_package try to use at least python3.8 as follows depending on platform version
# Ubuntu18.04; explictly installed python3.8 (default is python3.6)
# Ubuntu20.04; default python3.8
# NOTE find_package will try to use at least python3.10 as follows depending on platform version
# Ubuntu20.04; explictly installed python3.10 (default is python3.8)
# Ubuntu22.04; default python3.10
# Ubuntu24.04; explicitly installed python3.8 (default is python3.12)
# refer https://github.com/Samsung/ONE/issues/9962
find_package(Python 3.8 EXACT COMPONENTS Interpreter QUIET)
# refer https://github.com/Samsung/ONE/issues/15226
find_package(Python 3.10 EXACT COMPONENTS Interpreter QUIET)
if(NOT Python_FOUND)
find_package(Python 3.8 COMPONENTS Interpreter QUIET)
find_package(Python 3 COMPONENTS Interpreter QUIET)
endif()

# tensorflow 2.12.1 supports Python 3.8 ~ 3.11
if(Python_VERSION VERSION_GREATER_EQUAL 3.12)
message(STATUS "Build one-cmds: FALSE (Python version 3.12 or higher is not supported yet)")
return()
endif()
if(Python_VERSION VERSION_LESS 3.8)
message(STATUS "Build one-cmds: FAILED (Install Python version 3.8 or 3.10)")
if(NOT Python_Interpreter_FOUND)
message(STATUS "Build one-cmds: FAILED (Python3 is missing)")
return()
endif()

if(NOT Python_Interpreter_FOUND)
message(STATUS "Build one-cmds: FAILED (Python3 is missing)")
# NOTE assume only use 3.10.x or 3.12.x
if((Python_VERSION VERSION_GREATER_EQUAL 3.10) AND (Python_VERSION VERSION_LESS 3.11))
set(PYTHON_VERSION_MINOR 10)
elseif((Python_VERSION VERSION_GREATER_EQUAL 3.12) AND (Python_VERSION VERSION_LESS 3.13))
set(PYTHON_VERSION_MINOR 12)
else()
# TODO support more
message(STATUS "Build one-cmds: FAILED (Unsupported python: ${Python_VERSION})")
return()
endif()

Expand Down
43 changes: 37 additions & 6 deletions compiler/one-cmds/one-prepare-venv
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ VER_PROTOBUF=4.23.3
VER_NUMPY=1.24.3

echo "Setting version for '$DISTRIB_CODENAME'"
if [[ "$DISTRIB_CODENAME" == "bionic" ]]; then
: # use as is
elif [[ "$DISTRIB_CODENAME" == "focal" ]]; then
if [[ "$DISTRIB_CODENAME" == "focal" ]]; then
: # use as is
elif [[ "$DISTRIB_CODENAME" == "jammy" ]]; then
: # TODO change vesions
Expand All @@ -82,6 +80,32 @@ else
exit 1
fi

PYTHON_VER=$(${PYTHON3_EXEC} -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" )
if [[ "$PYTHON_VER" == "3.10" ]]; then
VER_TENSORFLOW=2.19.0
VER_ONNX=1.18.0
VER_ONNXRUNTIME=1.21.1
VER_TORCH="2.7.0+cpu"
VER_NUMPY="1.26.4"
VER_PROTOBUF="5.29.4"
VER_TF_PROB=0
VER_TF_ADON=0
VER_ONNX_TF=0
elif [[ "$PYTHON_VER" == "3.12" ]]; then
VER_TENSORFLOW=2.19.0
VER_ONNX=1.18.0
VER_ONNXRUNTIME=1.21.1
VER_TORCH="2.7.0+cpu"
VER_NUMPY="1.26.4"
VER_PROTOBUF="5.29.4"
VER_TF_PROB=0
VER_TF_ADON=0
VER_ONNX_TF=0
else
echo "Error one-prepare-venv: Unsupported python $PYTHON_VER"
exit 1
fi

PIP_TRUSTED_HOST="--trusted-host pypi.org "
PIP_TRUSTED_HOST+="--trusted-host pypi.python.org "
PIP_TRUSTED_HOST+="--trusted-host files.pythonhosted.org "
Expand Down Expand Up @@ -111,15 +135,22 @@ ${VENV_PYTHON} -m pip ${PIP_OPTIONS} install --upgrade pip setuptools

PYTHON_PACKAGES="tensorflow-cpu==${VER_TENSORFLOW} "
PYTHON_PACKAGES+="Pillow "
PYTHON_PACKAGES+="tensorflow_probability==${VER_TF_PROB} "
PYTHON_PACKAGES+="tensorflow_addons==${VER_TF_ADON} "
PYTHON_PACKAGES+="torch==${VER_TORCH} "
PYTHON_PACKAGES+="onnx==${VER_ONNX} "
PYTHON_PACKAGES+="onnxruntime==${VER_ONNXRUNTIME} "
PYTHON_PACKAGES+="onnx-tf==${VER_ONNX_TF} "
PYTHON_PACKAGES+="protobuf==${VER_PROTOBUF} "
PYTHON_PACKAGES+="fsspec==2024.6.1 "
PYTHON_PACKAGES+="pydot==${VER_PYDOT} "
PYTHON_PACKAGES+="numpy==${VER_NUMPY} "

if [[ "${VER_TF_PROB}" != "0" ]]; then
PYTHON_PACKAGES+="tensorflow_probability==${VER_TF_PROB} "
fi
if [[ "${VER_TF_ADON}" != "0" ]]; then
PYTHON_PACKAGES+="tensorflow_addons==${VER_TF_ADON} "
fi
if [[ "${VER_ONNX_TF}" != "0" ]]; then
PYTHON_PACKAGES+="onnx-tf==${VER_ONNX_TF} "
fi

${VENV_PYTHON} -m pip ${PIP_OPTIONS} install --upgrade ${PYTHON_PACKAGES} ${TORCH_SOURCE_OPTION}
59 changes: 59 additions & 0 deletions docs/howto/how-to-build-compiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,65 @@ $ NNCC_WORKSPACE=build/release ./nncc build
```
will build release version in `build/release` folder.

## Local install and command line tests

Local install test is to make an local installation in `build/install` path
and check the build artifacts and run compiler command line test with `onecc`
and others.

### How to make local installation
```
NNAS_BUILD_PREFIX=build/setup \
BUILD_TYPE=Release \
./nnas create-package --preset 20230907 --prefix build/install
```
This will configure and build necessary modules and install files in
`build/install` path.

### Prepare onnx2circle

`one-import-onnx` tool now uses `onnx2circle` tool from `circle-mlir`.

`onnx2cicle` tool can be prepared with (1) build from source or (2) install
from [launchpad.net](https://launchpad.net/~circletools).

Please read [README.md](../circle-mlir/README.md) for details how to build.
As `circle-mlir/externals` uses lots of storage(about 150~200GB) and time,
we recommand to use build with Docker image as described in above README file.

To use Debian package from [launchpad.net](https://launchpad.net/~circletools),
```
sudo -E add-apt-repository ppa:circletools/nightly
sudo apt update
sudo apt install onnx2circle
```
- this will install `onnx2circle` tool to `/usr/share/circletools` folder

`one-cmds/CMakeLists.txt` will install `onnx2circle` from (1) or (2) as
conversion tool for `one-import-onnx` command.

### Command line tests

To run command line tests, python virtual envirnment is necessary with
test models.

Prepare python virtual environment:
```
cd build/install/bin
bash ./one-prepare-venv
```

Download test models:
```
cd ../test
bash ./prepare_test_materials.sh
```

Run command line tests:
```
bash ./runtestall.sh
```

## Build for Windows

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.
Expand Down