[pytorch] add namespace for optTypeMetaToScalarType in codegen to avoid not declared when compile (#115623)

Fixes compilation failure in some environment.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/115623
Approved by: https://github.com/albanD
This commit is contained in:
cdzhan
2023-12-13 00:58:57 +00:00
committed by PyTorch MergeBot
parent 1392843e7b
commit 99554112d3
2 changed files with 3 additions and 3 deletions

View File

@ -144,7 +144,7 @@ def format_trace_inputs(f: NativeFunction) -> str:
name = "options"
return [
ADD_TRACE_INPUT.substitute(
name=name, input="optTypeMetaToScalarType(options.dtype_opt())"
name=name, input="c10::optTypeMetaToScalarType(options.dtype_opt())"
),
ADD_TRACE_INPUT.substitute(name=name, input="options.layout()"),
ADD_TRACE_INPUT.substitute(name=name, input="options.device()"),
@ -205,7 +205,7 @@ def format_trace_inputs(f: NativeFunction) -> str:
outplace = [
ADD_TRACE_INPUT.substitute(
name="out",
input="optTypeMetaToScalarType(out.options().dtype_opt())",
input="c10::optTypeMetaToScalarType(out.options().dtype_opt())",
),
ADD_TRACE_INPUT.substitute(name="out", input="out.options().layout()"),
ADD_TRACE_INPUT.substitute(name="out", input="out.options().device()"),

View File

@ -294,7 +294,7 @@ Check this module for more information.
elif goal == NamedCType("dtype", OptionalCType(BaseCType(scalarTypeT))):
try:
options = direct_solve(options_ctype)
return f"optTypeMetaToScalarType({options}.dtype_opt())"
return f"c10::optTypeMetaToScalarType({options}.dtype_opt())"
except UnsatError:
out_tensor = direct_solve(out_tensor_ctype)
return f"{out_tensor}.scalar_type()"