pytorch/torch/csrc/jit/python
Scott Wolchok 5d35b49ba7 Fix forced copying def_property_readonly for FunctionSchema & friends (#161301)
This took me a bit to figure out and I'm pretty sure I've looked at
this code before. Pybind uses
`return_value_policy::reference_internal` for `def_property`, which
[causes the owning object to be kept alive for the lifespan of the
return
value](https://pybind11.readthedocs.io/en/stable/advanced/functions.html),
allowing the getter to safely avoid copying the property
value. However, lambdas act like they return `auto`, not
`decltype(auto)`, so our lambdas themselves were forcing copies!

Testing: observed std::vector<Argument> copying disappear in Linux
perf profile of someOpInfo._schema.arguments/returns (in
_python_dispatch.correct_storage_aliasing).

Pull Request resolved: https://github.com/pytorch/pytorch/pull/161301
Approved by: https://github.com/Skylion007, https://github.com/malfet, https://github.com/wconstab
2025-08-30 06:55:42 +00:00
..
init.cpp Fix forced copying def_property_readonly for FunctionSchema & friends (#161301) 2025-08-30 06:55:42 +00:00
init.h
module_python.h
pybind_utils.cpp Add unsigned support to IValue (#160102) 2025-08-11 03:57:18 +00:00
pybind_utils.h [BE][8/16] fix typos in torch/ (torch/csrc/jit/) (#156318) 2025-07-02 22:55:29 +00:00
pybind.h
python_arg_flatten.cpp
python_arg_flatten.h
python_custom_class.cpp
python_custom_class.h
python_dict.cpp
python_dict.h
python_interpreter.cpp
python_ir.cpp
python_ir.h
python_ivalue.h [BE][8/16] fix typos in torch/ (torch/csrc/jit/) (#156318) 2025-07-02 22:55:29 +00:00
python_list.cpp
python_list.h
python_sugared_value.cpp [TorchScript, PT2] Add torch._check compatibility support (#159988) 2025-08-08 23:14:13 +00:00
python_sugared_value.h [BE][8/16] fix typos in torch/ (torch/csrc/jit/) (#156318) 2025-07-02 22:55:29 +00:00
python_tracer.cpp [BE][8/16] fix typos in torch/ (torch/csrc/jit/) (#156318) 2025-07-02 22:55:29 +00:00
python_tracer.h
python_tree_views.cpp
python_tree_views.h
script_init.cpp
script_init.h
update_graph_executor_opt.cpp
update_graph_executor_opt.h
utf8_decoding_ignore.cpp
utf8_decoding_ignore.h