You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pytorch-image-models/timm/models/fx_helpers.py

17 lines
503 B

def fx_and(a: bool, b: bool) -> bool:
"""
Symbolic tracing helper to substitute for normal usage of `* and *` within `torch._assert`.
Hint: Symbolic tracing does not support control flow but since an `assert` is either a dead-end or not, this hack
is okay.
"""
return (a and b)
def fx_float_to_int(x: float) -> int:
"""
Symbolic tracing helper to substitute for inbuilt `int`.
Hint: Inbuilt `int` can't accept an argument of type `Proxy`
"""
return int(x)