forked from apple/corenet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
sachinmehta
committed
Apr 23, 2024
0 parents
commit 9effa1d
Showing
723 changed files
with
91,756 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,50 @@ | ||
# Docker-specific: | ||
**/Dockerfile | ||
setup_bolt.sh | ||
.git | ||
.gitignore | ||
.dockerignore | ||
|
||
# Mirroring .gitignore | ||
# Note: dockerignore matches paths only from the root dir, while gitignore matches | ||
# paths from any nested directory. Thus, you'll need to add **/<path> for some paths. | ||
.vscode/ | ||
.coverage | ||
*.pyc | ||
**/*.pyc | ||
__pycache__ | ||
**/__pycache__ | ||
.DS_STORE | ||
**/.DS_STORE | ||
.idea | ||
|
||
*.swp | ||
.pytest_cache | ||
.mypy_cache | ||
.corenet_data_cache | ||
|
||
build/ | ||
|
||
results* | ||
vision_datasets/ | ||
exp_results/ | ||
exp_results* | ||
results_* | ||
|
||
*.so | ||
**/*.so | ||
model_zoo | ||
model_zoo/* | ||
pipeline.yaml | ||
|
||
*.egg-info | ||
**/*.egg-info | ||
|
||
venv/ | ||
|
||
trash/ | ||
mlx_model/ | ||
.tox/ | ||
|
||
# The playground_* files get generated by tutorials/train_new_model_on_new_dataset_from_scratch.ipynb | ||
**/playground_* |
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,3 @@ | ||
[flake8] | ||
max-line-length = 88 | ||
extend-ignore = E203 |
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,22 @@ | ||
*.tar filter=lfs diff=lfs merge=lfs -text | ||
*.gz filter=lfs diff=lfs merge=lfs -text | ||
*.zip filter=lfs diff=lfs merge=lfs -text | ||
*.zst filter=lfs diff=lfs merge=lfs -text | ||
*.zstd filter=lfs diff=lfs merge=lfs -text | ||
*.ipynb filter=lfs diff=lfs merge=lfs -text | ||
*.png filter=lfs diff=lfs merge=lfs -text | ||
*.jpeg filter=lfs diff=lfs merge=lfs -text | ||
*.jpg filter=lfs diff=lfs merge=lfs -text | ||
*.whl filter=lfs diff=lfs merge=lfs -text | ||
*.npy filter=lfs diff=lfs merge=lfs -text | ||
*.npz filter=lfs diff=lfs merge=lfs -text | ||
*.pt filter=lfs diff=lfs merge=lfs -text | ||
*.mov filter=lfs diff=lfs merge=lfs -text | ||
*.mp4 filter=lfs diff=lfs merge=lfs -text | ||
*.pdf filter=lfs diff=lfs merge=lfs -text | ||
*.tif filter=lfs diff=lfs merge=lfs -text | ||
*.tiff filter=lfs diff=lfs merge=lfs -text | ||
*.model filter=lfs diff=lfs merge=lfs -text | ||
*.parquet filter=lfs diff=lfs merge=lfs -text | ||
*.pkl filter=lfs diff=lfs merge=lfs -text | ||
*.safetensors filter=lfs diff=lfs merge=lfs -text |
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,37 @@ | ||
# Note: please mirror changes of this file to .dockerignore. | ||
|
||
.vscode/ | ||
.coverage | ||
*.pyc | ||
__pycache__ | ||
.DS_STORE | ||
.idea | ||
*.swp | ||
.pytest_cache | ||
.mypy_cache | ||
.corenet_data_cache | ||
|
||
build/ | ||
|
||
/results* | ||
vision_datasets/ | ||
exp_results/ | ||
exp_results* | ||
results_* | ||
|
||
*.so | ||
model_zoo | ||
model_zoo/* | ||
pipeline.yaml | ||
|
||
*.egg-info | ||
|
||
venv/ | ||
|
||
trash | ||
|
||
mlx_model/ | ||
.tox/ | ||
|
||
# The playground_* files get generated by tutorials/train_new_model_on_new_dataset_from_scratch.ipynb | ||
playground_* |
Large diffs are not rendered by default.
Oops, something went wrong.
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,71 @@ | ||
# Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as | ||
contributors and maintainers pledge to making participation in our project and | ||
our community a harassment-free experience for everyone, regardless of age, body | ||
size, disability, ethnicity, sex characteristics, gender identity and expression, | ||
level of experience, education, socio-economic status, nationality, personal | ||
appearance, race, religion, or sexual identity and orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment | ||
include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or | ||
advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic | ||
address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a | ||
professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable | ||
behavior and are expected to take appropriate and fair corrective action in | ||
response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or | ||
reject comments, commits, code, wiki edits, issues, and other contributions | ||
that are not aligned to this Code of Conduct, or to ban temporarily or | ||
permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies within all project spaces, and it also applies when | ||
an individual is representing the project or its community in public spaces. | ||
Examples of representing a project or community include using an official | ||
project e-mail address, posting via an official social media account, or acting | ||
as an appointed representative at an online or offline event. Representation of | ||
a project may be further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting the open source team at [[email protected]](mailto:[email protected]). All | ||
complaints will be reviewed and investigated and will result in a response that | ||
is deemed necessary and appropriate to the circumstances. The project team is | ||
obligated to maintain confidentiality with regard to the reporter of an incident. | ||
Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good | ||
faith may face temporary or permanent repercussions as determined by other | ||
members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4, | ||
available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html) |
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,11 @@ | ||
# Contribution Guide | ||
|
||
Thanks for your interest in contributing. This project was released to accompany a research paper for purposes of reproducability, and beyond its publication there are limited plans for future development of the repository. | ||
|
||
While we welcome new pull requests and issues please note that our response may be limited. Forks and out-of-tree improvements are strongly encouraged. | ||
|
||
## Before you get started | ||
|
||
By submitting a pull request, you represent that you have the right to license your contribution to Apple and the community, and agree by submitting the patch that your contributions are licensed under the [LICENSE](LICENSE). | ||
|
||
We ask that all community members read and observe our [Code of Conduct](CODE_OF_CONDUCT.md). |
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,47 @@ | ||
Copyright (C) 2024 Apple Inc. All Rights Reserved. | ||
|
||
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple | ||
Inc. ("Apple") in consideration of your agreement to the following | ||
terms, and your use, installation, modification or redistribution of | ||
this Apple software constitutes acceptance of these terms. If you do | ||
not agree with these terms, please do not use, install, modify or | ||
redistribute this Apple software. | ||
|
||
In consideration of your agreement to abide by the following terms, and | ||
subject to these terms, Apple grants you a personal, non-exclusive | ||
license, under Apple's copyrights in this original Apple software (the | ||
"Apple Software"), to use, reproduce, modify and redistribute the Apple | ||
Software, with or without modifications, in source and/or binary forms; | ||
provided that if you redistribute the Apple Software in its entirety and | ||
without modifications, you must retain this notice and the following | ||
text and disclaimers in all such redistributions of the Apple Software. | ||
Neither the name, trademarks, service marks or logos of Apple Inc. may | ||
be used to endorse or promote products derived from the Apple Software | ||
without specific prior written permission from Apple. Except as | ||
expressly stated in this notice, no other rights or licenses, express or | ||
implied, are granted by Apple herein, including but not limited to any | ||
patent rights that may be infringed by your derivative works or by other | ||
works in which the Apple Software may be incorporated. | ||
|
||
The Apple Software is provided by Apple on an "AS IS" basis. APPLE | ||
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION | ||
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS | ||
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND | ||
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. | ||
|
||
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL | ||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, | ||
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED | ||
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), | ||
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
|
||
|
||
------------------------------------------------------------------------------- | ||
SOFTWARE DISTRIBUTED IN THIS REPOSITORY: | ||
|
||
This software includes a number of subcomponents with separate | ||
copyright notices and license terms - please see the file ACKNOWLEDGEMENTS. | ||
------------------------------------------------------------------------------- |
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,148 @@ | ||
SHELL := /bin/bash | ||
YEAR = $$(date +%Y) | ||
LAST_YEAR = $$(($(YEAR) - 1)) | ||
COLOR_LOG = \033[34m | ||
COLOR_INFO = \033[32m | ||
COLOR_WARNING = \033[33m | ||
COLOR_ERROR = \033[31m | ||
COLOR_END = \033[0m | ||
|
||
SRC_DIRS = corenet tests | ||
|
||
.PHONY: format install-githooks prepush-check update-copyright-year | ||
|
||
update-copyright-year: | ||
@if [[ "$$CHECK_ONLY" == "" ]]; then \ | ||
if ! command -v rg &>/dev/null; then \ | ||
printf "$(COLOR_INFO)Installing ripgrep ...$(COLOR_END)\n"; \ | ||
if [[ "$$OSTYPE" == "darwin"* ]]; then \ | ||
brew install ripgrep; \ | ||
else \ | ||
sudo --preserve-env apt-get install ripgrep; \ | ||
fi; \ | ||
fi; \ | ||
rg -l "\(C\) $(LAST_YEAR)" \ | ||
| grep -v "ACKNOWLEDGEMENTS" \ | ||
| xargs -r -n1 -P 10 sed -i.bak.copyright "s/(C) $(LAST_YEAR) Apple/(C) $(YEAR) Apple/g" \ | ||
&& find . -name '*.bak.copyright' \ | ||
| xargs -r -n1 -P 10 rm; \ | ||
fi | ||
|
||
format: format-init-files format-license-headers format-eof-new-lines format-isort format-black format-conventions | ||
# Formatting checks succeeded. | ||
|
||
# The existence of __init__.py files is necessary for the inclusion of packages in the setup.py (i.e. pip-instsallable) package. | ||
format-init-files: | ||
# Checking missing __init__.py files... | ||
@python_files=$$(find $(SRC_DIRS) -iname "*.py"); \ | ||
for dir_name in $$(find $(SRC_DIRS) -type d -not -name __pycache__); do \ | ||
grep -q "^$$dir_name/" <(echo "$$python_files") || continue; \ | ||
init_file="$$dir_name/__init__.py"; \ | ||
[[ -f "$$init_file" ]] && continue; \ | ||
if [[ "$$CHECK_ONLY" == "1" ]]; then \ | ||
printf "$(COLOR_ERROR)Missing $$init_file. $(COLOR_END)\n"; \ | ||
else \ | ||
touch "$$init_file"; \ | ||
printf "$(COLOR_LOG)Added $$init_file. $(COLOR_END)\n"; \ | ||
fi \ | ||
done | ||
|
||
format-license-headers: update-copyright-year | ||
# Checking missing license headers files... | ||
# Read the first 4 lines of each file to check if the Copyright notice header exists. | ||
# The Copyright note is usually found on line 3, but some files may have an additional | ||
# '#/bin/bash' or '#/usr/bin/env python' header line, hence reading 3+1 lines. | ||
@for f in $$(find . -iname "*.py"); do \ | ||
[ -s "$$f" ] || continue; \ | ||
git check-ignore -q "$$f" && continue; \ | ||
export COPYRIGHT_NOTICE_LINES=4; \ | ||
(head -$$COPYRIGHT_NOTICE_LINES $$f | grep -q "# *Copyright (C) $(YEAR) Apple Inc. All Rights Reserved.") && continue; \ | ||
[[ "$$CHECK_ONLY" == "1" ]] && exit 1; \ | ||
sed -i '' -e "1s/^/#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) $(YEAR) Apple Inc. All Rights Reserved.\n#\n\n/" $$f; \ | ||
printf "$(COLOR_LOG)Added license header for $$f$(COLOR_END)\n"; \ | ||
done | ||
|
||
format-eof-new-lines: | ||
# Ensure newline at the end of all files... | ||
# Inspired by https://unix.stackexchange.com/a/161853/55814 | ||
@if [[ "$$CHECK_ONLY" == "" ]]; then \ | ||
git ls-files -z | while IFS= read -rd '' f; do \ | ||
if [[ -f "$$f" ]] && (file --mime-encoding "$$f" | grep -qv binary); then \ | ||
tail -c1 < "$$f" | read -r _ || (echo >> "$$f" && printf "$(COLOR_LOG) Added newline at the end of $$f$(COLOR_END)\n"); \ | ||
fi; \ | ||
done; \ | ||
fi | ||
|
||
format-isort: | ||
# Running isort... | ||
@if [[ "$$CHECK_ONLY" == "1" ]]; then \ | ||
isort --check-only .; \ | ||
else \ | ||
isort .; \ | ||
fi | ||
|
||
format-black: | ||
# Running black formatter... | ||
@if [[ "$$CHECK_ONLY" == "1" ]]; then \ | ||
black --check .; \ | ||
else \ | ||
black .; \ | ||
fi | ||
|
||
format-conventions: | ||
@if [[ "$$CHECK_ONLY" == "1" ]]; then \ | ||
echo "# Checking coding conventions..."; \ | ||
convention_test_files=(tests/test_conventions.py); \ | ||
[[ -d tests/internal ]] && convention_test_files+=(tests/internal/test_internal_conventions.py); \ | ||
export _parallel_args="$$( (python -c "import xdist.plugin" 2>/dev/null && echo '-n 4') || true)"; \ | ||
if ! pytest --junit-xml="" -q "$${convention_test_files[@]}" $$_parallel_args; then \ | ||
printf "$(COLOR_ERROR) Please manually fix the above convention errors. $(COLOR_END)\n"; \ | ||
exit 1; \ | ||
fi; \ | ||
fi | ||
|
||
|
||
prepush-check: | ||
@printf "$(COLOR_LOG)[pre-push hook]$(COLOR_END)\n" | ||
@CHECK_ONLY=1 make format || (printf "$(COLOR_ERROR)Formatting checks failed.$(COLOR_END) Please run '$(COLOR_INFO)make format$(COLOR_END)' command, commit, and push again.\n" && exit 1); | ||
@if [ -n "$$(git status --porcelain)" ]; then \ | ||
printf "$(COLOR_WARNING)Formatting checks succeeded, but please consider committing UNCOMMITTED changes to the following files:$(COLOR_END)\n"; \ | ||
git status --short; \ | ||
else \ | ||
printf "$(COLOR_INFO)Formatting checks succeeded.$(COLOR_END)\n"; \ | ||
fi | ||
|
||
install-githooks: | ||
@echo -e "#!/usr/bin/env bash\n" '\ | ||
set -euo pipefail\n\ | ||
# Check if Git LFS is installed\n\ | ||
if ! command -v git-lfs >/dev/null 2>&1; then\n\ | ||
echo >&2 "Error: Git LFS is not installed. Please install Git LFS to continue."\n\ | ||
exit 1\n\ | ||
fi\n\ | ||
\n\ | ||
git lfs pre-push "$$@"\n\n\ | ||
printf "$(COLOR_LOG)[pre-push hook]$(COLOR_END) Running formatting checks and fixes... To skip this hook, please run \"git push --no-verify\".\\n";\n\ | ||
if grep -q "^prepush-check:" Makefile 2>/dev/null; then\n\ | ||
make prepush-check;\n\ | ||
else\n\ | ||
printf "$(COLOR_WARNING)WARNING:$(COLOR_END) Skipping the pre-push formatting checks and fixes. The git hook is installed (probably on a different git branch), but Makefile is either missing or old on this branch.\\n";\n\ | ||
fi \ | ||
' > "$$(git rev-parse --git-path hooks)/pre-push" | ||
chmod +x "$$(git rev-parse --git-path hooks)/pre-push" | ||
# Successfully installed the pre-push hook. | ||
|
||
test-all: | ||
## | ||
# Notes: | ||
# * Run all tests and set OMP/MKL threads 1 to allow pytest parallelization | ||
# * The number of parallel tests will be 10 by default, which is good for running tests | ||
# locally. Larger numbers may cause OOM error. If PYTEST_WORKERS environment variable | ||
# is already set, the existing value gets used. | ||
# * Currently, our tests fail when DDP is enabled. Hence, we set disable gpus for test | ||
# by setting CUDA_VISIBLE_DEVICES="". | ||
## | ||
PYTEST_WORKERS="$${PYTEST_WORKERS:=10}"; CUDA_VISIBLE_DEVICES="" MKL_NUM_THREADS=1 NUMEXPR_NUM_THREADS=1 OMP_NUM_THREADS=1 pytest . -n $$PYTEST_WORKERS $(extra_args) | ||
|
||
coverage-test-all: | ||
PYTEST_WORKERS="$${PYTEST_WORKERS:=10}"; CUDA_VISIBLE_DEVICES="" MKL_NUM_THREADS=1 NUMEXPR_NUM_THREADS=1 OMP_NUM_THREADS=1 coverage run -m pytest . -n $$PYTEST_WORKERS $(extra_args) |
Oops, something went wrong.