diff --git a/torch/__init__.py b/torch/__init__.py index 6b2a581b682..2b879a31740 100644 --- a/torch/__init__.py +++ b/torch/__init__.py @@ -681,6 +681,10 @@ class SymFloat: """Returns the complex conjugate of the float.""" return self + def hex(self) -> str: + """Returns the hexadecimal representation of the float.""" + return self.node.guard_float("", 0).hex() + class SymBool: """ diff --git a/torch/_dynamo/variables/builder.py b/torch/_dynamo/variables/builder.py index 9c76a3016fc..0d9f8ebee98 100644 --- a/torch/_dynamo/variables/builder.py +++ b/torch/_dynamo/variables/builder.py @@ -2384,6 +2384,9 @@ def handle_traced_output(example_value, tx, proxy, options, subclass_type, targe ): set_example_value(proxy.node, example_value) return ConstantVariable.create(example_value, **options) + elif isinstance(example_value, str) and (proxy.node.target in ["hex"]): + set_example_value(proxy.node, example_value) + return ConstantVariable.create(example_value, **options) else: unimplemented( "torch.* op returned non-Tensor "