Skip to content

Commit 03e95d4

Browse files
committed
Interim applications update
1 parent 46d2b76 commit 03e95d4

File tree

66 files changed

+1076
-418
lines changed

Some content is hidden

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

66 files changed

+1076
-418
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ The [applications/](applications) folder contains example applications written i
2525

2626
| Model | Domain | Type |Links |
2727
| ------- | ------- |------- | ------- |
28-
| ResNet | Image Classifcation | Training & Inference | [TensorFlow 1](applications/tensorflow/cnns/) , [TensorFlow 2](applications/tensorflow/cnns/), [PyTorch](applications/pytorch/cnns/)|
28+
| ResNet | Image Classifcation | Training & Inference | [TensorFlow 1](applications/tensorflow/cnns/) , [TensorFlow 2](applications/tensorflow2/classification/), [PyTorch](applications/pytorch/cnns/)|
2929
| ResNeXt | Image Classifcation | Training & Inference | [TensorFlow 1](applications/tensorflow/cnns/) , [PopART (Inference)](applications/popart/resnext_inference)
3030
| EfficientNet | Image Classifcation | Training & Inference | [TensorFlow 1](applications/tensorflow/cnns/) , [PyTorch](applications/pytorch/cnns/)|
3131
| MobileNet | Image Classifcation | Inference | [TensorFlow 1](applications/tensorflow/cnns/inference) |
3232
| MobileNetv2 | Image Classifcation | Inference | [TensorFlow 1](applications/tensorflow/cnns/inference) |
33-
| MobileNetv3 | Image Classifcation | Training & Inference | [PyTorch](applications/tensorflow/cnns/) |
33+
| MobileNetv3 | Image Classifcation | Training & Inference | [PyTorch](applications/pytorch/cnns/) |
3434
| ViT(Vision Transformer) | Image Classifcation | Training| [PyTorch](applications/pytorch/vit) |
3535
| Yolov3 | Object Detection | Training & Inference | [TensorFlow 1](applications/tensorflow/detection/yolov3) |
3636
| Yolov4-P5 | Object Detection | Inference | [PyTorch](applications/pytorch/detection) |
@@ -41,7 +41,7 @@ The [applications/](applications) folder contains example applications written i
4141
| DeepVoice3 | TTS (TextToSpeech) | Training & Inference |[PopART](applications/popart/deep_voice) |
4242
| FastSpeech2 | TTS(TextToSpeech) | Training & Inference | [TensorFlow 2](applications/tensorflow2/fastspeech2/) |
4343
| Conformer | STT(SpeechToText) | Training & Inference | [PopART](applications/popart/conformer_asr) |
44-
| Conformer with Transformer | STT(SpeechToText) | Training & Inference | [TensorFlow 1](applications/tensorflow/conformer) |
44+
| Conformer with Transformer | STT(SpeechToText) | Training & Inference | [TensorFlow 1](applications/tensorflow/conformer) , [PyTorch](applications/pytorch/conformer) |
4545
| Transfomer Transducer | STT(SpeechToText) | Training & Inference | [PopART](applications/popart/transformer_transducer) |
4646
| TGN (Temporal Graph Network) | GNN | Training & Inference | [TensorFlow 1](applications/tensorflow/tgn/) |
4747
| MPNN (Message Passing Neural Networks) | GNN | Training & Inference | [TensorFlow 2](code_examples/tensorflow2/message_passing_neural_network) |
@@ -51,11 +51,12 @@ The [applications/](applications) folder contains example applications written i
5151
| RL Policy model | Reinforcement Learning | Training | [TensorFlow 1](applications/tensorflow/reinforcement_learning) |
5252
| MNIST RigL | Dynamic Sparsity | Training | [TensorFlow 1](applications/tensorflow/dynamic_sparsity/mnist_rigl) |
5353
| Autoregressive Language Modelling | Dynamic Sparsity | Training | [TensorFlow 1](applications/tensorflow/dynamic_sparsity/language_modelling) |
54-
| Sales forecasting | MLP (Multi-Layer Perceptron) | Training | [TensorFlow 1](applications/tensorflow/dynamic_sparsity/language_modelling) |
54+
| Sales forecasting | MLP (Multi-Layer Perceptron) | Training | [TensorFlow 1](applications/tensorflow/sales_forcasting/language_modelling) |
5555
| Contrastive Divergence VAE using MCMC methods | Generative Model | Training | [TensorFlow 1](applications/tensorflow/contrastive_divergence_vae) |
5656
| Monte Carlo Ray Tracing | Vision | Inference | [Poplar](applications/poplar/monte_carlo_ray_tracing) |
5757

5858

59+
5960
### Code examples
6061

6162
The [code_examples/](code_examples) folder contains smaller models and code examples. See the READMEs in each folder for details.
@@ -82,3 +83,4 @@ December 2021:
8283
- GNN : TGN(TensorFlow1), MPNN(TensorFlow 2)
8384

8485

86+

applications/popart/faster-rcnn/IPU/customized_ops.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
def load_lib():
1313
global LIB_LOADED
1414
if not LIB_LOADED:
15+
print(__file__)
16+
print(os.path.dirname(__file__))
1517
basedir = os.path.abspath(os.path.dirname(__file__))
18+
print(basedir)
1619
ctypes.cdll.LoadLibrary(
1720
os.path.join(basedir, "custom_ops/nms/build/libnms_ops.so"))
1821
ctypes.cdll.LoadLibrary(
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) 2021 Graphcore Ltd. All rights reserved.
2+
# Written by Hu Di
3+
4+
import pytest
5+
import os
6+
import subprocess
7+
8+
9+
def pytest_sessionstart(session):
10+
faster_rcnn_working_dic = os.path.join(os.path.dirname(__file__), '../')
11+
subprocess.run(['make'], shell=True, cwd=faster_rcnn_working_dic)

applications/popart/faster-rcnn/tests/test_nms.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import numpy as np
55
import sys
66
import os
7-
import subprocess
87
sys.path.append(os.path.join(os.path.dirname(__file__), '../'))
98
sys.path.append(os.path.join(os.path.dirname(__file__), '../IPU'))
109
from ipu_tensor import gcop
@@ -119,7 +118,5 @@ def py_cpu_nms(dets, scores, thresh):
119118

120119

121120
def test_nms():
122-
faster_rcnn_working_dic = os.path.join(os.path.dirname(__file__), '../')
123-
subprocess.run(['make'], shell=True, cwd=faster_rcnn_working_dic)
124121
for iou_thrd in [0.1, 0.3, 0.5, 0.7, 0.9]:
125122
helper_func(iou_thrd)

applications/popart/faster-rcnn/tests/test_roialign.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import sys
55
import os
6-
import subprocess
76
sys.path.append(os.path.join(os.path.dirname(__file__), '../'))
87
sys.path.append(os.path.join(os.path.dirname(__file__), '../IPU'))
98
from torchvision.ops import RoIAlign as torch_roialign
@@ -60,8 +59,6 @@ def my_test_func(feat, box, pt_on_output, output_shape, spatial_scale, aligned=T
6059

6160

6261
def test_roialign():
63-
faster_rcnn_working_dic = os.path.join(os.path.dirname(__file__), '../')
64-
subprocess.run(['make'], shell=True, cwd=faster_rcnn_working_dic)
6562
box_centers = np.random.rand(1, BOX_NUM, 2) * np.asarray(IMAGE_SIZE)
6663
box_whs = np.random.rand(
6764
1, BOX_NUM, 2) * (BOX_SIZE_RANGE[1] - BOX_SIZE_RANGE[0]) + BOX_SIZE_RANGE[0]
@@ -145,6 +142,6 @@ def clip_boxes(boxes, im_info):
145142
# local_spatial_scale = 1/16
146143
# local_result = my_test_func(local_feat,local_box,pt_on_output,output_shape,local_spatial_scale)
147144
np.testing.assert_allclose(
148-
torch_result.detach().numpy(), pooled_feat.data[0], rtol=1e-2)
145+
torch_result.detach().numpy(), pooled_feat.data[0], rtol=1e-2, atol=1e-5)
149146
np.testing.assert_allclose(
150-
torch_feat.grad.detach().numpy(), input_features.grad, rtol=1e-3)
147+
torch_feat.grad.detach().numpy(), input_features.grad, rtol=1e-3, atol=1e-6)

applications/popart/resnext_inference/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ torch==1.7.0
55
torchvision==0.8.1
66
urllib3==1.26.6
77
pretrainedmodels==0.7.4
8-
pytest==5.4.1
8+
pytest==6.2.5
99
pytest-pythonpath==0.7.3
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pytest
1+
pytest==6.2.5
22
pytest-pythonpath
33
pathlib
44

applications/pytorch/bert/README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -236,22 +236,18 @@ for f in *.tfrecord; do python3 -m tfrecord.tools.tfrecord2idx $f `basename $f .
236236

237237
## Licensing
238238

239-
The code presented here is licensed under the Apache License Version 2.0, see the LICENSE file in this directory.
239+
This application is licensed under Apache License 2.0.
240+
Please see the LICENSE file in this directory for full details of the license conditions.
240241

241-
This directory includes derived work from the following:
242+
This directory contains derived work from:
243+
* BERT, https://github.com/google-research/bert (licensed under the Apache License, Version 2.0)
244+
* Hugging Face Transformers, https://github.com/huggingface/transformers (licensed under the Apache License, Version 2.0)
242245

243-
BERT, https://github.com/google-research/bert
246+
See the headers in the source code for details.
244247

245-
Copyright 2018 The Google AI Language Team Authors.
248+
The following files include code derived from https://github.com/huggingface/transformers which uses Apache License, Version 2.0:
249+
* bert_fused_attention.py
250+
* squad_data.py
246251

247-
Licensed under the Apache License, Version 2.0 (the "License");
248-
you may not use this file except in compliance with the License.
249-
You may obtain a copy of the License at
250-
251-
http://www.apache.org/licenses/LICENSE-2.0
252-
253-
Unless required by applicable law or agreed to in writing, software
254-
distributed under the License is distributed on an "AS IS" BASIS,
255-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
256-
See the License for the specific language governing permissions and
257-
limitations under the License.
252+
The following files include code derived from https://github.com/google-research/bert which uses Apache License, Version 2.0:
253+
* third_party/create_pretraining_data.py

applications/pytorch/bert/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tokenizers>=0.10.3
44
scipy>=1.5.4
55
pyyaml>=5.4.1
66
wandb==0.12.1
7-
pytest>=6.2.4
7+
pytest==6.2.5
88
pytest-pythonpath>=0.7.3
99
tfrecord>=1.13
1010
filelock>=3.0.12

applications/pytorch/bert/squad_data.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ def postprocess_qa_predictions(examples, features, raw_predictions, n_best_size=
196196
if start_index >= len(offset_mapping) \
197197
or end_index >= len(offset_mapping) \
198198
or offset_mapping[start_index] is None \
199-
or offset_mapping[end_index] is None:
199+
or offset_mapping[end_index] is None \
200+
or offset_mapping[start_index] == [] \
201+
or offset_mapping[end_index] == []:
200202
continue
201203
# Don't consider answers with a length that is either < 0 or > max_answer_length.
202204
if end_index < start_index or end_index - start_index + 1 > max_answer_length:

0 commit comments

Comments
 (0)