Skip to content

Commit

Permalink
[tvmc] Introduce 'tune' subcommand (part 3/4) (apache#6537)
Browse files Browse the repository at this point in the history
* tvmc: introduce 'tune' subcommand (part 3/4)

 * introduces a subcommand to drive auto-tuning

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>

* [tvmc] address code review comments

* adjust --min-repeat-ms default value logic

* re-arrange rpc arguments to be --rpc-tracker=hostname:port and --rpc-key=str

* use a local reference of the tvmc logger

* add --target-host, default to llvm

Co-authored-by: Matthew Barrett <[email protected]>
Co-authored-by: Luke Hutton <[email protected]>
Co-authored-by: Giuseppe Rossini <[email protected]>
  • Loading branch information
4 people authored and Tushar Dey committed Oct 15, 2020
1 parent 2935596 commit d4cee45
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/tvm/driver/tvmc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
TVMC - TVM driver command-line interface
"""

from . import autotuner
from . import compiler
39 changes: 39 additions & 0 deletions python/tvm/driver/tvmc/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@
"""
Common utility functions shared by TVMC modules.
"""
import logging
import os.path

import tvm

from tvm import relay
from tvm import transform


# pylint: disable=invalid-name
logger = logging.getLogger("TVMC")


class TVMCException(Exception):
"""TVMC Exception"""

Expand Down Expand Up @@ -63,3 +72,33 @@ def convert_graph_layout(mod, desired_layout):
raise TVMCException(
"Error converting layout to {0}: {1}".format(desired_layout, str(err))
)


# TODO In a separate PR, eliminate the duplicated code here and in compiler.py (@leandron)
def target_from_cli(target):
"""
Create a tvm.target.Target instance from a
command line interface (CLI) string.
Parameters
----------
target : str
compilation target as plain string,
inline JSON or path to a JSON file
Returns
-------
tvm.target.Target
an instance of target device information
"""

if os.path.exists(target):
with open(target) as target_file:
logger.info("using target input from file: %s", target)
target = "".join(target_file.readlines())

# TODO(@leandron) We don't have an API to collect a list of supported
# targets yet
logger.debug("creating target from input: %s", target)

return tvm.target.Target(target)

0 comments on commit d4cee45

Please sign in to comment.