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

index_fill: Add device check #735

Merged
merged 6 commits into from
Aug 14, 2024
Merged
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions src/ATen/native/xpu/TensorAdvancedIndexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,15 @@ Tensor& XPUNativeFunctions::index_fill_(
"index_fill_(): Converting complex Scalar to non-complex type is not supported");
}

TORCH_CHECK(
self.device() == index.device(),
"index_fill_(): self and index value tensors ",
"should have same device type, but got self tensor device type ",
self.device(),
" and index value ",
"tensor device type ",
index.device());

// Handle the case when `self` is 0-dim
Tensor self_nonzero_dim = (self.dim() == 0) ? self.unsqueeze(-1) : self;
dim = at::maybe_wrap_dim(dim, self_nonzero_dim);
Expand Down