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 AutoHeuristic: documentation for mm (#133611) 2024-08-16 16:20:38 +00:00
aoti [cuDNN][SDPA] Remove TORCH_CUDNN_SDPA_ENABLED=1, enable cuDNN SDPA by default on H100 and 2nd on other archs >= sm80 (#125343) 2024-06-30 19:22:16 +00:00
api [Reland] [Torchgen] Pass mutable to cpp.valuetype_type (#134549) 2024-09-01 15:15:38 +00:00
decompositions [BE][Easy] eliminate relative import in torchgen (#128872) 2024-06-21 14:11:46 +00:00
dest [Intel GPU] xpu-ops codegen via backend whitelist (#130082) 2024-07-31 16:31:38 +00:00
executorch [ET] codegen: bool array as array ref (#134886) 2024-09-01 01:33:43 +00:00
fuse [BE] update type annotations for basic utilities in torch/__init__.py (#129001) 2024-06-24 18:04:38 +00:00
operator_versions [BE][Easy] enable postponed annotations in torchgen (#129376) 2024-06-29 09:23:39 +00:00
selective_build [BE][Easy] enable postponed annotations in torchgen (#129376) 2024-06-29 09:23:39 +00:00
shape_functions [BE][Easy] enable postponed annotations in torchgen (#129376) 2024-06-29 09:23:39 +00:00
static_runtime [BE][Easy] enable postponed annotations in torchgen (#129376) 2024-06-29 09:23:39 +00:00
__init__.py
BUCK.oss
BUILD.bazel
build.bzl
code_template.py [BE][Easy] enable postponed annotations in torchgen (#129376) 2024-06-29 09:23:39 +00:00
context.py [BE][Easy] enable postponed annotations in torchgen (#129376) 2024-06-29 09:23:39 +00:00
gen_aoti_c_shim.py [cuDNN][SDPA] Remove TORCH_CUDNN_SDPA_ENABLED=1, enable cuDNN SDPA by default on H100 and 2nd on other archs >= sm80 (#125343) 2024-06-30 19:22:16 +00:00
gen_backend_stubs.py [BE][Easy] replace import pathlib with from pathlib import Path (#129426) 2024-06-30 01:36:07 +00:00
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 propagate XLA's metadata after functional sync (#131076) 2024-07-31 18:20:00 +00:00
gen_lazy_tensor.py [3/N] Change #include <c10/util/Optional.h> to #include <optional> (#130300) 2024-07-09 13:32:57 +00:00
gen_schema_utils.py [HOP] support generating schema for hop (#133521) 2024-08-21 17:34:21 +00:00
gen_vmap_plumbing.py Added batching rule for sdpa_math, sdpa_efficient_attention forward, cudnn, and flash attention (#133964) 2024-08-22 05:29:49 +00:00
gen.py [Intel GPU]device guard codegen for XPU (#133980) 2024-09-05 01:53:31 +00:00
local.py [BE][Easy] enable postponed annotations in torchgen (#129376) 2024-06-29 09:23:39 +00:00
model.py [Intel GPU]device guard codegen for XPU (#133980) 2024-09-05 01:53:31 +00:00
native_function_generation.py [BE][Easy] enable postponed annotations in torchgen (#129376) 2024-06-29 09:23:39 +00:00
utils.py [torchgen] reference generated comment to actual location of the generator and template (#130020) 2024-07-05 21:47:14 +00:00
yaml_utils.py