mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Remove TH/THC Storage (#68556)
Summary: Fixes https://github.com/pytorch/pytorch/issues/67852 cc ezyang bhosmer smessmer ljk53 bdhirsh Pull Request resolved: https://github.com/pytorch/pytorch/pull/68556 Reviewed By: ejguan Differential Revision: D32652758 Pulled By: ngimel fbshipit-source-id: 170956fca112606f9008abe09b92c6ddc411be09
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f5fa91ba2e
commit
d9e7d85390
@ -198,6 +198,26 @@ void storage_copy(at::Storage dst, at::Storage src, bool non_blocking) {
|
||||
dst_t.copy_(src_t, non_blocking);
|
||||
}
|
||||
|
||||
void storage_fill(at::Storage self, uint8_t value) {
|
||||
auto options = c10::TensorOptions().device(self.device()).dtype(at::kByte);
|
||||
auto self_t = at::empty({0}, {}, options).set_(self);
|
||||
self_t.fill_(value);
|
||||
}
|
||||
|
||||
void storage_set(at::Storage self, ptrdiff_t idx, uint8_t value) {
|
||||
TORCH_CHECK((idx >= 0) && (idx < 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");
|
||||
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>();
|
||||
}
|
||||
|
||||
template class THPPointer<THPStorage>;
|
||||
|
||||
namespace torch { namespace gdb {
|
||||
|
Reference in New Issue
Block a user