Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ColossalAI
Commits
f071b500
Unverified
Commit
f071b500
authored
Jul 08, 2022
by
HELSON
Committed by
GitHub
Jul 08, 2022
Browse files
[polish] polish __repr__ for ColoTensor, DistSpec, ProcessGroup (#1235)
parent
0453776d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
4 deletions
+8
-4
colossalai/tensor/colo_tensor.py
colossalai/tensor/colo_tensor.py
+1
-1
colossalai/tensor/distspec.py
colossalai/tensor/distspec.py
+3
-3
colossalai/tensor/process_group.py
colossalai/tensor/process_group.py
+4
-0
No files found.
colossalai/tensor/colo_tensor.py
View file @
f071b500
...
...
@@ -158,7 +158,7 @@ class ColoTensor(torch.Tensor):
return
_convert_output
(
ret
,
pg
)
def
__repr__
(
self
):
return
f
'ColoTensor:
{
super
().
__repr__
()
}
\n
dist spec:
{
self
.
dist_spec
}
\n
process group:
{
self
.
process_group
}
'
return
f
'ColoTensor:
\n
{
super
().
__repr__
()
}
\n
{
self
.
dist_spec
}
\n
{
self
.
process_group
}
'
def
_convert_to_dist_spec
(
self
,
dist_spec
:
_DistSpec
)
->
None
:
"""_convert_to_dist_spec
...
...
colossalai/tensor/distspec.py
View file @
f071b500
...
...
@@ -32,11 +32,11 @@ class _DistSpec:
return
True
def
__repr__
(
self
)
->
str
:
res
=
"
\n
DistSpec:
\n\t
"
res
_list
=
[
"
DistSpec:"
]
for
attr
in
dir
(
self
):
if
not
attr
.
startswith
(
'__'
):
res
+=
f
'
{
attr
}
:
{
str
(
getattr
(
self
,
attr
))
}
\n\t
'
return
res
res
_list
.
append
(
f
'
\n\t
{
attr
}
:
{
str
(
getattr
(
self
,
attr
))
}
'
)
return
''
.
join
(
res_list
)
def
replicate
()
->
_DistSpec
:
...
...
colossalai/tensor/process_group.py
View file @
f071b500
...
...
@@ -112,6 +112,10 @@ class ProcessGroup:
def
has_cpu_groups
(
self
):
return
self
.
_has_cpu_groups
def
__repr__
(
self
):
return
"ProcessGroup:
\n\t
Rank: {}, World size: {}, DP degree: {}, TP degree: {}
\n\t
Ranks in group: {}"
.
\
format
(
self
.
_rank
,
self
.
_world_size
,
self
.
_dp_degree
,
self
.
_tp_degree
,
self
.
_rank_list
)
def
__eq__
(
self
,
obj
:
'ProcessGroup'
)
->
bool
:
if
not
isinstance
(
obj
,
ProcessGroup
):
return
False
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment