[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

@ -283,7 +283,7 @@ std::shared_ptr<SugaredValue> SimpleValue::attr(
std::vector<std::shared_ptr<SugaredValue>> SimpleValue::asTuple(
const SourceRange& loc,
GraphFunction& m,
const c10::optional<size_t>& size_hint) {
const std::optional<size_t>& size_hint) {
static const auto make_simple_value =
[](Value* v) -> std::shared_ptr<SugaredValue> {
return std::make_shared<SimpleValue>(v);
@ -525,7 +525,7 @@ RangeValue::RangeValue(
const SourceRange& loc,
GraphFunction& m,
std::vector<Value*> inputs,
c10::optional<int64_t> static_len) {
std::optional<int64_t> static_len) {
for (const auto i : c10::irange(inputs.size())) {
auto typ = inputs[i]->type();
if (!typ->cast<IntType>()) {
@ -645,7 +645,7 @@ void IterableTree::addChild(
const SourceRange& range,
GraphFunction& m,
const SugaredValuePtr& iter_value) {
c10::optional<int64_t> child_len = iter_value->staticLen();
std::optional<int64_t> child_len = iter_value->staticLen();
if (children_.empty()) {
unroll_length_ = child_len;
} else {
@ -748,7 +748,7 @@ std::shared_ptr<SugaredValue> NamedTupleConstructor::call(
std::shared_ptr<BuiltinFunction> BuiltinFunction::tryCreate(
Symbol symbol,
c10::optional<NamedValue> self) {
std::optional<NamedValue> self) {
for (const std::shared_ptr<Operator>& op : getAllOperatorsFor(symbol)) {
if (!self) {
return std::make_shared<BuiltinFunction>(symbol, nullptr);