mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Fix sign-compare violations in torch_python
Prerequisite change for enabling `-Werror=sign-compare` across PyTorch repo Pull Request resolved: https://github.com/pytorch/pytorch/pull/75079 Approved by: https://github.com/albanD
This commit is contained in:
committed by
PyTorch MergeBot
parent
78305ad2b7
commit
c593c220ff
@ -198,14 +198,14 @@ void storage_fill(at::Storage self, uint8_t value) {
|
||||
}
|
||||
|
||||
void storage_set(at::Storage self, ptrdiff_t idx, uint8_t value) {
|
||||
TORCH_CHECK((idx >= 0) && (idx < self.nbytes()), "out of bounds");
|
||||
TORCH_CHECK((idx >= 0) && (idx < static_cast<ptrdiff_t>(self.nbytes())), "out of bounds");
|
||||
auto options = c10::TensorOptions().device(self.device()).dtype(at::kByte);
|
||||
auto self_t = at::empty({0}, {}, options).set_(self);
|
||||
self_t[idx].fill_(value);
|
||||
}
|
||||
|
||||
uint8_t storage_get(at::Storage self, ptrdiff_t idx) {
|
||||
TORCH_CHECK((idx >= 0) && (idx < self.nbytes()), "out of bounds");
|
||||
TORCH_CHECK((idx >= 0) && (idx < static_cast<ptrdiff_t>(self.nbytes())), "out of bounds");
|
||||
auto options = c10::TensorOptions().device(self.device()).dtype(at::kByte);
|
||||
auto self_t = at::empty({0}, {}, options).set_(self);
|
||||
return self_t[idx].item<uint8_t>();
|
||||
|
Reference in New Issue
Block a user