-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PyTorch GPT2 model, packaging mechanism, pylint cleanup, model refact…
…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
1 parent
0794ad3
commit 538ba16
Showing
388 changed files
with
36,200 additions
and
7,909 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 |
---|---|---|
|
@@ -11,3 +11,9 @@ | |
|
||
# Jupyter notebooks | ||
.ipynb_checkpoints/ | ||
|
||
# Generated artifacts | ||
*.bak* | ||
*.whl | ||
*.egg-info/ | ||
build/ |
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,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) |
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
Oops, something went wrong.