Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
210130121
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2021
210130121
Commits
006b0ef7
Unverified
Commit
006b0ef7
authored
3 years ago
by
Yurui Li
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add GetRank and GetWordSize interface (#4809)
* add GetRank and GetWordSize interface * minor fix
parent
b6936aea
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
oneflow/api/python/env/env.cpp
+3
-0
3 additions, 0 deletions
oneflow/api/python/env/env.cpp
oneflow/api/python/env/env.h
+3
-0
3 additions, 0 deletions
oneflow/api/python/env/env.h
oneflow/api/python/env/env_api.h
+4
-0
4 additions, 0 deletions
oneflow/api/python/env/env_api.h
with
10 additions
and
0 deletions
oneflow/api/python/env/env.cpp
+
3
−
0
View file @
006b0ef7
...
...
@@ -30,4 +30,7 @@ ONEFLOW_API_PYBIND11_MODULE("", m) {
m
.
def
(
"DestroyEnv"
,
&
DestroyEnv
,
py
::
call_guard
<
py
::
gil_scoped_release
>
());
m
.
def
(
"CurrentMachineId"
,
&
CurrentMachineId
);
m
.
def
(
"GetRank"
,
&
GetRank
);
m
.
def
(
"GetWordSize"
,
&
GetWordSize
);
}
This diff is collapsed.
Click to expand it.
oneflow/api/python/env/env.h
+
3
−
0
View file @
006b0ef7
...
...
@@ -91,6 +91,9 @@ inline Maybe<void> InitEnv(const std::string& env_proto_str) {
inline
Maybe
<
long
long
>
CurrentMachineId
()
{
return
GlobalProcessCtx
::
Rank
();
}
inline
Maybe
<
int64_t
>
GetRank
()
{
return
GlobalProcessCtx
::
Rank
();
}
inline
Maybe
<
size_t
>
GetWordSize
()
{
return
GlobalProcessCtx
::
WorldSize
();
}
}
// namespace oneflow
#endif // ONEFLOW_API_PYTHON_ENV_ENV_H_
This diff is collapsed.
Click to expand it.
oneflow/api/python/env/env_api.h
+
4
−
0
View file @
006b0ef7
...
...
@@ -40,4 +40,8 @@ inline void DestroyEnv() { return oneflow::DestroyEnv().GetOrThrow(); }
inline
long
long
CurrentMachineId
()
{
return
oneflow
::
CurrentMachineId
().
GetOrThrow
();
}
inline
int64_t
GetRank
()
{
return
oneflow
::
GetRank
().
GetOrThrow
();
}
inline
size_t
GetWordSize
()
{
return
oneflow
::
GetWordSize
().
GetOrThrow
();
}
#endif // ONEFLOW_API_PYTHON_ENV_ENV_API_H_
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment