pytorch/torch/csrc/jit/python
David Berard 2547be5135 [JIT] during freezing, cast optional bias to half if weight is half
On GPU, conv errors if not all its inputs have the same dtype.

In the case of autocasting during freezing, what we see is:
1) inputs to conv are casted to half
2) inputs to batchnorm are not casted, so many are still floats
3) we try to fold conv + batchnorm, by finding different weight and bias such that conv(input, new_weight, new_bias) is equivalent to the original conv -> batchnorm.

If conv previously had an optional bias, then during freezing we will temporarily create a zero-valued bias as a placeholder for conv_bias. We want to construct it to have the same dtype as the weight input to conv, to avoid errors on GPU.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/77295

Approved by: https://github.com/eellison
2022-05-16 22:18:47 +00:00
..
init.cpp TorchScript to support capability to rethrow the original python exception (#77093) 2022-05-13 16:40:25 +00:00
init.h
module_python.h
pybind_utils.cpp Register prims as operators. 2022-05-11 16:38:14 +00:00
pybind_utils.h Register prims as operators. 2022-05-11 16:38:14 +00:00
pybind.h
python_arg_flatten.cpp [ONNX] Support optional type (#68793) (#73284) 2022-05-04 20:24:30 +00:00
python_arg_flatten.h
python_custom_class.cpp
python_custom_class.h
python_dict.cpp
python_dict.h
python_interpreter.cpp
python_ir.cpp [JIT] during freezing, cast optional bias to half if weight is half 2022-05-16 22:18:47 +00:00
python_ir.h
python_ivalue.h
python_list.cpp [BE] Fix pybind deprecation warnings (#72376) 2022-02-07 18:33:32 +00:00
python_list.h Fix sign-compare violations in python_list.h 2022-04-01 19:15:51 +00:00
python_sugared_value.cpp [JIT] Support for ParameterDict getattr 2022-05-13 01:03:25 +00:00
python_sugared_value.h [JIT] Support for ParameterDict getattr 2022-05-13 01:03:25 +00:00
python_tracer.cpp
python_tracer.h
python_tree_views.cpp Reland "Make debug_pkl smaller by only emitting unique traces." (#73368) 2022-04-18 22:34:21 +00:00
python_tree_views.h
script_init.cpp [JIT] Support for ParameterDict getattr 2022-05-13 01:03:25 +00:00
script_init.h
update_graph_executor_opt.cpp
update_graph_executor_opt.h