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

add_env_api_docs #7100

Merged
merged 14 commits into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions docs/source/env.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
oneflow.env
===================================
Environment
----------------------------------
.. currentmodule:: oneflow

.. autofunction:: oneflow.env.get_world_size
.. autofunction:: oneflow.env.get_rank
.. autofunction:: oneflow.env.get_local_rank
.. autofunction:: oneflow.env.get_node_size
.. autofunction:: oneflow.env.is_multi_client
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ OneFlow API Reference
optim
utils
cuda
env
distributed
comm
placement
Expand Down
1 change: 0 additions & 1 deletion docs/source/oneflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,3 @@ oneflow
from_numpy,

.. autofunction:: oneflow.relu
.. autofunction:: oneflow.env.get_rank
20 changes: 20 additions & 0 deletions python/oneflow/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@


def get_local_rank():
"""Returns the local rank of current machine.
Local rank is not globally unique. It is only unique per process on a machine.

Returns:
The the local rank of process on current machine.

"""
return oneflow._oneflow_internal.GetLocalRank()


def get_rank():
"""Returns the rank of current process group.
Rank is globally unique, range of which is [0, world_size).

Returns:
The rank of the process group.
Expand All @@ -42,6 +50,12 @@ def get_rank():


def get_node_size():
"""Returns the number of machines in the current process group.

Returns:
The the number of machines in the process group.

"""
return oneflow._oneflow_internal.GetNodeSize()


Expand All @@ -56,4 +70,10 @@ def get_world_size():


def is_multi_client():
"""Returns whether it is currently in multi client mode.

Returns:
True if currently in multi client mode, otherwise returns Flase.

"""
return oneflow._oneflow_internal.IsMultiClient()