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

make setitem device match #5835

Merged
merged 28 commits into from
Aug 13, 2021
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a60f706
make setitem device match
Flowingsun007 Aug 11, 2021
f645698
consistent tensor support
Flowingsun007 Aug 11, 2021
5ca4e63
refine
Flowingsun007 Aug 11, 2021
7350d6c
update
Flowingsun007 Aug 11, 2021
44116bf
refine
Flowingsun007 Aug 11, 2021
506973c
Merge branch 'master' into fix_scalar_setitem_device_not_match
Flowingsun007 Aug 11, 2021
ddfdf80
auto format by CI
oneflow-ci-bot Aug 11, 2021
fc0919a
refine
Flowingsun007 Aug 11, 2021
226e2b3
update
Flowingsun007 Aug 11, 2021
24bc351
Merge branch 'master' into fix_scalar_setitem_device_not_match
Flowingsun007 Aug 11, 2021
243351b
Merge branch 'master' into fix_scalar_setitem_device_not_match
Flowingsun007 Aug 11, 2021
8117303
Merge branch 'master' into fix_scalar_setitem_device_not_match
Flowingsun007 Aug 11, 2021
9c498da
Merge branch 'master' into fix_scalar_setitem_device_not_match
Flowingsun007 Aug 12, 2021
0fd9903
refine
Flowingsun007 Aug 12, 2021
a4d23ed
Merge branch 'master' into fix_scalar_setitem_device_not_match
Flowingsun007 Aug 12, 2021
c10d0f9
auto format by CI
oneflow-ci-bot Aug 12, 2021
52ad547
Merge branch 'master' into fix_scalar_setitem_device_not_match
Flowingsun007 Aug 12, 2021
d3f7f03
Merge branch 'master' into fix_scalar_setitem_device_not_match
Flowingsun007 Aug 12, 2021
a3eed31
Merge branch 'master' into fix_scalar_setitem_device_not_match
Flowingsun007 Aug 12, 2021
83147b8
Merge branch 'master' into fix_scalar_setitem_device_not_match
Flowingsun007 Aug 12, 2021
2108c76
Merge branch 'master' into fix_scalar_setitem_device_not_match
Flowingsun007 Aug 12, 2021
3f3888e
Merge branch 'master' into fix_scalar_setitem_device_not_match
oneflow-ci-bot Aug 12, 2021
d6e64b5
Merge branch 'master' into fix_scalar_setitem_device_not_match
oneflow-ci-bot Aug 12, 2021
e68bf18
Merge branch 'master' into fix_scalar_setitem_device_not_match
oneflow-ci-bot Aug 12, 2021
f69549c
Merge branch 'master' into fix_scalar_setitem_device_not_match
oneflow-ci-bot Aug 12, 2021
cd9af2e
Merge branch 'master' into fix_scalar_setitem_device_not_match
oneflow-ci-bot Aug 13, 2021
28cf025
Merge branch 'master' into fix_scalar_setitem_device_not_match
oneflow-ci-bot Aug 13, 2021
6dee6cf
Merge branch 'master' into fix_scalar_setitem_device_not_match
oneflow-ci-bot Aug 13, 2021
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
13 changes: 11 additions & 2 deletions python/oneflow/framework/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,17 @@ def _getitem(self, key):


def _setitem(self, key, value):
if isinstance(value, (int, float)):
value = flow.F.constant([1], value, self.dtype)
if self.is_consistent:
if isinstance(value, (int, float)):
value = flow.F.consistent_constant(
[1], value, self.dtype, placement=self.placement, sbp=flow.sbp.broadcast
)
else:
if isinstance(value, (int, float)):
value = flow.F.constant([1], value, self.dtype, device=self.device)
else:
value = value.to(device=self.device)

flow.F.tensor_setitem(self, key, value)
return self

Expand Down