You need to sign in or sign up before continuing.
Unverified Commit 685d8980 authored by fzyzcjy's avatar fzyzcjy Committed by GitHub
Browse files

Tiny add warning when cannot recognize bool env var (#5348)

parent 70645f4d
...@@ -78,10 +78,24 @@ time_infos = {} ...@@ -78,10 +78,24 @@ time_infos = {}
HIP_FP8_E4M3_FNUZ_MAX = 224.0 HIP_FP8_E4M3_FNUZ_MAX = 224.0
_warned_bool_env_var_keys = set()
def get_bool_env_var(name: str, default: str = "false") -> bool: def get_bool_env_var(name: str, default: str = "false") -> bool:
value = os.getenv(name, default) value = os.getenv(name, default)
return value.lower() in ("true", "1") value = value.lower()
truthy_values = ("true", "1")
falsy_values = ("false", "0")
if (value not in truthy_values) and (value not in falsy_values):
if value not in _warned_bool_env_var_keys:
logger.warning(
f"get_bool_env_var({name}) see non-understandable value={value} and treat as false"
)
_warned_bool_env_var_keys.add(value)
return value in truthy_values
# https://pytorch.org/docs/stable/notes/hip.html#checking-for-hip # https://pytorch.org/docs/stable/notes/hip.html#checking-for-hip
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment