Skip to content

Commit

Permalink
PyTorch GPT2 model, packaging mechanism, pylint cleanup, model refact…
Browse files Browse the repository at this point in the history
…oring updates

- Cleaned up code to minimize errors from static analysis (pylint)
- Model refactoring and code updates for 7 models (DeepLabV3, EfficientNetLite0, MobileNetV2, QuickSRNet, FFNet, Inverseform, SSD-MobileNetV2)
- Adding package generation capability via cmake and TOML
- Releasing first package release of aimet model zoo (installable wheel file binaries)
- Added code, documentation and artifacts the PyTorch GPT2 models

Signed-off-by: Bharath Ramaswamy <[email protected]>
  • Loading branch information
quic-bharathr committed Jan 25, 2023
1 parent 0794ad3 commit 538ba16
Show file tree
Hide file tree
Showing 388 changed files with 36,200 additions and 7,909 deletions.
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ else
fi

echo "Running Pylint - using $prj_root/.pylintrc"
export PYTHONPATH=$prj_root/zoo_tensorflow:$prj_root/zoo_torch
export PYTHONPATH=$prj_root/aimet_zoo_tensorflow:$prj_root/aimet_zoo_torch
# Verify that each of the source path directories exist
for path in ${PYTHONPATH//:/ }; do
if [[ ! -d $path ]]; then
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@

# Jupyter notebooks
.ipynb_checkpoints/

# Generated artifacts
*.bak*
*.whl
*.egg-info/
build/
132 changes: 132 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# =============================================================================
# @@-COPYRIGHT-START-@@
#
# Copyright (c) 2023 of Qualcomm Innovation Center, Inc. All rights reserved.
#
# @@-COPYRIGHT-END-@@
# =============================================================================

cmake_minimum_required(VERSION 3.17)

project(aimet-model-zoo)

# Set the software version from version.txt file (if not already set)
if(NOT DEFINED SW_VERSION)
file(STRINGS "packaging/version.txt" SW_VERSION)
message(STATUS "Set SW_VERSION = ${SW_VERSION} from ${CMAKE_CURRENT_SOURCE_DIR}/packaging/version.txt")
else()
message(STATUS "SW_VERSION already set to ${SW_VERSION}.")
endif()

# Set the deployment paths
set(ZOO_INSTALL_DIR "${CMAKE_BINARY_DIR}/staging")

# ----------------------------------
# Conditional build for TensorFlow
# ----------------------------------
if (NOT (DEFINED ENABLE_TENSORFLOW))
message("AIMET Model Zoo TensorFlow build not explicitly disabled. Enabling implicitly")
set(ENABLE_TENSORFLOW ON CACHE BOOL "")
endif(NOT (DEFINED ENABLE_TENSORFLOW))

if (ENABLE_TENSORFLOW)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/aimet_zoo_tensorflow
DESTINATION ${ZOO_INSTALL_DIR}
PATTERN "__pycache*" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
PATTERN "*.egg-info" EXCLUDE
)
else (ENABLE_TENSORFLOW)
message("AIMET TensorFlow build disabled")
endif (ENABLE_TENSORFLOW)


# ----------------------------------
# Conditional build for PyTorch
# ----------------------------------
if (NOT (DEFINED ENABLE_TORCH))
message("AIMET Model Zoo TensorFlow build not explicitly disabled. Enabling implicitly")
set(ENABLE_TORCH ON CACHE BOOL "")
endif(NOT (DEFINED ENABLE_TORCH))

if (ENABLE_TORCH)
# Install the source directories
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/aimet_zoo_torch
DESTINATION ${ZOO_INSTALL_DIR}
PATTERN "__pycache*" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
PATTERN "*.egg-info" EXCLUDE
)

else (ENABLE_TORCH)
message("AIMET PyTorch build disabled")
endif (ENABLE_TORCH)


# -------------------------------
# Generate pip packages
# -------------------------------

# Set the packaging path (if not already set)
if(NOT DEFINED AIMET_PACKAGE_PATH)
set(AIMET_PACKAGE_PATH "\"${ZOO_INSTALL_DIR}\"")
message(STATUS "Set AIMET_PACKAGE_PATH = ${AIMET_PACKAGE_PATH}")
endif(NOT DEFINED AIMET_PACKAGE_PATH)

add_custom_target(packagemodelzoo
# Run the install target first
COMMAND "${CMAKE_COMMAND}" --build . --target install

# Now run the packaging target to generate wheel files
COMMAND ${CMAKE_COMMAND} -DAIMET_PACKAGE_PATH=${AIMET_PACKAGE_PATH} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DENABLE_TENSORFLOW=${ENABLE_TENSORFLOW} -DENABLE_TORCH=${ENABLE_TORCH} -DSW_VERSION=${SW_VERSION} -DPROJECT_NAME=${CMAKE_PROJECT_NAME} -P ${CMAKE_CURRENT_SOURCE_DIR}/packaging/package_model_zoo.cmake
)


# -------------------------------
# Deployment
# -------------------------------

# Check the deployment path and set it to a default value (if not set)
if(NOT DEFINED DEPLOYMENT_PATH)
set(DEPLOYMENT_PATH "./deploy")
message(WARNING "DEPLOYMENT_PATH was not specified. Setting it to ${DEPLOYMENT_PATH}.")
else()
message(STATUS "DEPLOYMENT_PATH already set to ${DEPLOYMENT_PATH}.")
endif()

add_custom_target(deploy)

set(build_packaging_dir "${CMAKE_BINARY_DIR}/packaging")
file(GLOB package_tar_file "${build_packaging_dir}/*.tar.gz")
add_custom_command(TARGET deploy
COMMAND test -d ${DEPLOYMENT_PATH} || echo "Deployment directory ${DEPLOYMENT_PATH} does NOT exist. Creating..."
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPLOYMENT_PATH}
COMMAND ${CMAKE_COMMAND} -E copy ${package_tar_file} ${DEPLOYMENT_PATH}
)

# -------------------------------
# Upload pip packages
# -------------------------------

# Check the pip config file path and set it to a default value (if not set)
if(NOT DEFINED PIP_CONFIG_FILE)
set(PIP_CONFIG_FILE "None")
endif()

# Check the pip index name and set it to a default value (if not set)
if(NOT DEFINED PIP_INDEX)
set(PIP_INDEX "None")
endif()

# Check the pip certificate path and set it to a default value (if not set)
if(NOT DEFINED PIP_CERT_FILE)
set(PIP_CERT_FILE "None")
endif()

#TODO For some reason, this package upload target does NOT work as expected and needs to be debugged
add_custom_target(upload
# Now run the packaging target to upload the pip package
COMMAND ${CMAKE_COMMAND} -DPIP_CONFIG_FILE=${PIP_CONFIG_FILE} -DPIP_INDEX=${PIP_INDEX} -DPIP_CERT_FILE=${PIP_CERT_FILE} -P ${CMAKE_CURRENT_SOURCE_DIR}/packaging/upload_model_zoo.cmake
)

add_dependencies(upload packagemodelzoo)
66 changes: 66 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,69 @@ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-------------------------------------------------------------------------------

Copyright 2018 Tramac (github.com/Tramac)

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.

-------------------------------------------------------------------------------

Copyright 2018 Ji Lin (github.com/tonylins)

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.

-------------------------------------------------------------------------------

BSD 3-Clause License

Copyright (c) Soumith Chintala 2016,
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
Loading

0 comments on commit 538ba16

Please sign in to comment.