-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added PyTorch SalsaNext model; pylint cleanup, CMake and PR support; …
…model refactoring and w4a8 update - Added code, documentation and artifacts for the following new PyTorch models: SalsaNext - Added Pytorch w4a8 support for HRNET-Posenet, QuickSRNet and RangeNet++ models - Model refactoring and code updates for a few models (HRNet, classification models, super resolution models, ViT, MobileViT, gpt2) - Cleaned up more code to minimize errors from static analysis (pylint) - Adding pylint capability via cmake and Jenkins pull request mechanism - Released second package release of aimet model zoo (installable wheel file binaries) Signed-off-by: Hanwen Xiong <[email protected]>
- Loading branch information
1 parent
47c8891
commit 59640d1
Showing
258 changed files
with
71,914 additions
and
4,032 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
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,233 @@ | ||
# ============================================================================= | ||
# @@-COPYRIGHT-START-@@ | ||
# | ||
# Copyright (c) 2022 of Qualcomm Innovation Center, Inc. All rights reserved. | ||
# Changes from QuIC are licensed under the terms and conditions at | ||
# https://github.com/quic/aimet-model-zoo/blob/develop/LICENSE.pdf | ||
# | ||
# @@-COPYRIGHT-END-@@ | ||
# ============================================================================= | ||
|
||
# ---------------------------------------------- | ||
# Copyright (c) 2022 Qualcomm Technologies, Inc. | ||
# All Rights Reserved. | ||
# ---------------------------------------------- | ||
|
||
# Docker image file to build and test AIMET for both Tensorflow and PyTorch in a CPU environment | ||
|
||
FROM ubuntu:bionic | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update > /dev/null && \ | ||
apt-get install --no-install-recommends -y \ | ||
# Bare minimum Packages | ||
ca-certificates \ | ||
git \ | ||
ssh \ | ||
sudo \ | ||
wget \ | ||
xterm \ | ||
xauth > /dev/null && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Install certificates | ||
RUN sudo update-ca-certificates | ||
|
||
# Modified version of bash.bashrc that adjusts the prompt | ||
### COPY bash.bashrc /etc/ | ||
### RUN chmod 644 /etc/bash.bashrc | ||
|
||
### COPY profile.global /usr/local/etc/ | ||
### RUN chmod 555 /usr/local/etc/profile.global | ||
|
||
# Add sudo support | ||
RUN echo "%users ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers | ||
|
||
RUN apt-get update -y > /dev/null && \ | ||
apt-get install --no-install-recommends -y \ | ||
# Python | ||
python3.8 \ | ||
python3.8-dev \ | ||
python3-pip \ | ||
python3-setuptools \ | ||
build-essential \ | ||
# lmdb dependency | ||
libffi-dev && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Register the version in alternatives | ||
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 | ||
# Set python 3.8 as the default python | ||
RUN update-alternatives --set python3 /usr/bin/python3.8 | ||
|
||
# Python 2 pip installation | ||
RUN apt-get update && apt-get install -y python-pip && rm -rf /var/lib/apt/lists/* && \ | ||
python2.7 -m pip --no-cache-dir install --upgrade \ | ||
pip==20.3.4 \ | ||
restkit | ||
|
||
# Upgrade Python3 pip and install some more packages | ||
RUN python3 -m pip --no-cache-dir install --upgrade \ | ||
pip \ | ||
setuptools==41.0.1 \ | ||
wheel==0.33.4 | ||
|
||
# Ubuntu packages for tensorflow and pytorch aimet | ||
RUN dpkg --add-architecture i386 | ||
RUN apt-get update > /dev/null && \ | ||
apt-get install --no-install-recommends -y \ | ||
build-essential \ | ||
emacs \ | ||
environment-modules \ | ||
less \ | ||
libavcodec-dev \ | ||
libavformat-dev \ | ||
libgtest-dev \ | ||
libgtk2.0-dev \ | ||
libsox-dev \ | ||
libsox-fmt-all \ | ||
libstdc++6:i386 \ | ||
libswscale-dev \ | ||
libxtst6 \ | ||
lsb-release \ | ||
meld \ | ||
nano \ | ||
pandoc \ | ||
pkg-config \ | ||
python3-tk \ | ||
sox \ | ||
tree \ | ||
vim && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Python3 Packages | ||
RUN python3 -m pip --no-cache-dir install \ | ||
astroid==2.5.3 \ | ||
attrs==19.1.0 \ | ||
behave==1.2.6 \ | ||
bert-tensorflow \ | ||
blosc==1.10.1 \ | ||
cffi==1.12.3 \ | ||
click \ | ||
cumm==0.2.8 \ | ||
cython==0.29.12 \ | ||
dataclasses \ | ||
Deprecated \ | ||
docutils==0.16 \ | ||
grpcio \ | ||
grpcio-tools \ | ||
h5py==2.10.0 \ | ||
ipykernel \ | ||
Jinja2==3.0.3 \ | ||
jupyter \ | ||
keras==2.2.4 \ | ||
lmdb==1.2.1 \ | ||
matplotlib>=3 \ | ||
mock \ | ||
nbsphinx \ | ||
numpy==1.19.5 \ | ||
onnx==1.12.0 \ | ||
onnxsim \ | ||
onnxruntime \ | ||
onnxruntime-extensions \ | ||
opencv-python \ | ||
Pillow==9.3.0 \ | ||
pluggy==0.12.0 \ | ||
progressbar2 \ | ||
protobuf==3.20.1 \ | ||
psutil \ | ||
ptflops \ | ||
pybind11 \ | ||
pyDOE2 \ | ||
pylint==2.3.1 \ | ||
pymoo \ | ||
pytest==4.6.5 \ | ||
pytest-cov==2.6.1 \ | ||
pytorch-ignite \ | ||
PyYAML \ | ||
scikit-learn==1.1.3 \ | ||
scipy==1.8.1 \ | ||
spconv==2.1.20 \ | ||
sphinx==2.1.1 \ | ||
sphinx-jinja==1.1.1 \ | ||
sphinx-autodoc-typehints==1.6.0 \ | ||
tensorboard==2.4.0 \ | ||
tensorboardX==2.4 \ | ||
tensorflow-cpu==2.4.3 \ | ||
tensorflow-hub \ | ||
tensorflow-model-optimization \ | ||
tensorlayer==2.2.1 \ | ||
timm==0.4.12 \ | ||
torch==1.9.1+cpu -f https://download.pytorch.org/whl/torch_stable.html \ | ||
torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html \ | ||
torchtext==0.10.1 \ | ||
torchvision==0.10.1+cpu -f https://download.pytorch.org/whl/torch_stable.html \ | ||
tqdm \ | ||
transformers==4.11.3 \ | ||
wget && \ | ||
python3 -m ipykernel.kernelspec | ||
|
||
RUN cd /tmp && \ | ||
wget https://github.com/Kitware/CMake/releases/download/v3.19.3/cmake-3.19.3-Linux-x86_64.sh && \ | ||
mkdir /opt/cmake && \ | ||
sh cmake-3.19.3-Linux-x86_64.sh --prefix=/opt/cmake --skip-license | ||
|
||
RUN ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake | ||
RUN ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest | ||
RUN ln -s /opt/cmake/bin/cpack /usr/local/bin/cpack | ||
|
||
ENV PATH=/usr/local/bin:$PATH | ||
|
||
# Opencv | ||
# Ref: https://docs.opencv.org/3.2.0/d7/d9f/tutorial_linux_install.html | ||
COPY opencv_320_python38.patch /tmp | ||
RUN wget -q https://github.com/Itseez/opencv/archive/3.2.0.tar.gz -O /tmp/3.2.0.tar.gz > /dev/null && \ | ||
tar -C /tmp -xvf /tmp/3.2.0.tar.gz > /dev/null && \ | ||
patch /tmp/opencv-3.2.0/modules/python/src2/cv2.cpp /tmp/opencv_320_python38.patch && \ | ||
cd /tmp/opencv-3.2.0 && mkdir release && cd release && \ | ||
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=release -DWITH_FFMPEG=OFF -DBUILD_TESTS=OFF -DWITH_CUDA=OFF -DBUILD_PERF_TESTS=OFF -DWITH_IPP=OFF -DENABLE_PRECOMPILED_HEADERS=OFF .. > /dev/null && \ | ||
make -j16 > /dev/null && \ | ||
make -j16 install > /dev/null && \ | ||
rm -rf /tmp/opencv-3.2.0* | ||
|
||
EXPOSE 25000 | ||
RUN apt-get update && apt-get install -y openssh-server && rm -rf /var/lib/apt/lists/* | ||
RUN mkdir /var/run/sshd | ||
|
||
RUN apt-get update && apt-get install -y liblapacke liblapacke-dev && rm -rf /var/lib/apt/lists/* | ||
|
||
RUN apt-get update && apt-get install -y libjpeg8-dev && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set up symlink to point to the correct python version | ||
RUN ln -sf /usr/bin/python3.8 /usr/bin/python | ||
RUN ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib | ||
|
||
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \ | ||
sed -i 's/Port 22/Port 25000/' /etc/ssh/sshd_config | ||
|
||
# SSH login fix. Otherwise user is kicked off after login | ||
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd | ||
|
||
# Clone the tensorflow repo to enable development | ||
RUN cd / && git clone --depth 1 --single-branch --branch v2.4.3 https://github.com/tensorflow/tensorflow.git | ||
|
||
RUN python3 -m pip install git-pylint-commit-hook osqp | ||
|
||
# NOTE: We need to pin the holoviews version to this since the latest version has a circular dependency on bokeh 2.0.0 through the panel package | ||
RUN python3 -m pip install holoviews==1.12.7 netron jsonschema pandas==1.4.3 | ||
|
||
RUN python3 -m pip install bokeh==1.2.0 hvplot==0.4.0 | ||
|
||
# Remove existing Pillow & Pillow-SIMD and replace with correct version of Pillow-SIMD. | ||
RUN python3 -m pip uninstall -y Pillow Pillow-SIMD | ||
RUN python3 -m pip --no-cache-dir install Pillow-SIMD==9.0.0.post1 | ||
|
||
RUN apt-get update && apt-get install -y gnupg2 | ||
RUN wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add - && echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main" >> /etc/apt/sources.list | ||
RUN apt-get update --fix-missing -y && apt upgrade -y && apt-get install -y clang-11 clang-format clang-tidy-11 && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Create a version-less symbolic link for clang-tidy | ||
RUN ln -s /usr/bin/run-clang-tidy-11.py /usr/bin/run-clang-tidy.py |
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,135 @@ | ||
pipeline { | ||
parameters { | ||
string(name: 'PROJECT_NAME', defaultValue: 'aimet-model-zoo', description: 'project name') | ||
string(name: 'BUILD_LABEL_CPU', defaultValue: 'docker-build-aimet-pr-cpu', description: 'Jenkins node host name or label for CPU variants') | ||
string(name: 'BUILD_TIMEOUT', defaultValue: '3', description: 'Build timeout in hours') | ||
string(name: 'USE_LINARO', defaultValue: '-l', description: 'Use pre-built Linaro images, if available.') | ||
string(name: 'PREBUILT_DOCKER_IMAGE_URL', defaultValue: '', description: 'Use pre-built docker image from URL, if available.') | ||
} | ||
agent { label "${params.BUILD_LABEL_CPU}" } | ||
options { | ||
timestamps() | ||
timeout( time: 3, unit: 'HOURS' ) | ||
} | ||
environment{ | ||
def workspace = pwd() | ||
def REPO_URL = sh (script: "git config --get remote.origin.url", returnStdout: true).trim() | ||
def REPO_NAME = sh (script: "basename -s .git ${REPO_URL}", returnStdout: true).trim() | ||
|
||
PROJECT_ROOT = "${workspace}/${REPO_NAME}" | ||
PROJECT_NAME = "${params.PROJECT_NAME}" | ||
PROJECT_BRANCH = "${params.PROJECT_BRANCH}" | ||
WORKSPACE_ROOT = "${workspace}" | ||
|
||
} | ||
stages { | ||
stage('Setup') { | ||
steps { | ||
echo "*** Running SETUP stage on ${env.NODE_NAME} in workspace ${env.WORKSPACE_ROOT} ***" | ||
sh 'bash -l -c "rm -rf ${PROJECT_ROOT} | true"' | ||
sh 'bash -l -c "mkdir ${PROJECT_ROOT}"' | ||
// moving all files and folders except current and parent into ${REPO_NAME} folder | ||
sh 'mv `ls -1a | grep -v "^${REPO_NAME}$" | grep -v "^\\.$" | grep -v "^\\.\\.$" ` ${REPO_NAME}' | ||
script { | ||
// load threshold file to be used for unit test and code quality reporting | ||
def THRESHOLD_FILE = "${PROJECT_ROOT}/Jenkins/jenkins_threshold_configs.json" | ||
if (!fileExists("${THRESHOLD_FILE}")) { | ||
error("Error: Threshold file must be specified for project. ${THRESHOLD_FILE} does not exist.") | ||
} | ||
|
||
echo "Loading Thresholds Config file" | ||
THRESHOLD_OBJ = readJSON file: "${PROJECT_ROOT}/Jenkins/jenkins_threshold_configs.json"; | ||
} | ||
stash name: 'AIMETBuildTree', useDefaultExcludes: false | ||
} | ||
} | ||
stage('Pipelines start') { | ||
parallel { | ||
// Start the pipeline for Tensorflow CPU variant | ||
stage("TF TORCH CPU") { | ||
agent { label "${params.BUILD_LABEL_CPU}" } | ||
stages { | ||
stage('Setup') { | ||
steps { | ||
cleanWs() | ||
unstash 'AIMETBuildTree' | ||
script { | ||
env.AIMET_ZOO_VARIANT_TF_CPU = "tf-torch-cpu" | ||
} | ||
echo "*** Running SETUP stage for ${env.AIMET_ZOO_VARIANT_TF_CPU} variant on ${env.NODE_NAME} in workspace ${env.WORKSPACE_ROOT} ***" | ||
} | ||
} | ||
|
||
stage('Build Package') { | ||
steps { | ||
echo 'Building and Creating Package...' | ||
script { | ||
//TODO Change option back to "-bp" as soon as issue is fixed | ||
runStage(env.AIMET_ZOO_VARIANT_TF_CPU, "-bp") | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
stage('Code violations') { | ||
steps { | ||
echo 'Running code violations...' | ||
script { | ||
runStage(env.AIMET_ZOO_VARIANT_TF_CPU, "-v") | ||
} | ||
} | ||
post { | ||
always { | ||
step([ | ||
$class : 'WarningsPublisher', | ||
parserConfigurations : [[ | ||
parserName: 'PYLint', | ||
pattern : "**/**/**/*pylint_results.out" | ||
]], | ||
failedTotalHigh : THRESHOLD_OBJ.pylint_fail_thresholds.high_priority, | ||
failedTotalNormal : THRESHOLD_OBJ.pylint_fail_thresholds.normal_priority, | ||
failedTotalLow : THRESHOLD_OBJ.pylint_fail_thresholds.low_priority, | ||
usePreviousBuildAsReference : true | ||
]) | ||
script { | ||
if (currentBuild.currentResult.equals("FAILURE")) { | ||
// the plugin won't fail the stage. it only sets the build status, so we have to fail it | ||
// manually | ||
sh "exit 1" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} // stages | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
script { | ||
if (currentBuild.currentResult.equals("SUCCESS")) { | ||
echo 'Finished pull request Jenkins file' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
def runStage(AIMET_ZOO_VARIANT, options) { | ||
|
||
echo "*** Running stage ${options} for ${AIMET_ZOO_VARIANT} variant on ${env.NODE_NAME} in workspace ${env.WORKSPACE_ROOT} ***" | ||
|
||
def changedFiles = pullRequest.files.collect { | ||
it.getFilename() | ||
} | ||
print changedFiles | ||
if (!changedFiles.contains("Jenkins/Dockerfile.${AIMET_ZOO_VARIANT}".toString())) { | ||
print "Jenkins/Dockerfile.${AIMET_ZOO_VARIANT} not found in changed file list, so using Linaro Docker image for ${AIMET_ZOO_VARIANT}" | ||
} | ||
sh """ | ||
AIMET_ZOO_VARIANT=${AIMET_ZOO_VARIANT} bash -l -c "cd ${REPO_NAME} && ./Jenkins/buildntest.sh -e AIMET_ZOO_VARIANT ${options} ${env.USE_LINARO} ${env.PREBUILT_DOCKER_IMAGE_URL}" | ||
""" | ||
} |
Oops, something went wrong.