diff --git a/python/tvm/relax/frontend/nn/extern.py b/python/tvm/relax/frontend/nn/extern.py index 332d07cbc3c5..198ef0f23c46 100644 --- a/python/tvm/relax/frontend/nn/extern.py +++ b/python/tvm/relax/frontend/nn/extern.py @@ -228,7 +228,10 @@ def _detect_source_code(source_code) -> str: path = Path(source_code) except: # pylint: disable=bare-except return source_code - if not path.is_file(): + try: + if not path.is_file(): + return source_code + except: # pylint: disable=bare-except return source_code with path.open("r", encoding="utf-8") as file: return file.read()