pytorch/torch/csrc/jit/python
David Berard 25d87c8301 torch.ops.aten.*: sort aten ops before jit overloads (#107138)
Summary:
In fbcode, aten and jit ops can get registered in different orders depending on build mode. In dev mode, aten is registered first; in opt mode, jit is registered first.

This causes problems in torch.ops.aten.* calls; these calls use `torch._C._jit_get_operation`, which selects an overload based on the inputs to the call. It searches through the overloads for the op with the given name, and chooses the first one that matches the input types. "First" depends on whether aten or jit ops were registered first - e.g. in `test_both_scalars_cuda` in opt mode, it chooses `add.complex` and returns a complex value.

We also saw this issue in https://github.com/pytorch/pytorch/pull/103576.

This PR sorts the list of overloads first, putting the aten ops first.

Differential Revision: D48304930

Pull Request resolved: https://github.com/pytorch/pytorch/pull/107138
Approved by: https://github.com/ezyang, https://github.com/eellison
2023-08-17 03:05:59 +00:00
..
init.cpp torch.ops.aten.*: sort aten ops before jit overloads (#107138) 2023-08-17 03:05:59 +00:00
init.h
module_python.h
pybind_utils.cpp Move overloaded_args from FunctionSignature to PythonArgs (#106983) 2023-08-16 15:59:26 +00:00
pybind_utils.h Move overloaded_args from FunctionSignature to PythonArgs (#106983) 2023-08-16 15:59:26 +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
python_list.cpp Use size in python list (#102538) 2023-06-01 00:46:29 +00:00
python_list.h Use size in python list (#102538) 2023-06-01 00:46:29 +00:00
python_sugared_value.cpp
python_sugared_value.h
python_tracer.cpp
python_tracer.h
python_tree_views.cpp
python_tree_views.h
script_init.cpp [export][serde] Hookup export upgrader with TorchScript upgrader entries (#104227) 2023-07-06 16:57:36 +00:00
script_init.h
update_graph_executor_opt.cpp
update_graph_executor_opt.h
utf8_decoding_ignore.cpp
utf8_decoding_ignore.h