Skip to content

Commit 855e8d1

Browse files
authored
Merge branch 'master' into windows_ops
2 parents 5c2a1a8 + 1a300d8 commit 855e8d1

File tree

178 files changed

+2386
-1721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+2386
-1721
lines changed

.circleci/config.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,34 @@ jobs:
132132
sudo mv clang-format /opt/clang-format
133133
./travis-scripts/run-clang-format/run-clang-format.py -r torchvision/csrc --clang-format-executable /opt/clang-format
134134
135+
torchhub_test:
136+
docker:
137+
- image: circleci/python:3.7
138+
steps:
139+
- checkout
140+
- run:
141+
command: |
142+
pip install --user --progress-bar off numpy
143+
pip install --user --progress-bar off --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
144+
# need to install torchvision dependencies due to transitive imports
145+
pip install --user --progress-bar off --editable .
146+
python test/test_hub.py
147+
148+
torch_onnx_test:
149+
docker:
150+
- image: circleci/python:3.7
151+
steps:
152+
- checkout
153+
- run:
154+
command: |
155+
pip install --user --progress-bar off numpy
156+
pip install --user --progress-bar off --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
157+
# need to install torchvision dependencies due to transitive imports
158+
pip install --user --progress-bar off --editable .
159+
pip install --user onnx
160+
pip install --user onnxruntime
161+
python test/test_onnx.py
162+
135163
binary_linux_wheel:
136164
<<: *binary_common
137165
docker:
@@ -1060,6 +1088,8 @@ workflows:
10601088
- python_lint
10611089
- python_type_check
10621090
- clang_format
1091+
- torchhub_test
1092+
- torch_onnx_test
10631093

10641094
unittest:
10651095
jobs:
@@ -1174,6 +1204,8 @@ workflows:
11741204
- python_lint
11751205
- python_type_check
11761206
- clang_format
1207+
- torchhub_test
1208+
- torch_onnx_test
11771209
- binary_linux_wheel:
11781210
cu_version: cpu
11791211
filters:

.circleci/config.yml.in

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,34 @@ jobs:
132132
sudo mv clang-format /opt/clang-format
133133
./travis-scripts/run-clang-format/run-clang-format.py -r torchvision/csrc --clang-format-executable /opt/clang-format
134134

135+
torchhub_test:
136+
docker:
137+
- image: circleci/python:3.7
138+
steps:
139+
- checkout
140+
- run:
141+
command: |
142+
pip install --user --progress-bar off numpy
143+
pip install --user --progress-bar off --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
144+
# need to install torchvision dependencies due to transitive imports
145+
pip install --user --progress-bar off --editable .
146+
python test/test_hub.py
147+
148+
torch_onnx_test:
149+
docker:
150+
- image: circleci/python:3.7
151+
steps:
152+
- checkout
153+
- run:
154+
command: |
155+
pip install --user --progress-bar off numpy
156+
pip install --user --progress-bar off --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
157+
# need to install torchvision dependencies due to transitive imports
158+
pip install --user --progress-bar off --editable .
159+
pip install --user onnx
160+
pip install --user onnxruntime
161+
python test/test_onnx.py
162+
135163
binary_linux_wheel:
136164
<<: *binary_common
137165
docker:
@@ -686,6 +714,8 @@ workflows:
686714
- python_lint
687715
- python_type_check
688716
- clang_format
717+
- torchhub_test
718+
- torch_onnx_test
689719

690720
unittest:
691721
jobs:
@@ -702,6 +732,8 @@ workflows:
702732
- python_lint
703733
- python_type_check
704734
- clang_format
735+
- torchhub_test
736+
- torch_onnx_test
705737
{{ build_workflows(prefix="nightly_", filter_branch="nightly", upload=True) }}
706738
docker_build:
707739
triggers:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

.travis.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,6 @@ function(CUDA_CONVERT_FLAGS EXISTING_TARGET)
3232
endif()
3333
endfunction()
3434

35-
file(GLOB HEADERS torchvision/csrc/*.h)
36-
# Image extension
37-
file(GLOB IMAGE_HEADERS torchvision/csrc/cpu/image/*.h)
38-
file(GLOB IMAGE_SOURCES torchvision/csrc/cpu/image/*.cpp)
39-
file(GLOB OPERATOR_HEADERS torchvision/csrc/cpu/*.h)
40-
file(GLOB OPERATOR_SOURCES ${OPERATOR_HEADERS} torchvision/csrc/cpu/*.cpp ${IMAGE_HEADERS} ${IMAGE_SOURCES} ${HEADERS} torchvision/csrc/*.cpp)
41-
if(WITH_CUDA)
42-
file(GLOB OPERATOR_HEADERS ${OPERATOR_HEADERS} torchvision/csrc/cuda/*.h)
43-
file(GLOB OPERATOR_SOURCES ${OPERATOR_SOURCES} ${OPERATOR_HEADERS} torchvision/csrc/cuda/*.cu)
44-
endif()
45-
file(GLOB MODELS_HEADERS torchvision/csrc/models/*.h)
46-
file(GLOB MODELS_SOURCES torchvision/csrc/models/*.h torchvision/csrc/models/*.cpp)
47-
4835
if(MSVC)
4936
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4819")
5037
if(WITH_CUDA)
@@ -77,7 +64,19 @@ if(MSVC AND IGNORE_PYTHON_DEBUG_LIBRARY)
7764
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:${PYTHON3_DEBUG_LIBRARY_NAME}")
7865
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:${PYTHON3_DEBUG_LIBRARY_NAME}")
7966
endif()
80-
add_library(${PROJECT_NAME} SHARED ${MODELS_SOURCES} ${OPERATOR_SOURCES} ${IMAGE_SOURCES})
67+
68+
set(TVCPP torchvision/csrc)
69+
list(APPEND ALLOW_LISTED ${TVCPP} ${TVCPP}/io/image ${TVCPP}/io/image/cpu ${TVCPP}/models ${TVCPP}/ops
70+
${TVCPP}/ops/autograd ${TVCPP}/ops/cpu)
71+
if(WITH_CUDA)
72+
list(APPEND ALLOW_LISTED ${TVCPP}/ops/cuda ${TVCPP}/ops/autocast)
73+
endif()
74+
75+
FOREACH(DIR ${ALLOW_LISTED})
76+
file(GLOB ALL_SOURCES ${ALL_SOURCES} ${DIR}/*.*)
77+
ENDFOREACH()
78+
79+
add_library(${PROJECT_NAME} SHARED ${ALL_SOURCES})
8180
target_link_libraries(${PROJECT_NAME} PRIVATE ${TORCH_LIBRARIES} ${PNG_LIBRARY} ${JPEG_LIBRARIES} Python3::Python)
8281
set_target_properties(${PROJECT_NAME} PROPERTIES
8382
EXPORT_NAME TorchVision
@@ -113,13 +112,8 @@ install(EXPORT TorchVisionTargets
113112
NAMESPACE TorchVision::
114113
DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_DIR})
115114

116-
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
117-
install(FILES
118-
${OPERATOR_HEADERS}
119-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/cpu)
120-
if(WITH_CUDA)
121-
install(FILES
122-
${OPERATOR_HEADERS}
123-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/cuda)
124-
endif()
125-
install(FILES ${MODELS_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/models)
115+
FOREACH(INPUT_DIR ${ALLOW_LISTED})
116+
string(REPLACE "${TVCPP}" "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}" OUTPUT_DIR ${INPUT_DIR})
117+
file(GLOB INPUT_FILES ${INPUT_DIR}/*.*)
118+
install(FILES ${INPUT_FILES} DESTINATION ${OUTPUT_DIR})
119+
ENDFOREACH()

CONTRIBUTING.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Contributing to Torchvision
2+
3+
We want to make contributing to this project as easy and transparent as possible.
4+
5+
## TL;DR
6+
7+
We appreciate all contributions. If you are interested in contributing to Torchvision, there are many ways to help out.
8+
Your contributions may fall into the following categories:
9+
10+
- It helps the project if you could
11+
- Report issues you're facing
12+
- Give a :+1: on issues that others reported and that are relevant to you
13+
14+
- Answering queries on the issue tracker, investigating bugs are very valuable contributions to the project.
15+
16+
- You would like to improve the documentation. This is no less important than improving the library itself!
17+
If you find a typo in the documentation, do not hesitate to submit a GitHub pull request.
18+
19+
- If you would like to fix a bug
20+
- please pick one from the [list of open issues labelled as "help wanted"](https://github.com/pytorch/vision/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)
21+
- comment on the issue that you want to work on this issue
22+
- send a PR with your fix, see below.
23+
24+
- If you plan to contribute new features, utility functions or extensions, please first open an issue and discuss the feature with us.
25+
26+
## Issues
27+
28+
We use GitHub issues to track public bugs. Please ensure your description is
29+
clear and has sufficient instructions to be able to reproduce the issue.
30+
31+
## Development installation
32+
33+
### Install PyTorch Nightly
34+
35+
```bash
36+
conda install pytorch -c pytorch-nightly
37+
# or with pip (see https://pytorch.org/get-started/locally/)
38+
# pip install numpy
39+
# pip install --pre torch -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html
40+
```
41+
42+
### Install Torchvision
43+
44+
```bash
45+
git clone https://github.com/pytorch/vision.git
46+
cd vision
47+
python setup.py install
48+
# or, for OSX
49+
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install
50+
# for C++ debugging, please use DEBUG=1
51+
# DEBUG=1 python setup.py install
52+
pip install flake8 typing mypy pytest scipy
53+
```
54+
You may also have to install `libpng-dev` and `libjpeg-turbo8-dev` libraries:
55+
```bash
56+
conda install libpng jpeg
57+
```
58+
59+
## Development Process
60+
61+
If you plan to modify the code or documentation, please follow the steps below:
62+
63+
1. Fork the repository and create your branch from `master`.
64+
2. If you have modified the code (new feature or bug-fix), please add unit tests.
65+
3. If you have changed APIs, update the documentation. Make sure the documentation builds.
66+
4. Ensure the test suite passes.
67+
5. Make sure your code passes `flake8` formatting check.
68+
69+
For more details about pull requests,
70+
please read [GitHub's guides](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).
71+
72+
If you would like to contribute a new model, please see [here](#New-model).
73+
74+
If you would like to contribute a new dataset, please see [here](#New-dataset).
75+
76+
### Code formatting and typing
77+
78+
New code should be compatible with Python 3.X versions and be compliant with PEP8. To check the codebase, please run
79+
```bash
80+
flake8 --config=setup.cfg .
81+
```
82+
83+
The codebase has type annotations, please make sure to add type hints if required. We use `mypy` tool for type checking:
84+
```bash
85+
mypy --config-file mypy.ini
86+
```
87+
88+
### Unit tests
89+
90+
If you have modified the code by adding a new feature or a bug-fix, please add unit tests for that. To run a specific
91+
test:
92+
```bash
93+
pytest test/<test-module.py> -vvv -k <test_myfunc>
94+
# e.g. pytest test/test_transforms.py -vvv -k test_crop
95+
```
96+
97+
If you would like to run all tests:
98+
```bash
99+
pytest test -vvv
100+
```
101+
102+
### Documentation
103+
104+
Torchvision uses [Google style](http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html)
105+
for formatting docstrings. Length of line inside docstrings block must be limited to 120 characters.
106+
107+
Please, follow the instructions to build and deploy the documentation locally.
108+
109+
#### Install requirements
110+
111+
```bash
112+
cd docs
113+
pip install -r requirements.txt
114+
```
115+
116+
#### Build
117+
118+
```bash
119+
cd docs
120+
make html
121+
```
122+
123+
#### Local deployment
124+
125+
Please, use python 3.X for the command below:
126+
```bash
127+
cd docs/build/html
128+
python -m http.server <port>
129+
# e.g. python -m http.server 1234
130+
```
131+
Then open the browser at `0.0.0.0:<port>` (e.g. `0.0.0.0:1234`)
132+
133+
### New model
134+
135+
More details on how to add a new model will be provided later. Please, do not send any PR with a new model without discussing
136+
it in an issue as, most likely, it will not be accepted.
137+
138+
### New dataset
139+
140+
More details on how to add a new dataset will be provided later. Please, do not send any PR with a new dataset without discussing
141+
it in an issue as, most likely, it will not be accepted.
142+
143+
### Pull Request
144+
145+
If all previous checks (flake8, mypy, unit tests) are passing, please send a PR. Submitted PR will pass other tests on
146+
different operation systems, python versions and hardwares.
147+
148+
For more details about pull requests workflow,
149+
please read [GitHub's guides](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).
150+
151+
## License
152+
153+
By contributing to Torchvision, you agree that your contributions will be licensed
154+
under the LICENSE file in the root directory of this source tree.

0 commit comments

Comments
 (0)