[codemod] c10:optional -> std::optional (#126135)

Generated by running the following from PyTorch root:
```
find . -regex ".*\.\(cpp\|h\|cu\|hpp\|cc\|cxx\)$" | grep -v "build/" | xargs -n 50 -P 4 perl -pi -e 's/c10::optional/std::optional/'
```

`c10::optional` is just an alias for `std::optional`. This removes usages of that alias in preparation for eliminating it entirely.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/126135
Approved by: https://github.com/Skylion007, https://github.com/malfet, https://github.com/albanD, https://github.com/aaronenyeshi
This commit is contained in:
Richard Barnes
2024-05-14 19:35:49 +00:00
committed by PyTorch MergeBot
parent b55f57b7af
commit ed327876f5
907 changed files with 5655 additions and 5655 deletions

View File

@ -162,7 +162,7 @@ class TORCH_API ProcessGroup : public torch::CustomClassHolder {
at::TensorList,
const c10::intrusive_ptr<::c10d::ProcessGroup>&,
const c10::intrusive_ptr<::c10d::ReduceOp>&,
const c10::optional<at::Tensor>& sparse_indices,
const std::optional<at::Tensor>& sparse_indices,
int64_t)>();
return std::get<1>(op.call(
@ -620,7 +620,7 @@ class TORCH_API ProcessGroup : public torch::CustomClassHolder {
void setBackend(
c10::DeviceType deviceType,
BackendType backendType,
const c10::optional<c10::intrusive_ptr<Backend>>& backend) {
const std::optional<c10::intrusive_ptr<Backend>>& backend) {
// TODO: should we add these entries after the backend setting succeeds?
deviceTypeToBackendType_[deviceType] = backendType;
deviceTypes_.insert(deviceType);
@ -703,11 +703,11 @@ class TORCH_API ProcessGroup : public torch::CustomClassHolder {
// optimizations such as automatic use of ncclCommSplit. The device
// is specified in `init_process_group` and eventually makes it
// here and then down into the actual backend instances.
c10::optional<at::Device> getBoundDeviceId() const {
std::optional<at::Device> getBoundDeviceId() const {
return bound_device_id_;
}
void setBoundDeviceId(c10::optional<at::Device> device) {
void setBoundDeviceId(std::optional<at::Device> device) {
if (device) {
TORCH_CHECK(device->has_index(), "setBoundDeviceId must have an index");
}
@ -742,7 +742,7 @@ class TORCH_API ProcessGroup : public torch::CustomClassHolder {
std::unordered_map<BackendType, c10::intrusive_ptr<Backend>>
backendTypeToBackend_;
c10::optional<at::Device> bound_device_id_;
std::optional<at::Device> bound_device_id_;
};
} // namespace c10d