-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: main updates: 1. Add module view 2. Add DataPipe support 3. Add pytorch lightning view 4. Fix some bugs Pull Request resolved: #517 Reviewed By: chaekit Differential Revision: D34307403 Pulled By: robieta fbshipit-source-id: 8526342f03e2b8cd47c6121a9984d6a706058916
- Loading branch information
1 parent
b654f58
commit cdfa44f
Showing
73 changed files
with
14,911 additions
and
3,884 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
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 = 120 | ||
per-file-ignores = __init__.py:F401 torch_tb_profiler/io/file.py: F401 |
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,34 @@ | ||
# ------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# ------------------------------------------------------------------------- | ||
default_language_version: | ||
python: python3.8 | ||
|
||
ci: | ||
autofix_prs: true | ||
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions' | ||
autoupdate_schedule: quarterly | ||
# submodules: true | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.1.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
exclude: torch_tb_profiler/static/index.html | ||
- id: trailing-whitespace | ||
- id: double-quote-string-fixer | ||
|
||
- repo: https://github.com/pre-commit/mirrors-autopep8 | ||
rev: v1.6.0 | ||
hooks: | ||
- id: autopep8 | ||
name: Format code | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 4.0.1 | ||
hooks: | ||
- id: flake8 | ||
args: | ||
- "--max-line-length=120" | ||
- "--per-file-ignores=__init__.py:F401 tb_plugin/torch_tb_profiler/io/file.py: F401" | ||
name: Check PEP8 |
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
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
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
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 @@ | ||
import torch | ||
import torch.nn as nn | ||
import torch.optim | ||
from torch.utils.data.dataloader_experimental import DataLoader2 | ||
|
||
from torchvision import transforms as T | ||
import torchvision.prototype.datasets as pdatasets | ||
import torchvision.prototype.models as models | ||
from torchvision.prototype.datasets._builtin import Cifar10 | ||
|
||
|
||
if __name__ == "__main__": | ||
model = models.resnet50(models.ResNet50_Weights.ImageNet1K_V1) | ||
trainset = Cifar10().to_datapipe(root='./data', decoder=pdatasets.decoder.raw) | ||
transform = T.Compose([T.Resize(256), T.CenterCrop(224)]) | ||
trainset = trainset.map(transform, input_col="image") | ||
trainset = trainset.map(fn=T.functional.convert_image_dtype, input_col="image") | ||
dl = DataLoader2(trainset, batch_size=64) | ||
criterion = nn.CrossEntropyLoss().cuda(0) | ||
optimizer = torch.optim.SGD(model.parameters(), lr=0.001, momentum=0.9) | ||
device = torch.device("cuda:0") | ||
model.to(device=device).train() | ||
|
||
with torch.profiler.profile( | ||
activities=[ | ||
torch.profiler.ProfilerActivity.CPU, | ||
torch.profiler.ProfilerActivity.CUDA], | ||
schedule=torch.profiler.schedule( | ||
wait=1, | ||
warmup=1, | ||
active=2), | ||
on_trace_ready=torch.profiler.tensorboard_trace_handler('./result', worker_name='datapipe0'), | ||
record_shapes=True, | ||
profile_memory=True, # This will take 1 to 2 minutes. Setting it to False could greatly speedup. | ||
with_stack=True | ||
) as p: | ||
for step, data in enumerate(dl, 0): | ||
print("step:{}".format(step)) | ||
input_tensors = data['image'] | ||
label_tensors = data['label'] | ||
inputs, labels = input_tensors.to(device=device), label_tensors.to(device=device) | ||
outputs = model(inputs) | ||
loss = criterion(outputs, labels) | ||
optimizer.zero_grad() | ||
loss.backward() | ||
optimizer.step() | ||
if step + 1 >= 4: | ||
break | ||
p.step() | ||
print("done") |
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
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
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
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 |
---|---|---|
|
@@ -8,4 +8,3 @@ | |
<div id="app"></div> | ||
</body> | ||
</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
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 |
---|---|---|
|
@@ -10,4 +10,3 @@ | |
"proseWrap": "always", | ||
"endOfLine": "lf" | ||
} | ||
|
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
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
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
Oops, something went wrong.