mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Change ATEN generator argument type to const std::optional<Generator>& (#120076)
This PR proposes to use std::optional<Generator>& for underlying functions to avoid unnecessary copy and move operations. The torchgen code was changed to generate the new type. Pull Request resolved: https://github.com/pytorch/pytorch/pull/120076 Approved by: https://github.com/malfet
This commit is contained in:
@ -246,7 +246,7 @@ struct PythonArgs {
|
||||
inline std::vector<int64_t> intlistWithDefault(
|
||||
int i,
|
||||
std::vector<int64_t> default_intlist);
|
||||
inline c10::optional<at::Generator> generator(int i);
|
||||
inline std::optional<at::Generator> generator(int i);
|
||||
inline at::Storage storage(int i);
|
||||
inline at::Storage storage(
|
||||
int i,
|
||||
@ -1069,7 +1069,7 @@ inline bool PythonArgs::isNone(int i) {
|
||||
return args[i] == nullptr;
|
||||
}
|
||||
|
||||
inline c10::optional<at::Generator> PythonArgs::generator(int i) {
|
||||
inline std::optional<at::Generator> PythonArgs::generator(int i) {
|
||||
if (!args[i])
|
||||
return c10::nullopt;
|
||||
return reinterpret_cast<THPGenerator*>(args[i])->cdata;
|
||||
|
Reference in New Issue
Block a user