Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Add sync_context and sync to nn.Metric #302

Merged
merged 49 commits into from
Jun 21, 2021
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
80575de
wip
tchaton Jun 17, 2021
904ecec
add _apply_sync to nn.Metric
tchaton Jun 17, 2021
71ca9be
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 17, 2021
e4d99d8
move to context manager
tchaton Jun 17, 2021
94d3450
Merge branch 'apply_sync_fn' of https://github.com/PyTorchLightning/m…
tchaton Jun 17, 2021
bfcbc74
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 17, 2021
41a60e7
resolve flake8
tchaton Jun 17, 2021
b0498b4
Merge branch 'apply_sync_fn' of https://github.com/PyTorchLightning/m…
tchaton Jun 17, 2021
94fab1b
add sync
tchaton Jun 17, 2021
31498ef
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 17, 2021
31563dc
update
tchaton Jun 17, 2021
7d24123
Merge branch 'apply_sync_fn' of https://github.com/PyTorchLightning/m…
tchaton Jun 17, 2021
15e6d9a
update on comments
tchaton Jun 18, 2021
b3d5ec5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2021
d4367db
Merge branch 'master' into apply_sync_fn
tchaton Jun 18, 2021
fc42bbe
update
tchaton Jun 18, 2021
0dcb041
update
tchaton Jun 18, 2021
980329d
Merge branch 'apply_sync_fn' of https://github.com/PyTorchLightning/m…
tchaton Jun 18, 2021
3b4e838
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2021
140aeeb
add restore_cache
tchaton Jun 18, 2021
1cf6a44
Merge branch 'apply_sync_fn' of https://github.com/PyTorchLightning/m…
tchaton Jun 18, 2021
3ab11cd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2021
ca04cfb
add a sync test
tchaton Jun 18, 2021
f2ae287
Merge branch 'apply_sync_fn' of https://github.com/PyTorchLightning/m…
tchaton Jun 18, 2021
45b1b1f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2021
8aa2a74
resolve flake8
tchaton Jun 18, 2021
0f2ed93
resolve loading
tchaton Jun 18, 2021
de32cbf
Merge branch 'apply_sync_fn' of https://github.com/PyTorchLightning/m…
tchaton Jun 18, 2021
25bfbf3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2021
7222aa3
resolve flake8
tchaton Jun 18, 2021
6dd7705
Update torchmetrics/metric.py
tchaton Jun 18, 2021
da215ad
remove _update_signature
tchaton Jun 18, 2021
dc8e699
Merge branch 'apply_sync_fn' of https://github.com/PyTorchLightning/m…
tchaton Jun 18, 2021
fe456f2
Apply suggestions from code review
Borda Jun 18, 2021
303e829
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2021
586ae75
update on comments
tchaton Jun 18, 2021
a460801
Merge branch 'apply_sync_fn' of https://github.com/PyTorchLightning/m…
tchaton Jun 18, 2021
409e20a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2021
71fad52
add missing is_distributed_fn
tchaton Jun 18, 2021
b7e2030
Merge branch 'apply_sync_fn' of https://github.com/PyTorchLightning/m…
tchaton Jun 18, 2021
e72de7d
update on comments
tchaton Jun 18, 2021
11a3ab8
Update torchmetrics/metric.py
carmocca Jun 18, 2021
d9c0a53
resolve failing test
tchaton Jun 18, 2021
f37e77f
Merge branch 'apply_sync_fn' of https://github.com/PyTorchLightning/m…
tchaton Jun 18, 2021
6e7e3a8
Deepsource smells
carmocca Jun 18, 2021
7ee31d0
Apply suggestions from code review
Borda Jun 21, 2021
99d99e1
update
tchaton Jun 21, 2021
0df9659
Merge branch 'apply_sync_fn' of https://github.com/PyTorchLightning/m…
tchaton Jun 21, 2021
9872ddd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 17, 2021
commit bfcbc74ec585ec99c54bb00e5308e6b4df41de5e
7 changes: 4 additions & 3 deletions torchmetrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
import operator
from abc import ABC, abstractmethod
from collections.abc import Sequence
from contextlib import contextmanager
from copy import deepcopy
from typing import Any, Callable, List, Optional, Union

import torch
from torch import Tensor, nn
from contextlib import contextmanager

from torchmetrics.utilities import apply_to_collection, rank_zero_warn
from torchmetrics.utilities.data import _flatten, dim_zero_cat, dim_zero_mean, dim_zero_sum
from torchmetrics.utilities.distributed import gather_all_tensors
Expand Down Expand Up @@ -227,8 +228,8 @@ def _apply_sync(
dist_sync_fn: Optional[Callable] = None,
) -> None:
"""
Context manager to synchronize the states between processes when running in a distributed setting
and restore the local cache states after yielding.
Context manager to synchronize the states between processes when running in a distributed setting
and restore the local cache states after yielding.

Args:
dist_sync_fn: Function to be used to perform states synchronization
Expand Down