-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DRAFT: circle-quantize with alternative names
on-going draft to support alternative names. Signed-off-by: SaeHie Park <[email protected]>
- Loading branch information
1 parent
f0a308f
commit f632982
Showing
5 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[onecc] | ||
one-import-onnx=True | ||
one-optimize=True | ||
one-quantize=True | ||
include=O1 | ||
|
||
[one-import-onnx] | ||
input_path=onnx_conv2d_conv2d.onnx | ||
output_path=onnx_conv2d_conv2d.circle | ||
|
||
[one-optimize] | ||
input_path=onnx_conv2d_conv2d.circle | ||
output_path=onnx_conv2d_conv2d.opt.circle | ||
convert_nchw_to_nhwc=True | ||
|
||
[one-quantize] | ||
input_path=onnx_conv2d_conv2d.opt.circle | ||
output_path=onnx_conv2d_conv2d.opt.qm.circle | ||
quant_config=onnx_name.qconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"default_quantization_dtype" : "uint8", | ||
"default_granularity" : "layer", | ||
"layers" : [ | ||
{ | ||
"names" : [ | ||
"onnx_tf_prefix_Relu_3;Add_1;convolution_1;Const_3" | ||
], | ||
"alternate": [ | ||
{ | ||
"onnx_tf_prefix_Relu_3;Add_1;convolution_1;Const_3": | ||
[ | ||
"onnx_tf_prefix_Relu_3;Add_1;convolution_1;Const" | ||
] | ||
} | ||
], | ||
"dtype" : "int16", | ||
"granularity" : "channel" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
|
||
DRIVER_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
||
VENV_ACTIVATE=${DRIVER_PATH}/venv/bin/activate | ||
# NOTE please use venv's python instead of python after `source activation`. | ||
# This script is called by debian maintainer script, i.e. `postinst`. | ||
# Since debian maintainer script is called with sudo, `source activation` is ignored. | ||
VENV_PYTHON=${DRIVER_PATH}/venv/bin/python | ||
|
||
if [ ! -f ${VENV_ACTIVATE} ]; then | ||
# Create python virtual enviornment | ||
python3.8 -m venv "${DRIVER_PATH}/venv" | ||
fi | ||
|
||
# NOTE version | ||
# - https://github.com/onnx/onnx/blob/master/docs/Versioning.md | ||
# - https://github.com/onnx/onnx-tensorflow/blob/master/Versioning.md | ||
|
||
VER_TENSORFLOW=2.8.0 | ||
VER_ONNX=1.11.0 | ||
VER_ONNXRUNTIME=1.11.0 | ||
VER_ONNX_TF=1.10.0 | ||
VER_PYDOT=1.4.2 | ||
|
||
# Install tensorflow | ||
|
||
PIP_TRUSTED_HOST="--trusted-host pypi.org " | ||
PIP_TRUSTED_HOST+="--trusted-host pypi.python.org " | ||
PIP_TRUSTED_HOST+="--trusted-host files.pythonhosted.org " | ||
PIP_TRUSTED_HOST+="--trusted-host download.pytorch.org " | ||
|
||
PIP_TIMEOUT="--default-timeout=1000 " | ||
|
||
PIP_OPTIONS="${PIP_TIMEOUT} ${PIP_TRUSTED_HOST}" | ||
|
||
# NOTE $ONE_PREPVENV_PIP_OPTION is to provide additional PIP options | ||
# such as ceritificate file behind firewall | ||
# ex) ONE_PREPVENV_PIP_OPTION="--cert SomePrivateCetificate.crt" ./one-prepare-venv | ||
if [[ ! -z "$ONE_PREPVENV_PIP_OPTION" ]]; then | ||
PIP_OPTIONS+=" ${ONE_PREPVENV_PIP_OPTION} " | ||
fi | ||
|
||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install --upgrade pip setuptools | ||
if [ -n "${EXT_TENSORFLOW_WHL}" ]; then | ||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install ${EXT_TENSORFLOW_WHL} | ||
else | ||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install tensorflow-cpu==${VER_TENSORFLOW} | ||
fi | ||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install Pillow | ||
# TODO remove version fix, https://github.com/Samsung/ONE/issues/9240 | ||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install tensorflow_probability==0.16.0 | ||
# TODO remove version fix, https://github.com/Samsung/ONE/issues/10481 | ||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install tensorflow_addons==0.16.1 | ||
|
||
# Install PyTorch and ONNX related | ||
# NOTE set ONE_PREPVENV_TORCH_STABLE to override 'torch_stable.html' URL. | ||
# torch_stable.html points to download URL of torch wheel file(s) | ||
# but sometimes the server gets unstable, especially from in-house CI. | ||
TORCH_STABLE_URL="https://download.pytorch.org/whl/torch_stable.html" | ||
if [[ ! -z "$ONE_PREPVENV_TORCH_STABLE" ]]; then | ||
TORCH_STABLE_URL="${ONE_PREPVENV_TORCH_STABLE}" | ||
fi | ||
# TODO remove torch message | ||
echo "Torch from '${ONE_PREPVENV_TORCH_STABLE}' -> '${TORCH_STABLE_URL}'" | ||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install torch==1.11.0+cpu -f ${TORCH_STABLE_URL} | ||
|
||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install onnx==${VER_ONNX} | ||
|
||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install onnxruntime==${VER_ONNXRUNTIME} | ||
|
||
# Provide install of custom onnx-tf | ||
if [ -n "${EXT_ONNX_TF_WHL}" ]; then | ||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install ${EXT_ONNX_TF_WHL} | ||
else | ||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install onnx-tf==${VER_ONNX_TF} | ||
fi | ||
|
||
# NOTE refer https://github.com/protocolbuffers/protobuf/issues/10051 | ||
# TODO remove this when issue is resolved | ||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install --upgrade protobuf==3.20.1 | ||
|
||
# Install pydot for visq | ||
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install pydot==${VER_PYDOT} |