pax_global_header 0000666 0000000 0000000 00000000064 14103743654 0014521 g ustar 00root root 0000000 0000000 52 comment=dc8b4878d21f96c205aae0360f0a08500057e000
eagerpy-0.30.0/ 0000775 0000000 0000000 00000000000 14103743654 0013235 5 ustar 00root root 0000000 0000000 eagerpy-0.30.0/.github/ 0000775 0000000 0000000 00000000000 14103743654 0014575 5 ustar 00root root 0000000 0000000 eagerpy-0.30.0/.github/FUNDING.yml 0000664 0000000 0000000 00000001133 14103743654 0016410 0 ustar 00root root 0000000 0000000 # These are supported funding model platforms
# github: [jonasrauber]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ["paypal.me/jonasrauber"]
eagerpy-0.30.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14103743654 0016632 5 ustar 00root root 0000000 0000000 eagerpy-0.30.0/.github/workflows/docs.yml 0000664 0000000 0000000 00000001276 14103743654 0020313 0 ustar 00root root 0000000 0000000 name: Docs
on:
push:
branches:
- master
jobs:
vuepress:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install vuepress
run: |
sudo apt update
sudo apt install yarn
sudo yarn global add vuepress
- name: Build
run: |
sudo vuepress build
working-directory: ./docs
- name: Push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sudo git init
sudo git add -A
sudo git commit -m 'deploy'
sudo git push -f https://x-access-token:${GITHUB_TOKEN}@github.com/jonasrauber/eagerpy.git master:gh-pages
working-directory: ./docs/.vuepress/dist
eagerpy-0.30.0/.github/workflows/pypi.yml 0000664 0000000 0000000 00000001132 14103743654 0020333 0 ustar 00root root 0000000 0000000 name: PyPI
on:
release:
types: [created]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.6'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
eagerpy-0.30.0/.github/workflows/tests.yml 0000664 0000000 0000000 00000004560 14103743654 0020524 0 ustar 00root root 0000000 0000000 name: Tests
on:
push:
branches:
- master
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.6, 3.7]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install requirements-dev.txt
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements-dev.txt
- name: flake8
run: |
flake8 . --count --show-source --statistics
- name: black
run: |
black --check --verbose .
- name: Install package
run: |
pip install -e .
- name: Install requirements.txt
run: |
function retry-with-backoff() {
for BACKOFF in 0 1 2 4 8 16 32 64; do
sleep $BACKOFF
if "$@"; then
return 0
fi
done
return 1
}
retry-with-backoff pip install -r requirements.txt
- name: mypy (package)
run: |
mypy -p eagerpy
- name: mypy (tests)
run: |
mypy tests/
- name: Test with pytest
run: |
pytest --cov-report term-missing --cov=eagerpy --verbose
- name: Test with pytest (NumPy)
run: |
pytest --cov-report term-missing --cov=eagerpy --cov-append --verbose --backend numpy
- name: Test with pytest (PyTorch)
run: |
pytest --cov-report term-missing --cov=eagerpy --cov-append --verbose --backend pytorch
- name: Test with pytest (JAX)
run: |
pytest --cov-report term-missing --cov=eagerpy --cov-append --verbose --backend jax
- name: Test with pytest (TensorFlow)
run: |
pytest --cov-report term-missing --cov=eagerpy --cov-append --verbose --backend tensorflow
- name: Codecov
continue-on-error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
codecov
- name: Coveralls
continue-on-error: true
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
coveralls
eagerpy-0.30.0/.gitignore 0000664 0000000 0000000 00000004304 14103743654 0015226 0 ustar 00root root 0000000 0000000 .mypy_cache
.pytest_cache/
# Created by https://www.gitignore.io/api/osx,vim,linux,python
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### OSX ###
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
### Vim ###
# swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# session
Session.vim
# temporary
.netrwhist
# auto-generated tag files
tags
# PyCharm
.idea/
# Visual Studio Code
.vscode/
# End of https://www.gitignore.io/api/osx,vim,linux,python
eagerpy-0.30.0/.pre-commit-config.yaml 0000664 0000000 0000000 00000000300 14103743654 0017507 0 ustar 00root root 0000000 0000000 repos:
- repo: https://github.com/ambv/black
rev: 19.10b0
hooks:
- id: black
language_version: python3.6
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
eagerpy-0.30.0/LICENSE 0000664 0000000 0000000 00000002055 14103743654 0014244 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2020 Jonas Rauber
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
eagerpy-0.30.0/MANIFEST.in 0000664 0000000 0000000 00000000101 14103743654 0014763 0 ustar 00root root 0000000 0000000 include eagerpy/VERSION
include eagerpy/py.typed
include LICENSE
eagerpy-0.30.0/Makefile 0000664 0000000 0000000 00000003717 14103743654 0014705 0 ustar 00root root 0000000 0000000 .PHONY: test
test:
pytest --pdb --cov-report term-missing --cov=eagerpy --verbose
pytest --pdb --cov-report term-missing --cov=eagerpy --cov-append --verbose --backend numpy
pytest --pdb --cov-report term-missing --cov=eagerpy --cov-append --verbose --backend pytorch
pytest --pdb --cov-report term-missing --cov=eagerpy --cov-append --verbose --backend jax
pytest --pdb --cov-report term-missing --cov=eagerpy --cov-append --verbose --backend tensorflow
pytest --pdb --cov-report term-missing --cov=eagerpy --cov-append --verbose --backend pytorch-gpu
.PHONY: black
black:
black .
.PHONY: blackcheck
blackcheck:
black --check .
.PHONY: flake8
flake8:
flake8
.PHONY: mypy
mypy:
mypy -p eagerpy
mypy tests/
.PHONY: docs
docs:
pydocmd generate
cd docs && vuepress build --temp /tmp/
.PHONY: installvuepress
installvuepress:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
sudo yarn global add vuepress
.PHONY: servedocs
servedocs:
cd docs/.vuepress/dist/ && python3 -m http.server 9999
.PHONY: devdocs
devdocs:
cd docs && vuepress dev --temp /tmp/ --port 9999
.PHONY: pushdocs
pushdocs:
cd docs/.vuepress/dist/ && git init && git add -A && git commit -m 'deploy'
cd docs/.vuepress/dist/ && git push -f git@github.com:jonasrauber/eagerpy.git master:gh-pages
.PHONY: install
install:
pip3 install -e .
.PHONY: devsetup
devsetup:
pre-commit install
.PHONY: build
build:
python3 setup.py sdist
.PHONY: commit
commit:
git add eagerpy/VERSION
git commit -m 'Version $(shell cat eagerpy/VERSION)'
.PHONY: release
release: build
twine upload dist/eagerpy-$(shell cat eagerpy/VERSION).tar.gz
.PHONY: pyre
pyre:
pyre --source-directory . check
.PHONY: pytype
pytype:
pytype .
.PHONY: pyright
pyright:
pyright .
.PHONY: mypyreport
mypyreport:
-mypy . --html-report build
python3 -m http.server 9999
eagerpy-0.30.0/README.rst 0000664 0000000 0000000 00000011135 14103743654 0014725 0 ustar 00root root 0000000 0000000 .. raw:: html
.. image:: https://badge.fury.io/py/eagerpy.svg
:target: https://badge.fury.io/py/eagerpy
.. image:: https://codecov.io/gh/jonasrauber/eagerpy/branch/master/graph/badge.svg
:target: https://codecov.io/gh/jonasrauber/eagerpy
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/ambv/black
==================================================================================
EagerPy: Writing Code That Works Natively with PyTorch, TensorFlow, JAX, and NumPy
==================================================================================
`EagerPy `_ is a **Python framework** that lets you write code that automatically works natively with `PyTorch `_, `TensorFlow `_, `JAX `_, and `NumPy `_. EagerPy is **also great when you work with just one framework** but prefer a clean and consistent API that is fully chainable, provides extensive type annotions and lets you write beautiful code.
🔥 Design goals
----------------
- **Native Performance**: EagerPy operations get directly translated into the corresponding native operations.
- **Fully Chainable**: All functionality is available as methods on the tensor objects and as EagerPy functions.
- **Type Checking**: Catch bugs before running your code thanks to EagerPy's extensive type annotations.
📖 Documentation
-----------------
Learn more about EagerPy in the `documentation `_.
🚀 Quickstart
--------------
.. code-block:: bash
pip install eagerpy
EagerPy requires Python 3.6 or newer. Besides that, all essential dependencies are automatically installed. To use it with PyTorch, TensorFlow, JAX, or NumPy, the respective framework needs to be installed separately. These frameworks are not declared as dependencies because not everyone wants to use and thus install all of them and because some of these packages have different builds for different architectures and `CUDA `_ versions.
🎉 Example
-----------
.. code-block:: python
import torch
x = torch.tensor([1., 2., 3., 4., 5., 6.])
import tensorflow as tf
x = tf.constant([1., 2., 3., 4., 5., 6.])
import jax.numpy as np
x = np.array([1., 2., 3., 4., 5., 6.])
import numpy as np
x = np.array([1., 2., 3., 4., 5., 6.])
# No matter which framwork you use, you can use the same code
import eagerpy as ep
# Just wrap a native tensor using EagerPy
x = ep.astensor(x)
# All of EagerPy's functionality is available as methods
x = x.reshape((2, 3))
x.flatten(start=1).square().sum(axis=-1).sqrt()
# or just: x.flatten(1).norms.l2()
# and as functions (yes, gradients are also supported!)
loss, grad = ep.value_and_grad(loss_fn, x)
ep.clip(x + eps * grad, 0, 1)
# You can even write functions that work transparently with
# Pytorch tensors, TensorFlow tensors, JAX arrays, NumPy arrays
def my_universal_function(a, b, c):
# Convert all inputs to EagerPy tensors
a, b, c = ep.astensors(a, b, c)
# performs some computations
result = (a + b * c).square()
# and return a native tensor
return result.raw
🗺 Use cases
------------
`Foolbox Native `_, the latest version of
Foolbox, a popular adversarial attacks library, has been rewritten from scratch
using EagerPy instead of NumPy to achieve native performance on models
developed in PyTorch, TensorFlow and JAX, all with one code base.
EagerPy is also used by other frameworks to reduce code duplication (e.g. `GUDHI `_) or to `compare the performance of different frameworks `_.
📄 Citation
------------
If you use EagerPy, please cite our `paper `_ using the this BibTex entry:
.. code-block::
@article{rauber2020eagerpy,
title={{EagerPy}: Writing Code That Works Natively with {PyTorch}, {TensorFlow}, {JAX}, and {NumPy}},
author={Rauber, Jonas and Bethge, Matthias and Brendel, Wieland},
journal={arXiv preprint arXiv:2008.04175},
year={2020},
url={https://eagerpy.jonasrauber.de},
}
🐍 Compatibility
-----------------
We currently test with the following versions:
* PyTorch 1.4.0
* TensorFlow 2.1.0
* JAX 0.1.57
* NumPy 1.18.1
eagerpy-0.30.0/docs/ 0000775 0000000 0000000 00000000000 14103743654 0014165 5 ustar 00root root 0000000 0000000 eagerpy-0.30.0/docs/.vuepress/ 0000775 0000000 0000000 00000000000 14103743654 0016117 5 ustar 00root root 0000000 0000000 eagerpy-0.30.0/docs/.vuepress/config.js 0000664 0000000 0000000 00000001600 14103743654 0017717 0 ustar 00root root 0000000 0000000 module.exports = {
title: 'EagerPy',
description: 'A unified API for PyTorch, TensorFlow, JAX and NumPy',
themeConfig: {
nav: [
{ text: 'Guide', link: '/guide/' },
{ text: 'API', link: '/api/' },
{ text: 'GitHub', link: 'https://github.com/jonasrauber/eagerpy' }
],
sidebar: [
{
title: 'Guide',
collapsable: false,
children: [
'/guide/',
'/guide/getting-started',
'/guide/converting',
'/guide/generic-functions',
'/guide/autodiff',
'/guide/examples',
'/guide/development',
'/guide/citation',
],
},
{
title: 'API',
collapsable: false,
children: [
'/api/',
['/api/tensor', 'Tensor'],
'/api/lib',
'/api/norms',
'/api/types',
],
},
],
},
}
eagerpy-0.30.0/docs/.vuepress/public/ 0000775 0000000 0000000 00000000000 14103743654 0017375 5 ustar 00root root 0000000 0000000 eagerpy-0.30.0/docs/.vuepress/public/CNAME 0000664 0000000 0000000 00000000026 14103743654 0020141 0 ustar 00root root 0000000 0000000 eagerpy.jonasrauber.de eagerpy-0.30.0/docs/.vuepress/public/logo.png 0000664 0000000 0000000 00000024123 14103743654 0021045 0 ustar 00root root 0000000 0000000 PNG
IHDR ڴS aiCCPkCGColorSpaceDisplayP3 (c``RI,(aa``+)
rwRR`b
>@%0|/:%5I^bՋD0գ d SJSl):
ȞbC@$XMH3}VHHIBOGbCnₜJ c%VhʢG`(*x%(30s 8, Ě30n~@\;b'v$%)-rH@=iF`yF'{Vc``ww1Py !e5 DeXIfMM * i &