Skip to content

Commit d524569

Browse files
committed
Replace ::std with std
Signed-off-by: cyy <[email protected]>
1 parent 2bf52e5 commit d524569

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

tools/autograd/load_derivatives.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ def repl(m: re.Match[str]) -> str:
969969
if nctype.type == OptionalCType(BaseCType(stringT)):
970970
formula = re.sub(
971971
rf"\b{name}\b",
972-
f"{name}.has_value() ? std::optional<::std::string_view>({name}.value()) : std::nullopt",
972+
f"{name}.has_value() ? std::optional<std::string_view>({name}.value()) : std::nullopt",
973973
formula,
974974
)
975975

torchgen/api/cpp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
ArrayCType,
1010
ArrayRefCType,
1111
BaseCType,
12+
BaseCppType,
1213
BaseTypeToCppMapping,
1314
Binding,
1415
boolT,
@@ -110,7 +111,10 @@ def valuetype_type(
110111
else:
111112
return NamedCType(binds, BaseCType(longT))
112113
# All other BaseType currently map directly to BaseCppTypes.
113-
return NamedCType(binds, BaseCType(BaseTypeToCppMapping[t.name]))
114+
cpp_type = BaseTypeToCppMapping[t.name]
115+
if str(cpp_type) == "std::string_view":
116+
cpp_type = BaseCppType(ns="::std", name=cpp_type.name)
117+
return NamedCType(binds, BaseCType(cpp_type))
114118
elif isinstance(t, OptionalType):
115119
elem = valuetype_type(t.elem, binds=binds, mutable=mutable, symint=symint)
116120
if elem is None:

torchgen/api/types/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
float8_e4m3fnT = BaseCppType("at", "Float8_e4m3fn")
5353
float8_e4m3fnuzT = BaseCppType("at", "Float8_e4m3fnuz")
5454
float8_e8m0fnuT = BaseCppType("at", "Float8_e8m0fnu")
55-
stringT = BaseCppType("::std", "string_view")
55+
stringT = BaseCppType("std", "string_view")
5656
generatorT = BaseCppType("at", "Generator")
5757
scalarTypeT = BaseCppType("at", "ScalarType")
5858
tensorT = BaseCppType("at", "Tensor")

0 commit comments

Comments
 (0)