Commit Graph

46 Commits

Author SHA1 Message Date
Mark Shields d1467777c6 Finish support for list-of-targets (#11382)
* Finish support for list-of-targets

This finishes the work started in https://github.com/apache/tvm/pull/11173 to support
'external codegen' targets in the N build-like API surfaces.

 - It turns out it's ok if a build is given only a single 'external codegen' target, so remove that check
   in CompilationConfig::Init. When Collage builds a 'candidate partition' it does so for a single target.
   As far as Collage is concerned it does not care whether the target is regular (eg Target("cuda")), or
   for a specific external codegen (eg Target("cutlass")), it just passes the target into the build.

 - Add CompilationConfig::FindPrimitiveTargetForKind which I'll later need to retrieve
   the external codegen Target instance corresponding to a "Compiler" attribute value.

 - Target.update_target_host_consist was supporting three API styles:
    - single target
    - map from device type to target
    - map from target to IRModule (for the ir_to_runtime API)
   I replaced all those calls with a more specialized 'canonicalize' call:
    - Target.canonicalize_target_and_host
    - Target.canonicalize_multi_targets_and_host
    - Target.canonicalize_target_map_and_host
   In particular, all the tuning interfaces (task extraction, tuning, tuning records) all explicitly
   *do not* support multiple targets since the underlying code just doesn't support that.

* - Lints
- Revert unintended changes

* - more lints

* - Fix model_library_format handling of target.
- Improve comments in compilation_config.h

* - Lints
- Update target/target_host params documentation

* - Fix micro library format tests
- Rev micro library format from 5 to 6
- Use Target.current() in a few places

* - eta contract comprehension

* - Woops, one more device: target map left
- Handle host already being in Target

* - lint

* - lint

* - Bug with append
- Take device type from target

* - Fix hexagon
2022-05-23 09:14:28 -07:00
Qiang Zhang 7a00843d14 [RPC] Add Missing Command Line Option "through-proxy" of RPC Server (#10188) 2022-02-10 09:36:58 +00:00
Muyang Li d8fd5bd6bb Fix some typos (#8101)
* fix bugs in the auto scheduler record:

* reformat the code

* reformat the code

* use the os.path.abspath

* change error to warning

* reformat the warning code

* fix some typos

* fix some typos

* fix some typos

* fix the port number typo
2021-05-21 09:30:02 -07:00
Tianqi Chen 284faf241f [RPC] Make tracker jupyter friendly (#7961)
This PR uses the PopenWorker to handle the tracker start up
and makes the tracker jupyter friendly.
2021-05-03 13:41:02 -07:00
Robert Kimball f4a680d80c Replace 0.0.0.0 with 127.0.0.1 for client connections (#7766)
* Rename references to 0.0.0.0 to localhost. Also change references to 127.0.0.1 to localhost so that all references are consistent. 0.0.0.0 is not the same as localhost.
2021-05-02 07:43:12 -04:00
Tianqi Chen 8bd857d6fa [RPC][REFACTOR] Use PopenWorker to handle RPC Server. (#7889)
Previously the rpc server relies multiprocessing to start a new process and does not work under jupyter.
It also have a popen mode that does ensure the socket start listening before returning the port number.

This PR switches the implementations use PopenWorker. The port number is returned after the socket
get binded, which resolves some of the RPC flaky issues(need sleep to wait the server to start).
It also makes the RPC server jupyter friendly.
2021-04-20 15:04:48 -07:00
Tianqi Chen d5af4f2cfc [PYTHON][RPC] Make rpc proxy jupyter friendly via PopenWorker. (#7757)
* [PYTHON][RPC] Make rpc proxy jupyter friendly via PopenWorker.

* Rework the contrib tests that was previous broken.
2021-03-31 11:40:09 -07:00
Xiyou Zhou 0bd1536200 [Target] Add support for target object with host field compatible with previous api (#7534)
* Fix legacy code on target host

* Modify legacy code for target host change

* Add tests and fix merge issue

* Add condition for same host

* Modify all files for new target host api compatibility

* Add newline

* Change import format

* Optimize test file

* Add match error info for unit tests

* Fix for heterogeneous targets

* Fix format for dict iteration

* Fix target host type error

* Skip one testcase for tvm infinite loop bug

* Fixed bug for target map compatibility

* Fix another TargetsMap issue

* Fix typo and infinite loop error

* Temporary fix for handle issue

* Fix vm target

* Add condition support for str case

* Add GetHost function and fix previous bugs

* Fix measure_record.cc

* Fix search_task.cc

* Fix compiler.cc, memory_alloc.cc

* Fix driver_api.cc

* Fix format

* Fix bugs and GetHost function usage

* Fix clang format

* Fix bug

* Modify python tests

* Change python unit tests to new target api

* Fi test_runtime_heterogeneous.py

* Modify tutorials & remove extra print

* Update more tests to new api

* Refine the tutorial target usage

* change argument name for Target constructor function

* Fix target export function

* Fix and validate all tutorial usage

* Remove unused argument

* Fix format

* Fix bug in driver/build_module.py for heterogeneous target

* Fix bug in driver/build_module.py for heterogeneous target more

* Fix target host type error

* Fix cudnn target host bug

* Fix according to reviews, add helper function in python

* Refactor code as helper function

* Expand helper function

* Fix bug add and update python helper function

* Update target hosts

* Fix format & refresh function

* Fix unit test bug

* Fix bug in refreshing host

* Fix bug

* Add SetHost function

* Update export function

* Fix format

* Fix export bug in target

* Fix bug on host referencing

* Addtional tests

* Address review issues

* Fix format target.py

* Fix issues and format

* Add some 3rd party dependencies

* Merge main branch

* Fix target.h format

* Remove redundent import

* Fix function name

* Add parameter name

* Fix new code bug

* Fix bug in lowering
2021-03-31 10:44:39 -07:00
Tianqi Chen 37af2d741d [CONTRIB] PopenPoolExecutor (#6959)
PopenPoolExecutor implements a ProcessPoolExecutor backed by popen.

- Only handles invoking functions in tvm namespace.
- Unlike multiprocessing, does not require __main__ block,
  which means it can directly run on jupyter notebook.
- Come with timeout and fault tolerant support to timeout
  long running jobs, and restart the process when an error happens.

Recommended usage: it is recommended to create a pool and reuse
it in a long running job(e.g. autotuning) so that the process
are reused when possible.
2020-12-20 13:07:58 -08:00
Andrew Reusch f956c38cd7 [µTVM] Add serial transport, parameterize µTVM Zephyr test, run on physical HW (#6789)
* [BUGFIX] Respect infinite-timed session start timeouts.

 * When debugging, the intended behavior is to set the session start
   timeout to infinite to allow the user to configure the debugger.
 * At present, if a session start retry timeout is defined, the
   current logic will bail after the retry timeout expires.
 * This change makes the session start logic retry forever, once per
   retry timeout.

* Document RPCEndpoint::Create.

* Add stm32f746xx to tvm.target.micro() call; fix parameter name.

 * This API is expected to just be used with positional args, not
   kwargs, so this change isn't expected to cause any breakage.
 * model is more inline with the rest of the file, given TVM Target
   Specification RFC.

* [BUGFIX] If session start fails, exit transport context manager.

 * If an error occurred during session setup, then complex transports
   e.g. DebugWrapperTransport would not de-initialize.

* Align transport writes/reads in TransportLogger

* fix syntax errors which were not exercised in previous PR

* Remove microTVM logic from standard RPC server, add debug shell.

 * microTVM uses the host RPC server as a way to launch a debugger in
   a dedicated, separate terminal window. microTVM needs to be able to
   launch the debugger itself, because its model of the device
   flash/debug flow separates these two things into distinct
   operations implemented by shell commands (for maximum portability
   across frameworks).
 * microTVM can be configured to launch the debugger (e.g. GDB) in the
   same terminal as is used for flashing, but this is sub-optimal
   because then it hides any logs emitted by the device.
 * Using the standard RPC server was hard because GDB expects the user
   to issue SIGINT to interrupt program flow, but due to the RPC
   server's necessary use of multiprocessing, multiple signal handlers
   needed to be SIG_IGN'd, and further, because libtvm.so is
   intentionally frontend-agnostic, it's difficult to include signal
   handling directly in that binary (Python expects you to call
   PyErr_CheckSignals, but we don't require and don't want to require
   python-dev to compile libtvm.so, and this is the only such case
   where libtvm.so is expected to block the main thread for a long
   period of time).
 * Here we implement a separate microTVM debug shell python script
   using the non-blocking server implementation.

* Add serial transport, parameterize test_zephyr to work on real hardware

* add pytest test fixture, missed from previous change.

 * this test fixture helps to parameterize the test case

* address leandron@ comment from #6703
2020-10-31 09:24:01 -04:00
Andrew Reusch c7ff88516f Add µTVM Zephyr support + QEMU regression test (#6603)
* Split transport classes into transport package.

* Introduce transport timeouts.

* black format

* Add metadata-only artifacts

* Simplify utvm rpc server API and ease handling of short packets.

* add zephyr test against qemu

* Add qemu build config

* fix typo

* cleanup zephyr main

* fix nonblocking piping on some linux kernels

* don't double-open transport

* validate FD are in non-blocking mode

* gitignore test debug files

* cleanup zephyr compiler

* re-comment serial until added

* remove logging

* add zephyr exclusions to check_file_type

* add asf header

* lint

* black format

* more pylint

* kill utvm rpc_server bindings, which don't work anymore and fail pylint

* fix compiler warning

* fixes related to pylint

* clang-format again

* more black format

* add qemu regression

* Fix paths for qemu/ dir

* fix typo

* fix SETFL logic

* export SessionTerminatedError and update except after moving

* fix test_micro_artifact

* retrigger staging CI

* fix jenkins syntax hopefully

* one last syntax error

* Add ci_qemu to Jenkinsfile

* build in qemu

* address liangfu comments

* fix new bug with list passing

* retrigger CI
2020-10-15 15:55:45 +08:00
lhutton1 de0c3a4240 [RPC] Lazily import micro when starting an RPC server (#6505)
* [RPC] Lazily import micro when starting an RPC server

Since #6334 the RPC server cannot be started unless USE_MICRO is enabled. I've tracked this down to an import in `python/tvn/exec/rpc_server.py`: `from tvm import micro` in the top level list of imports. This will mean that we try to import micro when it's not been built. Fix this by lazily importing micro when initializing an rpc server with micro enabled.

Change-Id: I8f22d81e215cfe4ac0662b0a99bdf02a3e91f90c

* fix lint

Change-Id: I8b78b678374bc82b3b66a7b3595ed4f1684e7d90
2020-09-17 14:49:32 -07:00
Jared Roesch f13fed55cf [Format] Convert all Python code w/o CI (#6448)
* Add black setup

* Tweak pyproject.toml

* Fix syntax issues

* Fix

* Tweak

* Black all Python code
2020-09-11 22:17:24 +09:00
Junru Shao 67a7497ad3 [Target] Use TargetNode::attrs for Target serialization (#5993) 2020-07-05 09:52:08 -07:00
Tianqi Chen cdc7ae492e [WEB] WebGPU support (#5545)
This PR introduces WebGPU support to tvm.
The WebGPU runtime is directly built in javascript(as WebGPU uses JS as the first class citizen API)
and exposes back to the tvm's runtime via PackedFuncs.

One important note is that `ctx.sync` is not async.
This is due to the fact that WebGPU is a purely async API and we cannot block in the web environment.

So the current best way to use the js api is to wrap things in an async function.
When copy a GPU array to CPU, `await ctx.sync()` need to be called to wait for copy completion.

We use a AsyncIO rpc server to serve the async functions to the clients.
2020-05-09 16:59:18 -07:00
Tianqi Chen 702fd0f0f4 [WEB][RUNTIME] TVM WebAssembly JS Runtime (#5506)
* [WEB] Remove the old web runtime

* [WEB][RUNTIME] TVM WebAssembly Runtime

This PR introduces a brand new TVM web runtime based on the WASM standard API.
Main highlights:

- The new runtime is rewritten using the Typescript.
- The new runtime now directly interfaces with WebAssembly's standard API,
  instead of relying on emscripten's API.
  This change will make the js runtime more portable to runtime variants.
  For example, we could also try to make it interface with the tvm's rust runtime implementation.
- System library can be provided through WASI
  - We also build a hack to enable Emscripten to generate a WASI like
    bundle for runtime environment on the Web.
- The wasm generation now uses the mainlin LLVM.
- Dynamic link(dlopen) is not used due to limitation of wasm,
  instead we rely on the recent new RPC refactor to directly
  restart a new session for each wasm binary sent to the RPC.

* Address review comments

* Skip tensorcore test
2020-05-07 13:47:36 -07:00
Andrew Reusch 8d72496887 [RUNTIME][uTVM] AutoTVM + uTVM for Cortex-M7 (#5417)
* Prototype for micro TVM.

* Cleanup and sync micro tvm prototype.

* Use /std:c++14 with MSVC.

 * Per tqchen: project has already moved to C++14
 * Presubmit failed for code that built locally on gcc.

* fix ASF lint, and fix add_asf_header too

* Compiles with USE_MICRO=OFF.

* Cleanup TargetPtr and word size representations.

* fix compile warning

* address logan's comments

* address logan and liangfu comments

* address thierry's comments

* address u99127, liangfu, tmoreau89 comments

Co-authored-by: Logan Weber <weberlo@cs.washington.edu>
2020-04-30 10:59:33 -07:00
Logan Weber 47c870a9eb [µTVM] Enable AutoTVM for ARM STM32F746XX Boards (#4274) 2019-12-02 10:38:12 -08:00
Tianqi Chen cffb4fba03 [HEADER] Add Header to Comply with ASF Release Policy (#2982)
* [HEADER] ASF header dir=include

* [HEADER] ASF Header dir=src

* [HEADER] ASF Header -dir=python

* [HEADER] ASF header dir=topi

* [HEADER] ASF Header dir=nnvm

* [HEADER] ASF Header -dir=tutorials

* [HEADER] ASF Header dir=tests

* [HEADER] ASF Header -dir=docker

* fix whitespace

* [HEADER] ASF Header -dir=jvm

* [HEADER] ASF Header -dir=web

* [HEADER] ASF Header --dir=apps

* [HEADER] ASF Header --dir=vta

* [HEADER] ASF Header -dir=go

* temp

* [HEADER] ASF Header --dir=rust

* [HEADER] Add ASF Header --dir=cmake

* [HEADER] ASF Header --dir=docs

* [HEADER] Header for Jenkinsfile

* [HEADER] ASF Header to toml and md

* [HEADER] ASF Header to gradle

* Finalize rat cleanup

* Fix permission

* Fix java test

* temporary remove nnvm onnx test
2019-04-07 21:14:02 -07:00
Alexander Pivovarov 3259e6b36a Fix PRC typo (#2939) 2019-03-31 23:05:12 -07:00
llyfacebook 0806b69e3f [RPC] Add the IPV6 support for server side auto tuning (#2462)
* use IPV6 instead of IPV4

* backward compatible

* add error report

* fix linter

* more linter

* fix the python2 api
2019-01-20 18:08:03 -08:00
Tianqi Chen 794bf7fe6e Fix Web Build after CMake transition. (#2407) 2019-01-09 12:19:53 -08:00
lihaozhehw bd44fe03ec Python security issue about mktemp() and abspath() (#2202) 2018-11-30 16:05:31 -08:00
Lianmin Zheng 1027909857 [TOPI] Update pre-tuned parameters for TX2 and fp16 on Mali (#1892) 2018-10-12 09:19:41 -07:00
Lianmin Zheng cfafd212c0 [AUTOTVM] Simplify TopHub (#1630) 2018-08-22 20:21:15 -07:00
Lianmin Zheng b7beb1ebef [AUTOTVM] Allow fallback for template & Fix bugs in tuners (#1615)
* support fallback & fix bugs in tuners & clean topi test

* update task extraction

* update task extraction

* fix arm tutorial

* Update tune_nnvm_arm.py
2018-08-21 18:35:32 -07:00
Lianmin Zheng 9e33774664 fix dependenci and improve doc (#1535) 2018-08-03 14:47:22 -07:00
Lianmin Zheng 32076df815 [AUTOTVM] TOPI integration for ARM CPU (#1487) 2018-08-02 08:59:25 -07:00
Tianqi Chen 81db22c56a [RPC] graduate tvm.contrib.rpc -> tvm.rpc (#1410) 2018-07-09 15:23:41 -07:00
Lianmin Zheng d0eb2d3dbc Add silent mode to rpc server and rpc tracker (#1268) 2018-06-12 19:18:15 -07:00
eqy 5ba24773d6 support custom IP address from rpc server to tracker (PUT) (#1243) 2018-06-07 21:32:37 -07:00
Leyuan Wang dcf18a3c20 [RPC] default use spawn for fork safety (#1240) 2018-06-06 22:52:03 -07:00
Tianqi Chen 396393c2a5 [APP] ROCM RPC (#1155) 2018-05-10 20:24:35 -07:00
Tianqi Chen 51c40b4f8b [CODEGEN] Enable cross compile of AMDGPU without rocm, update rpc (#1154) 2018-05-10 19:27:55 -07:00
Tianqi Chen 3d67ea17d2 [RPC] support tracker in proxy (#1082) 2018-04-05 21:44:07 -07:00
Tianqi Chen 79fc66724d [RPC] Tracker status query (#1081) 2018-04-05 13:47:48 -07:00
Tianqi Chen 6bd8dbc764 [RPC] Refactor, introduce tracker (#1080)
* [RPC] Refactor, introduce tracker

* [RPC] Change RPC hand shake convention, always get remote key.

* fix lint
2018-04-04 20:40:41 -07:00
Lianmin Zheng 07cc21f106 add exclusive mode for rpc server (#941) 2018-02-28 08:54:58 -08:00
Lianmin Zheng fb556ef4b8 [CONTRIB] add peak test (#878)
* add peak test

* fix error for lanes=16

* update doc

* fix names

* fix names
2018-02-06 17:51:03 -08:00
ziheng bdcd325686 [FIX] Fix bug and typo in rpc_server (#263)
* [FIX] Fix bug and typo in rpc_server

* [FIX] Remove unnecessary condition
2017-07-18 23:19:25 -07:00
Tianqi Chen 7b6427e3a8 [RPC] Allow RPCServer to run without decorator (#257) 2017-07-17 13:40:42 -07:00
ziheng 204e9cb429 [EXECUTOR] Fix bug and improve (#252)
* [EXECUTOR] Fix bug and improve

* [EXECUTOR] Enhance test case
2017-07-16 14:54:08 -07:00
Tianqi Chen 8d241b9d86 [RPC] Allow back pressure from writer (#250)
* [RPC] Allow backpressure from writer

* fix

* fix
2017-07-15 18:23:20 -07:00
ziheng c6d4f5af20 [EXECUTOR] Enable load executor remotely (#245)
* [EXECUTOR] Enable load executor remotely

* [EXECUTOR] Pipeline

* Pass bytearray directly

* Enable load dynamic library in rpc_server.py

* Fix

* lint

* Return Module from remote side directly

* Remove unused header file

* Fix

* fix
2017-07-15 13:03:30 -07:00
Tianqi Chen c324494f1a [RUNTIME][RPC] Change RPCServer to Event Driven Code (#243)
* [RUNTIME][RPC] Change RPCServer to Event Driven Code

* fix
2017-07-13 18:44:33 -07:00
Tianqi Chen 1d0d876b7c [TEST/CI] 32bit compatibility and CI. (#159) 2017-05-24 19:06:32 -07:00