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
0453776d
Unverified
Commit
0453776d
authored
Jul 08, 2022
by
HELSON
Committed by
GitHub
Jul 08, 2022
Browse files
[tensor] fix a assertion in colo_tensor cross_entropy (#1232)
parent
0e199d71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
colossalai/nn/_ops/loss.py
colossalai/nn/_ops/loss.py
+1
-1
tests/test_tensor/test_loss_func.py
tests/test_tensor/test_loss_func.py
+2
-2
No files found.
colossalai/nn/_ops/loss.py
View file @
0453776d
...
@@ -23,7 +23,7 @@ def colo_cross_entropy(input_tensor: GeneralTensor,
...
@@ -23,7 +23,7 @@ def colo_cross_entropy(input_tensor: GeneralTensor,
input_tensor
=
convert_to_colo_tensor
(
input_tensor
,
pg
)
input_tensor
=
convert_to_colo_tensor
(
input_tensor
,
pg
)
if
input_tensor
.
is_replicate
():
# Input is gathered
if
input_tensor
.
is_replicate
():
# Input is gathered
assert
target
.
is_replicate
()
and
weight
.
is_replicate
(),
\
assert
target
.
is_replicate
()
and
(
weight
is
None
or
weight
.
is_replicate
()
)
,
\
"Target tensor and weight tensor both should be complete"
"Target tensor and weight tensor both should be complete"
output
=
F
.
cross_entropy
(
input_tensor
,
output
=
F
.
cross_entropy
(
input_tensor
,
target
,
target
,
...
...
tests/test_tensor/test_loss_func.py
View file @
0453776d
...
@@ -41,7 +41,7 @@ def run_dist(rank, world_size, port):
...
@@ -41,7 +41,7 @@ def run_dist(rank, world_size, port):
@
pytest
.
mark
.
dist
@
pytest
.
mark
.
dist
@
pytest
.
mark
.
parametrize
(
'world_size'
,
[
2
])
@
pytest
.
mark
.
parametrize
(
'world_size'
,
[
1
,
2
])
@
rerun_if_address_is_in_use
()
@
rerun_if_address_is_in_use
()
def
test_loss_func
(
world_size
):
def
test_loss_func
(
world_size
):
run_func
=
partial
(
run_dist
,
world_size
=
world_size
,
port
=
free_port
())
run_func
=
partial
(
run_dist
,
world_size
=
world_size
,
port
=
free_port
())
...
@@ -49,4 +49,4 @@ def test_loss_func(world_size):
...
@@ -49,4 +49,4 @@ def test_loss_func(world_size):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_loss_func
(
2
)
test_loss_func
(
1
)
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