mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[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:
@ -42,8 +42,8 @@ def unwrap_tensor(name: str, cur_level_var: str) -> list[str]:
|
||||
|
||||
def unwrap_optional_tensor(name: str, cur_level_var: str) -> list[str]:
|
||||
result = f"""\
|
||||
optional<Tensor> {name}_value;
|
||||
optional<int64_t> {name}_bdim;
|
||||
std::optional<Tensor> {name}_value;
|
||||
std::optional<int64_t> {name}_bdim;
|
||||
if ({name}) {{
|
||||
std::tie({name}_value, {name}_bdim) = unwrapTensorAtLevel({name}.value(), {cur_level_var});
|
||||
}}"""
|
||||
|
Reference in New Issue
Block a user