Improve namespace for c10::MemoryFormat::Contiguous in torchgen/api/cpp.py (#131622)

Top-level namespaces are more convenient for out-of-tree device extensions.

For example, now we have a patch for it in `torch_npu`:

98c50ced16/codegen/gen_backend_stubs.py (L772-L778)

```python
JIT_TO_CPP_DEFAULT["contiguous_format"] = "c10::MemoryFormat::Contiguous"
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131622
Approved by: https://github.com/zou3519
This commit is contained in:
Yuanhao Ji
2024-08-14 14:41:01 +00:00
committed by PyTorch MergeBot
parent efc6e8457a
commit 378b12f3ad
2 changed files with 2 additions and 2 deletions

View File

@ -287,7 +287,7 @@ class PythonArgument:
"::std::nullopt": "None",
"std::nullopt": "None",
"{}": "None",
"MemoryFormat::Contiguous": "contiguous_format",
"c10::MemoryFormat::Contiguous": "contiguous_format",
"QScheme::PER_TENSOR_AFFINE": "per_tensor_affine",
}.get(self.default, self.default)
return f"{name}: {type_str} = {default}"