Skip to content

Commit

Permalink
Merge branch 'oneflow_dev' of https://github.com/QuantumLiu/TensorLayerX
Browse files Browse the repository at this point in the history
 into oneflow_dev
  • Loading branch information
QuantumLiu committed Feb 14, 2023
2 parents 5230e8e + 45c247e commit 5087fde
Show file tree
Hide file tree
Showing 88 changed files with 2,122 additions and 2,100 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.git
.log
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__pycache__/
*.py[cod]
*$py.class
.DS_Store

# C extensions
*.so
Expand Down
3 changes: 0 additions & 3 deletions .pyup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ requirements:
# Not necessary, but recommended libraries
- requirements/requirements_extra.txt

# Requirements for contrib loggers
- requirements_contrib_loggers.txt

# Requirements for the db
- requirements/requirements_db.txt

Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ formats:
- pdf

python:
version: 3.6
version: 3.7

requirements_file:
requirements/requirements_doc.txt
144 changes: 78 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,91 @@
[![Downloads](https://pepy.tech/badge/tensorlayerx/week)](https://pepy.tech/project/tensorlayerx/week)
[![Docker Pulls](https://img.shields.io/docker/pulls/tensorlayer/tensorlayerx.svg)](https://hub.docker.com/r/tensorlayer/tensorlayerx/)

🇬🇧 TensorLayerX is a multi-backend AI framework, which supports TensorFlow, Pytorch, MindSpore, PaddlePaddle, OneFlow and Jittor as the backends, allowing users to run the code on different hardware like Nvidia-GPU and Huawei-Ascend.
[TensorLayerX](https://tensorlayerx.readthedocs.io) is a multi-backend AI framework, supports TensorFlow, Pytorch, MindSpore, PaddlePaddle, OneFlow and Jittor as the backends, allowing users to run the code on different hardware like Nvidia-GPU, Huawei-Ascend, Cambricon and more.
This project is maintained by researchers from Peking University, Imperial College London, Princeton, Stanford, Tsinghua, Edinburgh and Peng Cheng Lab.
[supported layers](https://shimo.im/sheets/kJGCCTxXvqj99RGV/F5m5Z).

🇨🇳 TensorLayerX 是一个跨平台开发框架,支持TensorFlow, Pytorch, MindSpore, PaddlePaddle, OneFlow和Jittor,用户不需要修改任何代码即可以运行在各类操作系统和AI硬件上(如Nvidia-GPU 和 Huawei-Ascend),并支持混合框架的开发。这个项目由北京大学、鹏城实验室、爱丁堡大学、帝国理工、清华、普林斯顿、斯坦福等机构的研究人员维护。
[支持列表](https://shimo.im/sheets/kJGCCTxXvqj99RGV/F5m5Z)

GitHub: https://github.com/tensorlayer/TensorLayerX
OpenI: https://openi.pcl.ac.cn/OpenI/TensorLayerX

# Document
TensorLayerX has extensive documentation for both beginners and professionals.

[![English Documentation](https://img.shields.io/badge/documentation-english-blue.svg)](https://tensorlayerx.readthedocs.io/en/latest/)

# DeepLearning course
🔥We have opened a video course for introductory learning deep learning, with example codes based on TensorLayerX.
[Bilibili link](https://www.bilibili.com/video/BV1xB4y1h7V2?share_source=copy_web&vd_source=467c17f872fcde378494433520e19999)
# Deep Learning course
We have video courses for deep learning, with example codes based on TensorLayerX.
[Bilibili link](https://www.bilibili.com/video/BV1xB4y1h7V2?share_source=copy_web&vd_source=467c17f872fcde378494433520e19999) (chinese)

# Design Features

Compare with [TensorLayer](https://github.com/tensorlayer/TensorLayer), [TensorLayerX](http://tensorlayerx.readthedocs.io)(TLX) is a brand new seperated project for platform-agnostic purpose.
<p align="center"><img src="https://git.openi.org.cn/hanjr/tensorlayerx-image/raw/branch/master/version.png" width="840"\></p>

Compare to TensorLayer version:
- ***Compatibility***: Support worldwide frameworks and AI chips, enabling one code runs on all platforms.

<p align="center"><img src="https://git.openi.org.cn/hanjr/tensorlayerx-image/raw/branch/master/version.png" width="840"\></p>
- ***Model Zoo***: Provide a series of applications containing classic and SOTA models, covering CV, NLP, RL and other fields.

- ***Deployment***: Support ONNX protocol, model export, import and deployment.

# Multi-backend Design

You can immediately use TensorLayerX to define a model via Pytorch-stype, and switch to any backends easily.

```python
import os
os.environ['TL_BACKEND'] = 'tensorflow' # modify this line, switch to any backends easily!
#os.environ['TL_BACKEND'] = 'mindspore'
#os.environ['TL_BACKEND'] = 'paddle'
#os.environ['TL_BACKEND'] = 'torch'
import tensorlayerx as tlx
from tensorlayerx.nn import Module
from tensorlayerx.nn import Linear
class CustomModel(Module):

def __init__(self):
super(CustomModel, self).__init__()

self.linear1 = Linear(out_features=800, act=tlx.ReLU, in_features=784)
self.linear2 = Linear(out_features=800, act=tlx.ReLU, in_features=800)
self.linear3 = Linear(out_features=10, act=None, in_features=800)

🔥TensorLayerX inherits the features of the previous verison, including ***Simplicity***, ***Flexibility*** and ***Zero-cost Abstraction***. ***Compare with [TensorLayer](https://github.com/tensorlayer/TensorLayer), TensorLayerX supports more backends, such as TensorFlow, MindSpore, PaddlePaddle and PyTorch. It allows users to run the same code on different hardwares like Nvidia-GPU and Huawei-Ascend.*** In addition, more features are ***under development***.
def forward(self, x, foo=False):
z = self.linear1(x)
z = self.linear2(z)
out = self.linear3(z)
if foo:
out = tlx.softmax(out)
return out

- ***Model Zoo***: Build a series of model Zoos containing classic and sota models,covering CV, NLP, RL and other fields.
MLP = CustomModel()
MLP.set_eval()
```

- ***Deploy***: In feature, TensorLayerX will support the ONNX protocol, supporting model export, import and deployment.

- ***Parallel***: In order to improve the efficiency of neural network model training, parallel computing is indispensable.

# Resources

- [TLX2ONNX](https://github.com/tensorlayer/TLX2ONNX/) ONNX Model Exporter for TensorLayerX. ✅
- [Examples](https://github.com/tensorlayer/TensorLayerX/tree/main/examples) for tutorials✅
- [GammaGL](https://github.com/BUPT-GAMMA/GammaGL) is a multi-backend graph learning library based on TensorLayerX.✅
- OpenIVA an easy-to-use product-level deployment framework✅
- [TLXZoo](https://github.com/tensorlayer/TLXZoo) pretrained models/backbones🚧
- TLXCV a bunch of Computer Vision applications🚧
- TLXNLP a bunch of Natural Language Processing applications🚧
- TLXRL a bunch of Reinforcement Learning applications, check [RLZoo](https://github.com/tensorlayer/RLzoo) for the old version✅
- [Examples](https://github.com/tensorlayer/TensorLayerX/tree/main/examples) for tutorials
- [GammaGL](https://github.com/BUPT-GAMMA/GammaGL) is series of graph learning algorithm
- [TLXZoo](https://github.com/tensorlayer/TLXZoo) a series of pretrained backbones
- [TLXCV](https://github.com/tensorlayer/TLXCV) a series of Computer Vision applications
- [TLXNLP](https://github.com/tensorlayer/TLXNLP) a series of Natural Language Processing applications
- [TLX2ONNX](https://github.com/tensorlayer/TLX2ONNX/) ONNX model exporter for TensorLayerX.
- [Paddle2TLX](https://github.com/tensorlayer/paddle2tlx) model code converter from PaddlePaddle to TensorLayerX.

More resources can be found [here](https://github.com/tensorlayer)


# Quick Start
# Installation

## Installation
- The latest TensorLayerX compatible with the following backend version

### Via docker
| TensorLayerX | TensorFlow | MindSpore | PaddlePaddle|PyTorch|
| :-----:| :----: | :----: |:-----:|:----:|
| v0.5.8 | v2.4.0 | v1.8.1 | v2.2.0 | v1.10.0 |
| v0.5.7 | v2.0.0 | v1.6.1 | v2.0.2 | v1.10.0 |

- Via docker

Docker is an open source application container engine. In the [TensorLayerX Docker Repository](https://hub.docker.com/repository/docker/tensorlayer/tensorlayerx),
different versions of TensorLayerX have been installed in docker images.
Expand All @@ -74,56 +108,35 @@ different versions of TensorLayerX have been installed in docker images.
docker pull tensorlayer/tensorlayerx:tagname
```


### Via pip
- Via pip for the stable version
```bash
# install from pypi
pip3 install tensorlayerx
```

### Build from source
- Build from source for the latest version
```bash
# install from Github
pip3 install git+https://github.com/tensorlayer/tensorlayerx.git
```
For more installation instructions, please refer to [Installtion](https://tensorlayerx.readthedocs.io/en/latest/user/installation.html)

## Define a model

You can immediately use tensorlayerx to define a model, using your favourite framework in the background, like so:
```python
import os
os.environ['TL_BACKEND'] = 'tensorflow' # modify this line, switch to any framework easily!
#os.environ['TL_BACKEND'] = 'mindspore'
#os.environ['TL_BACKEND'] = 'paddle'
#os.environ['TL_BACKEND'] = 'torch'
import tensorlayerx as tlx
from tensorlayerx.nn import Module
from tensorlayerx.nn import Linear
class CustomModel(Module):
# Contributing
Join our community as a code contributor, find out more in our [Help wanted list](https://github.com/tensorlayer/TensorLayerX/issues/5) and [Contributing](https://tensorlayerx.readthedocs.io/en/latest/user/contributing.html) guide!

def __init__(self):
super(CustomModel, self).__init__()

self.linear1 = Linear(out_features=800, act=tlx.ReLU, in_features=784)
self.linear2 = Linear(out_features=800, act=tlx.ReLU, in_features=800)
self.linear3 = Linear(out_features=10, act=None, in_features=800)
# Getting Involved

def forward(self, x, foo=False):
z = self.linear1(x)
z = self.linear2(z)
out = self.linear3(z)
if foo:
out = tlx.softmax(out)
return out
We suggest users to report bugs using Github issues. Users can also discuss how to use TensorLayerX in the following slack channel.

MLP = CustomModel()
MLP.set_eval()
```

# Contributing
Join our community as a code contributor, find out more in our [Help wanted list](https://github.com/tensorlayer/TensorLayerX/issues/5) and [Contributing](https://tensorlayerx.readthedocs.io/en/latest/user/contributing.html) guide!
<br/>

<a href="https://join.slack.com/t/tensorlayer/shared_invite/enQtODk1NTQ5NTY1OTM5LTQyMGZhN2UzZDBhM2I3YjYzZDBkNGExYzcyZDNmOGQzNmYzNjc3ZjE3MzhiMjlkMmNiMmM3Nzc4ZDY2YmNkMTY" target="\_blank">
<div align="center">
<img src="https://github.com/tensorlayer/TensorLayer/blob/bdc2c14ff9ed9bd3ec7004d625e15683df7b530d/img/join_slack.png?raw=true" width="40%"/>
</div>
</a>

# Contact
- [email protected]
Expand All @@ -133,14 +146,6 @@ Join our community as a code contributor, find out more in our [Help wanted list
If you find TensorLayerX useful for your project, please cite the following papers:

```
@article{tensorlayer2017,
author = {Dong, Hao and Supratak, Akara and Mai, Luo and Liu, Fangde and Oehmichen, Axel and Yu, Simiao and Guo, Yike},
journal = {ACM Multimedia},
title = {{TensorLayer: A Versatile Library for Efficient Deep Learning Development}},
url = {http://tensorlayer.org},
year = {2017}
}
@inproceedings{tensorlayer2021,
title={TensorLayer 3.0: A Deep Learning Library Compatible With Multiple Backends},
author={Lai, Cheng and Han, Jiarong and Dong, Hao},
Expand All @@ -149,6 +154,13 @@ If you find TensorLayerX useful for your project, please cite the following pape
year={2021},
organization={IEEE}
}
@article{tensorlayer2017,
author = {Dong, Hao and Supratak, Akara and Mai, Luo and Liu, Fangde and Oehmichen, Axel and Yu, Simiao and Guo, Yike},
journal = {ACM Multimedia},
title = {{TensorLayer: A Versatile Library for Efficient Deep Learning Development}},
url = {http://tensorlayer.org},
year = {2017}
}
```


2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ License

TensorLayerX is released under the Apache 2.0 license.

.. |TENSORLAYER-LOGO| image:: https://git.openi.org.cn/TensorLayer/tensorlayer3.0/src/branch/master/img/tl_transparent_logo.png
.. |TENSORLAYER-LOGO| image:: https://git.openi.org.cn/hanjr/tensorlayerx-image/raw/branch/master/tlx-LOGO--02.jpg
:target: https://tensorlayerx.readthedocs.io/en/latest/
3 changes: 1 addition & 2 deletions countlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def countlines(start, lines=0, header=True, begin_start=None):
print('{:>10} |{:>10} | {:<20}'.format(
newlines, lines, reldir_of_thing))


for thing in os.listdir(start):
thing = os.path.join(start, thing)
if os.path.isdir(thing):
Expand All @@ -31,4 +30,4 @@ def countlines(start, lines=0, header=True, begin_start=None):
return lines

if __name__ == '__main__':
countlines('.')
countlines('.')
4 changes: 2 additions & 2 deletions docker/DockerLint.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
docker pull hadolint/hadolint:latest
docker run --rm -i hadolint/hadolint hadolint --ignore DL3007 - < Dockerfile
docker pull tensorlayer/tensorlayerx:tagname
docker run --rm -i tensorlayer/tensorlayerx hadolint --ignore DL3007 - < Dockerfile

PAUSE;
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ RUN echo "Container Tag: ${TF_CONTAINER_VERSION}" \
echo "Building a Nightly Release" \
&& apt-get install -y git \
&& mkdir /dist/ && cd /dist/ \
&& git clone https://github.com/tensorlayer/tensorlayer.git \
&& cd tensorlayer \
&& git clone https://github.com/tensorlayer/tensorlayerx.git \
&& cd tensorlayerx \
&& pip install --disable-pip-version-check --no-cache-dir --upgrade -e .[all]; \
else \
echo "Building Tag Release: $TL_VERSION" \
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
'tensorflow',
'tqdm',
'h5py',
'rich',

# TL C++ Packages
'tensorlayerx.third_party.roi_pooling.roi_pooling.roi_pooling_ops',
Expand Down
3 changes: 1 addition & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Welcome to TensorLayerX


.. image:: user/my_figs/tlx_transparent_logo.png
:width: 30 %
:width: 60 %
:align: center
:target: https://github.com/tensorlayer/TensorLayerX

Expand Down Expand Up @@ -34,7 +34,6 @@ to the library as a developer.
user/installation
user/examples
user/contributing
user/get_involved
user/faq

.. toctree::
Expand Down
Loading

0 comments on commit 5087fde

Please sign in to comment.