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

Align getitem with pytorch when index on different devices #7977

Merged
merged 109 commits into from
Apr 30, 2022

Conversation

mosout
Copy link
Contributor

@mosout mosout commented Apr 7, 2022

@mosout mosout requested a review from Flowingsun007 April 8, 2022 10:26
@mosout mosout requested a review from oneflow-ci-bot April 11, 2022 07:58
@mosout mosout requested review from oneflow-ci-bot and removed request for oneflow-ci-bot April 12, 2022 04:54
@jackalcooper jackalcooper requested review from oneflow-ci-bot and removed request for oneflow-ci-bot April 13, 2022 02:20
@mosout mosout requested review from oneflow-ci-bot and removed request for oneflow-ci-bot April 27, 2022 09:25
@mosout mosout requested review from oneflow-ci-bot and removed request for oneflow-ci-bot April 28, 2022 08:52
@mosout mosout requested review from oneflow-ci-bot and removed request for oneflow-ci-bot April 28, 2022 14:42
@mosout mosout merged commit 028a5ed into Oneflow-Inc:master Apr 30, 2022
Comment on lines +1945 to +1957
if (!tensor_indices.empty()) {
const auto x_device = JUST(x->device());
for (int64_t i = 0; i < tensor_indices.size(); ++i) {
const auto tensor_index = tensor_indices[i];
if (tensor_index == nullptr) { continue; }
const auto tensor_index_device = JUST(tensor_index->device());
if ((tensor_index_device->type() != x_device->type())
|| (tensor_index_device->device_id() != x_device->device_id())) {
tensor_indices[i] = JUST(Copy(tensor_index, x_device->type(), x_device->device_id()));
}
}
result = JUST(ApplyAdvancedIndexing(result, tensor_indices));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段代码写成一个单独的函数在ApplyAdvancedIndexing中合适的位置调用吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants