mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
add hex method on SymFloat (#139451)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139451 Approved by: https://github.com/ezyang
This commit is contained in:
parent
8d1eaa3da6
commit
fdd298dcb7
2 changed files with 7 additions and 0 deletions
|
|
@ -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:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -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 "
|
||||
|
|
|
|||
Loading…
Reference in a new issue