[12/N] Use std::optional (#132361)

Follows #132396

Pull Request resolved: https://github.com/pytorch/pytorch/pull/132361
Approved by: https://github.com/eqy
This commit is contained in:
cyy
2024-08-02 13:46:44 +00:00
committed by PyTorch MergeBot
parent 56f2917bef
commit b9cb1abf65
63 changed files with 204 additions and 208 deletions

View File

@ -258,7 +258,7 @@ PyObject* THPEngine_run_backward(
for (const auto i : c10::irange(num_tensors)) {
PyObject* _tensor = PyTuple_GET_ITEM(tensors, i);
Edge gradient_edge; // Temporary variable to hold the gradient edge
c10::optional<at::Tensor> mb_output;
std::optional<at::Tensor> mb_output;
if (THPVariable_Check(_tensor)) {
mb_output = THPVariable_Unpack(_tensor);
TORCH_CHECK(