VTA API

This document contains the python API to VTA compiler toolchain.

VTA Package is a TVM backend extension to support VTA hardware.

Besides the compiler toolchain, it also includes utility functions to configure the hardware environment and access remote device through RPC.

Hardware Information

vta.Environment(cfg)

Hardware configuration object.

This object contains all the information needed for compiling to a specific VTA backend.

Parameters

cfg (dict of str to value.) – The configuration parameters.

Example

# the following code reconfigures the environment
# temporarily to attributes specified in new_cfg.json
new_cfg = json.load(json.load(open("new_cfg.json")))
with vta.Environment(new_cfg):
    # env works on the new environment
    env = vta.get_env()
vta.get_env()

Get the current VTA Environment.

Returns

env – The current environment.

Return type

Environment

RPC Utilities

vta.reconfig_runtime(remote)

Reconfigure remote runtime based on current hardware spec.

Parameters

remote (RPCSession) – The TVM RPC session

vta.program_fpga(remote, bitstream=None)

Upload and program bistream

Parameters
  • remote (RPCSession) – The TVM RPC session

  • bitstream (str, optional) – Path to a local bistream file. If unset, tries to download from cache server.

Compiler API

We program VTA using TVM, so the compiler API in vta package is only a thin wrapper to provide VTA specific extensions.

vta.build_config(debug_flag=0, **kwargs)

Build a build config for VTA.

Parameters
  • debug_flag (int) – The dbeug flag to be passed.

  • kwargs (dict) – Additional configurations.

Returns

build_config – The build config that can be used in TVM.

Return type

BuildConfig

Example

# build a vta module.
with vta.build_config():
    vta_module = tvm.build(s, ...)
vta.build(*args, **kwargs)

Thin wrapper of tvm.build

This wrapper automatically applies VTA’s build_config if there is no user specified build_config in context.

See also

tvm.build()

The original TVM’s build function

vta.lower(*args, **kwargs)

Thin wrapper of tvm.lower

This wrapper automatically applies VTA’s build_config if there is no user specified build_config in context.

See also

tvm.lower()

The original TVM’s lower function