diff --git a/apps/vta_rpc/start_rpc_server.sh b/apps/vta_rpc/start_rpc_server.sh index a6f80e27f1399..fc5dc347d7824 100755 --- a/apps/vta_rpc/start_rpc_server.sh +++ b/apps/vta_rpc/start_rpc_server.sh @@ -6,9 +6,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -19,4 +19,4 @@ PROJROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../" && pwd )" export PYTHONPATH=${PYTHONPATH}:${PROJROOT}/python:${PROJROOT}/vta/python export PYTHONPATH=${PYTHONPATH}:/home/xilinx/pynq -python3 -m vta.exec.rpc_server +python3 -m vta_onboard.exec.rpc_server diff --git a/apps/vta_rpc/start_rpc_server_to_tracker.sh b/apps/vta_rpc/start_rpc_server_to_tracker.sh index 40d01557fe23e..15af3b9d75625 100755 --- a/apps/vta_rpc/start_rpc_server_to_tracker.sh +++ b/apps/vta_rpc/start_rpc_server_to_tracker.sh @@ -23,4 +23,4 @@ TARGET=$(python ${VTA_CONFIG} --target) export PYTHONPATH=${PYTHONPATH}:${PROJROOT}/python:${PROJROOT}/vta/python export PYTHONPATH=${PYTHONPATH}:/home/xilinx/pynq -python3 -m vta.exec.rpc_server --tracker fleet:9190 --key $TARGET +python3 -m vta_onboard.exec.rpc_server --tracker fleet:9190 --key $TARGET diff --git a/vta/python/vta/__init__.py b/vta/python/vta/__init__.py index 5fce76808c45d..70c53741f055d 100644 --- a/vta/python/vta/__init__.py +++ b/vta/python/vta/__init__.py @@ -20,6 +20,7 @@ Besides the compiler toolchain, it also includes utility functions to configure the hardware environment and access remote device through RPC. """ +import logging import sys from .autotvm import module_loader @@ -29,8 +30,18 @@ __version__ = "0.1.0" -# do not from tvm import topi when running vta.exec.rpc_server -# to maintain minimum dependency on the board -if sys.argv[0] not in ("-c", "-m"): +_LOG = logging.getLogger(__name__) + +# do not from tvm import topi when __main__ is in vta_onboard +# to maintain minimum Python dependencies on the board. +# TODO(vta-team): move board-only logic imported above into vta_onboard. +if "vta_onboard" not in sys.modules: from . import top from .build_module import build_config, lower, build +else: + _LOG.warning( + "NOTE: some sub-packages of vta were not imported because the vta_onboard package " + "was detected in sys.modules. VTA assumes this indicates you are running on the " + "FPGA board. The full vta package requires dependencies that are too burdensome " + "to install in this environment." + ) diff --git a/vta/python/vta_onboard/__init__.py b/vta/python/vta_onboard/__init__.py new file mode 100644 index 0000000000000..9320e2dc02d3f --- /dev/null +++ b/vta/python/vta_onboard/__init__.py @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Defines a package that can be run onboard the FPGA's microcontroller.""" diff --git a/vta/python/vta/exec/rpc_server.py b/vta/python/vta_onboard/exec/rpc_server.py similarity index 95% rename from vta/python/vta/exec/rpc_server.py rename to vta/python/vta_onboard/exec/rpc_server.py index dcf564dd03140..3fbc6ed65dd19 100644 --- a/vta/python/vta/exec/rpc_server.py +++ b/vta/python/vta_onboard/exec/rpc_server.py @@ -20,6 +20,10 @@ """ from __future__ import absolute_import +# A marker used in vta.__init__ to detect whether to skip top-level imports to save time in starting +# the RPC server. Must appear before importing vta package. +VTA_SKIP_PACKAGE_IMPORTS = True + import logging import argparse import os @@ -30,8 +34,8 @@ from tvm.contrib import cc from vta import program_bitstream -from ..environment import get_env, pkg_config -from ..libinfo import find_libvta +from vta.environment import get_env, pkg_config +from vta.libinfo import find_libvta def server_start(): @@ -124,7 +128,7 @@ def reconfig_runtime(cfg_json): def main(): - """Main funciton""" + """Main function""" parser = argparse.ArgumentParser() parser.add_argument( "--host", type=str, default="0.0.0.0", help="The host IP address the server binds to"