Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TVMC] Treat invalid FILE arguments #9213

Merged
merged 1 commit into from
Oct 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion python/tvm/driver/tvmc/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import json
import logging
from typing import Dict, List, Optional, Union
from tarfile import ReadError

import numpy as np
import tvm
Expand Down Expand Up @@ -115,7 +116,14 @@ def drive_run(args):
except IOError as ex:
raise TVMCException("Error loading inputs file: %s" % ex)

tvmc_package = TVMCPackage(package_path=args.FILE)
try:
tvmc_package = TVMCPackage(package_path=args.FILE)
except IsADirectoryError:
raise TVMCException(f"File {args.FILE} must be an archive, not a directory.")
except FileNotFoundError:
raise TVMCException(f"File {args.FILE} does not exist.")
except ReadError:
raise TVMCException(f"Could not read model from archive {args.FILE}!")

result = run_module(
tvmc_package,
Expand Down