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
1a9e2c2d
Unverified
Commit
1a9e2c2d
authored
Apr 21, 2022
by
Ziyue Jiang
Committed by
GitHub
Apr 21, 2022
Browse files
[tensor] fix kwargs in colo_tensor torch_funtion (#825)
parent
eb1b8990
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
4 deletions
+3
-4
colossalai/tensor/colo_tensor.py
colossalai/tensor/colo_tensor.py
+1
-1
tests/test_tensor/test_op.py
tests/test_tensor/test_op.py
+2
-3
No files found.
colossalai/tensor/colo_tensor.py
View file @
1a9e2c2d
...
@@ -63,6 +63,6 @@ class ColoTensor(object):
...
@@ -63,6 +63,6 @@ class ColoTensor(object):
kwargs
=
{}
kwargs
=
{}
kwargs
=
{
kwargs
=
{
k
warg
:
kwargs
[
kwarg
]
.
torch_tensor
()
if
isinstance
(
kwarg
,
ColoTensor
)
else
kwarg
for
k
warg
in
kwargs
k
:
v
.
torch_tensor
()
if
isinstance
(
v
,
ColoTensor
)
else
v
for
k
,
v
in
kwargs
.
items
()
}
}
return
func
(
*
args
,
**
kwargs
)
return
func
(
*
args
,
**
kwargs
)
tests/test_tensor/test_op.py
View file @
1a9e2c2d
...
@@ -59,14 +59,13 @@ def test_no_wrap_op():
...
@@ -59,14 +59,13 @@ def test_no_wrap_op():
t_ref
=
torch
.
randn
(
3
,
5
)
t_ref
=
torch
.
randn
(
3
,
5
)
t
=
ColoTensor
.
init_from_torch_tensor
(
t_ref
.
clone
())
t
=
ColoTensor
.
init_from_torch_tensor
(
t_ref
.
clone
())
assert
torch
.
sum
(
t
)
==
torch
.
sum
(
t_ref
)
assert
torch
.
sum
(
t
)
==
torch
.
sum
(
t_ref
)
assert
torch
.
sum
(
input
=
t
)
==
torch
.
sum
(
input
=
t_ref
)
def
test_lazy_init_tensor
():
def
test_lazy_init_tensor
():
lazy_t
=
ColoTensor
((
2
,
3
),
dtype
=
torch
.
float32
,
requires_grad
=
True
)
lazy_t
=
ColoTensor
((
2
,
3
),
dtype
=
torch
.
float32
,
requires_grad
=
True
)
assert
lazy_t
.
_torch_tensor
==
None
assert
lazy_t
.
_torch_tensor
==
None
assert
lazy_t
.
torch_tensor
().
numel
()
==
6
assert
lazy_t
.
torch_tensor
().
numel
()
==
6
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_
lazy_init_tensor
()
test_
no_wrap_op
()
# test_element_wise()
# test_element_wise()
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