Skip to content

fix(examples): align results of distributed examples #95

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

Merged
merged 10 commits into from
Oct 8, 2022
Merged
Changes from 1 commit
Commits
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
chore: update default arguments
  • Loading branch information
XuehaiPan committed Oct 7, 2022
commit 891d6d09b6f491d13ce0a42157f002b29b63fc66
20 changes: 16 additions & 4 deletions torchopt/distributed/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def remote_sync_call(


def parallelize_async(
partitioner: Partitioner = batch_partitioner,
partitioner: Optional[Partitioner] = None,
reducer: Optional[Callable[[Iterable[T]], U]] = None,
timeout: Optional[float] = UNSET_RPC_TIMEOUT,
) -> Callable[[Callable[..., T]], Callable[..., Union[Future[List[T]], Future[U]]]]:
Expand All @@ -379,14 +379,20 @@ def parallelize_async(
partitioner (Partitioner, optional): A partitioner that partitions the arguments to multiple
workers. Defaults to :func:`batch_partitioner`.
reducer (Callable[[Iterable[T]], U], optional): A reducer that reduces the results from
multiple workers. Defaults to :data:`None`.
multiple workers. Defaults to :func:`mean_reducer` if the ``partitioner`` is not
specified, i.e., :func:`batch_partitioner`. Otherwise, it defaults to :data:`None`.
timeout (float, optional): The timeout for the RPC call. Defaults to
:data:`rpc.api.UNSET_RPC_TIMEOUT`.

Returns:
The decorated function.
"""

if partitioner is None:
partitioner = batch_partitioner
if reducer is None:
reducer = mean_reducer

def wrapper(func: Callable[..., T]) -> Callable[..., Union[Future[List[T]], Future[U]]]:
@functools.wraps(func)
def wrapped(*args: Any, **kwargs: Any) -> Union[Future[List[T]], Future[U]]:
Expand Down Expand Up @@ -418,7 +424,7 @@ def wrapped(*args: Any, **kwargs: Any) -> Union[Future[List[T]], Future[U]]:


def parallelize(
partitioner: Partitioner = batch_partitioner,
partitioner: Optional[Partitioner] = None,
reducer: Optional[Callable[[Iterable[T]], U]] = None,
timeout: Optional[float] = UNSET_RPC_TIMEOUT,
) -> Callable[[Callable[..., T]], Callable[..., Union[List[T], U]]]:
Expand All @@ -430,14 +436,20 @@ def parallelize(
partitioner (Partitioner, optional): A partitioner that partitions the arguments to multiple
workers. Defaults to :func:`batch_partitioner`.
reducer (Callable[[Iterable[T]], U], optional): A reducer that reduces the results from
multiple workers. Defaults to :data:`None`.
multiple workers. Defaults to :func:`mean_reducer` if the ``partitioner`` is not
specified, i.e., :func:`batch_partitioner`. Otherwise, it defaults to :data:`None`.
timeout (float, optional): The timeout for the RPC call. Defaults to
:data:`rpc.api.UNSET_RPC_TIMEOUT`.

Returns:
The decorated function.
"""

if partitioner is None:
partitioner = batch_partitioner
if reducer is None:
reducer = mean_reducer

def wrapper(func: Callable[..., T]) -> Callable[..., Union[List[T], U]]:
@functools.wraps(func)
def wrapped(*args: Any, **kwargs: Any) -> Union[List[T], U]:
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy