Avoid COW materialize in various places (1) (#124984)

Most, not all, of these cases were found automatically with `git grep -n '^\s*\<const\>.*\*.*=.*\<data_ptr\>'`

Part of #97856

Pull Request resolved: https://github.com/pytorch/pytorch/pull/124984
Approved by: https://github.com/Skylion007
This commit is contained in:
Kurt Mohler
2024-04-26 00:30:01 +00:00
committed by PyTorch MergeBot
parent 2ea1e84d40
commit abcb42cdd2
52 changed files with 147 additions and 145 deletions

View File

@ -131,7 +131,7 @@ struct TensorQueue : torch::CustomClassHolder {
const std::string key = "queue";
at::Tensor size_tensor;
size_tensor = dict.at(std::string(key + "/size")).cpu();
const auto* size_tensor_acc = size_tensor.data_ptr<int64_t>();
const auto* size_tensor_acc = size_tensor.const_data_ptr<int64_t>();
int64_t queue_size = size_tensor_acc[0];
for (const auto index : c10::irange(queue_size)) {