pytorch/torchgen
ZhiweiYan-96 a7a53b796b [Intel GPU]device guard codegen for XPU (#133980)
This PR is a supplement to #130082. The previous PR  #130082 fulfill the basic functionality of codegen, while we found it fails to handle the device sameness check in lots of uts.  Current PR is aimed to facilitate the XPU device guard code generation.

With current PR, the code snippet in `RegisterXPU.cpp` is as follows, where we can see the device guard is successfully generated.
```c++
namespace {
at::Tensor & wrapper_XPU_Tensor_float_out_normal_out(const at::Tensor & mean, double std, ::std::optional<at::Generator> generator, at::Tensor & out) {
  std::optional<Device> common_device = std::nullopt;
(void)common_device; // Suppress unused variable warning
  c10::impl::check_and_update_common_device(common_device, out, "wrapper_XPU_Tensor_float_out_normal_out", "out");
  c10::impl::check_and_update_common_device(common_device, mean, "wrapper_XPU_Tensor_float_out_normal_out", "mean");
  const OptionalDeviceGuard device_guard(device_of(out));
  return at::native::normal_out(mean, std, generator, out);
}
} // anonymous namespace
```
Nevertheless, without current change, the generated code is
```c++
namespace {
at::Tensor & wrapper_XPU_Tensor_float_out_normal_out(const at::Tensor & mean, double std, ::std::optional<at::Generator> generator, at::Tensor & out) {
    // No device check
  // DeviceGuard omitted
  return at::native::normal_out(mean, std, generator, out);
}
} // anonymous namespace
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/133980
Approved by: https://github.com/EikanWang, https://github.com/malfet
2024-09-05 01:53:31 +00:00
..
_autoheuristic
aoti
api [Reland] [Torchgen] Pass mutable to cpp.valuetype_type (#134549) 2024-09-01 15:15:38 +00:00
decompositions
dest
executorch [ET] codegen: bool array as array ref (#134886) 2024-09-01 01:33:43 +00:00
fuse
operator_versions
selective_build
shape_functions
static_runtime
__init__.py
BUCK.oss
BUILD.bazel
build.bzl
code_template.py
context.py
gen.py [Intel GPU]device guard codegen for XPU (#133980) 2024-09-05 01:53:31 +00:00
gen_aoti_c_shim.py
gen_backend_stubs.py
gen_executorch.py [ET][CodeGen] Remove TORCH_API from NativeFunctions.h declarations (#134245) 2024-08-28 19:58:37 +00:00
gen_functionalization_type.py
gen_lazy_tensor.py
gen_schema_utils.py
gen_vmap_plumbing.py
local.py
model.py [Intel GPU]device guard codegen for XPU (#133980) 2024-09-05 01:53:31 +00:00
native_function_generation.py
utils.py
yaml_utils.py