Skip to content

Commit

Permalink
Merge branch 'aluo/qnn/conv2d-transpose-fixes' of github.com:AndrewZh…
Browse files Browse the repository at this point in the history
…aoLuo/tvm into aluo/qnn/conv2d-transpose-fixes

* 'aluo/qnn/conv2d-transpose-fixes' of github.com:AndrewZhaoLuo/tvm: (27 commits)
  fix keras
  jostle
  more frontend tests fixes
  remove f2qi for later pr
  remove formatting only change
  undo just formatting changes
  lint
  add todo
  fix fake quantization pass
  fix qnn conv2d transpose tests
  fix vitis tests
  change layouts for conv2d_transpose too
  fix bug with layout transform
  add test
  lint
  make pytorch tests pass
  fix a lot of initial tests
  Disable Hexagon TestConv2dPackedFilter test (apache#9344)
  BUG: Look through on_device annotations when looking for shape constants (apache#9345)
  [Community] @ganler -> Reviewer (apache#9346)
  ...
  • Loading branch information
AndrewZhaoLuo committed Oct 25, 2021
2 parents 525ab24 + 54bd920 commit be20086
Show file tree
Hide file tree
Showing 42 changed files with 944 additions and 322 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ We do encourage everyone to work anything they are interested in.
- [Trevor Morris](https://github.com/trevor-m): @trevor-m
- [Tatsuya Nishiyama](https://github.com/nishi-t): @nishi-t
- [Leandro Nunes](https://github.com/leandron): @leandron
- [Jiawei Liu](https://github.com/ganler): @ganler
- [Lily Orth-Smith](https://github.com/electriclilies): @electriclilies
- [Wei Pan](https://github.com/wpan11nv): @wpan11nv
- [Krzysztof Parzyszek](https://github.com/kparzysz-quic): @kparzysz-quic
Expand Down
18 changes: 18 additions & 0 deletions apps/microtvm/arduino/README.md
Original file line number Diff line number Diff line change
@@ -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. -->

This directory contains code to interface microTVM with [Arduino](https://www.arduino.cc/).

This file was deleted.

59 changes: 59 additions & 0 deletions apps/microtvm/arduino/template_project/boards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"due": {
"package": "arduino",
"architecture": "sam",
"board": "arduino_due_x_dbg",
"model": "sam3x8e"
},
"feathers2": {
"package": "esp32",
"architecture": "esp32",
"board": "feathers2",
"model": "esp32",
"note": "Due to the way the Feather S2 bootloader works, compilation behaves fine but uploads cannot be done automatically."
},
"metrom4": {
"package": "adafruit",
"architecture": "samd",
"board": "adafruit_metro_m4",
"model": "atsamd51"
},
"spresense": {
"package": "SPRESENSE",
"architecture": "spresense",
"board": "spresense",
"model": "cxd5602gg",
"note": "Spresense only works as of its v2.3.0 sdk."
},
"nano33ble": {
"package": "arduino",
"architecture": "mbed_nano",
"board": "nano33ble",
"model": "nrf52840"
},
"pybadge": {
"package": "adafruit",
"architecture": "samd",
"board": "adafruit_pybadge_m4",
"model": "atsamd51"
},
"teensy40": {
"package": "teensy",
"architecture": "avr",
"board": "teensy40",
"model": "imxrt1060",
"note": "The Teensy boards are listed here for completeness, but they won't work until https://github.com/arduino/arduino-cli/issues/700 is finished."
},
"teensy41": {
"package": "teensy",
"architecture": "avr",
"board": "teensy41",
"model": "imxrt1060"
},
"wioterminal": {
"package": "Seeeduino",
"architecture": "samd",
"board": "seeed_wio_terminal",
"model": "atsamd51"
}
}
98 changes: 23 additions & 75 deletions apps/microtvm/arduino/template_project/microtvm_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,77 +44,21 @@
IS_TEMPLATE = not (API_SERVER_DIR / MODEL_LIBRARY_FORMAT_RELPATH).exists()


BOARDS = API_SERVER_DIR / "boards.json"

# Data structure to hold the information microtvm_api_server.py needs
# to communicate with each of these boards.
try:
with open(BOARDS) as boards:
BOARD_PROPERTIES = json.load(boards)
except FileNotFoundError:
raise FileNotFoundError(f"Board file {{{BOARDS}}} does not exist.")


class BoardAutodetectFailed(Exception):
"""Raised when no attached hardware is found matching the requested board"""


# Data structure to hold the information microtvm_api_server.py needs
# to communicate with each of these boards. Currently just holds the
# components of each board's FQBN, but might be extended in the future
# to include the SRAM, PSRAM, flash, etc. on each board.
BOARD_PROPERTIES = {
"due": {
"package": "arduino",
"architecture": "sam",
"board": "arduino_due_x_dbg",
"model": "sam3x8e",
},
# Due to the way the Feather S2 bootloader works, compilation
# behaves fine but uploads cannot be done automatically
"feathers2": {
"package": "esp32",
"architecture": "esp32",
"board": "feathers2",
"model": "esp32",
},
"metrom4": {
"package": "adafruit",
"architecture": "samd",
"board": "adafruit_metro_m4",
"model": "atsamd51",
},
# Spresense only works as of its v2.3.0 sdk
"spresense": {
"package": "SPRESENSE",
"architecture": "spresense",
"board": "spresense",
"model": "cxd5602gg",
},
"nano33ble": {
"package": "arduino",
"architecture": "mbed_nano",
"board": "nano33ble",
"model": "nrf52840",
},
"pybadge": {
"package": "adafruit",
"architecture": "samd",
"board": "adafruit_pybadge_m4",
"model": "atsamd51",
},
# The Teensy boards are listed here for completeness, but they
# won't work until https://github.com/arduino/arduino-cli/issues/700
# is finished
"teensy40": {
"package": "teensy",
"architecture": "avr",
"board": "teensy40",
"model": "imxrt1060",
},
"teensy41": {
"package": "teensy",
"architecture": "avr",
"board": "teensy41",
"model": "imxrt1060",
},
"wioterminal": {
"package": "Seeeduino",
"architecture": "samd",
"board": "seeed_wio_terminal",
"model": "atsamd51",
},
}

PROJECT_TYPES = ["example_project", "host_driven"]

PROJECT_OPTIONS = [
Expand All @@ -123,11 +67,6 @@ class BoardAutodetectFailed(Exception):
choices=list(BOARD_PROPERTIES),
help="Name of the Arduino board to build for",
),
server.ProjectOption(
"arduino_model",
choices=[board["model"] for _, board in BOARD_PROPERTIES.items()],
help="Name of the model for each Arduino board.",
),
server.ProjectOption("arduino_cli_cmd", help="Path to the arduino-cli tool."),
server.ProjectOption("port", help="Port to use for connecting to hardware"),
server.ProjectOption(
Expand Down Expand Up @@ -166,8 +105,9 @@ def _copy_project_files(self, api_server_dir, project_dir, project_type):
so this file is copied separately in generate_project.
"""
project_types_folder = api_server_dir.parents[0]
for item in (project_types_folder / project_type / "src").iterdir():
for item in (API_SERVER_DIR / "src" / project_type).iterdir():
if item.name == "project.ino":
continue
dest = project_dir / "src" / item.name
if item.is_dir():
shutil.copytree(item, dest)
Expand All @@ -176,7 +116,7 @@ def _copy_project_files(self, api_server_dir, project_dir, project_type):

# Arduino requires the .ino file have the same filename as its containing folder
shutil.copy2(
project_types_folder / project_type / "project.ino",
API_SERVER_DIR / "src" / project_type / "project.ino",
project_dir / f"{project_dir.stem}.ino",
)

Expand Down Expand Up @@ -344,12 +284,20 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec

# Copies files from the template folder to project_dir
shutil.copy2(API_SERVER_DIR / "microtvm_api_server.py", project_dir)
shutil.copy2(BOARDS, project_dir / BOARDS.name)
self._copy_project_files(API_SERVER_DIR, project_dir, options["project_type"])

# Copy standalone_crt into src folder
self._copy_standalone_crt(source_dir, standalone_crt_dir)
self._remove_unused_components(source_dir, options["project_type"])

# Populate crt-config.h
crt_config_dir = project_dir / "src" / "standalone_crt" / "crt_config"
crt_config_dir.mkdir()
shutil.copy2(
API_SERVER_DIR / "crt_config" / "crt_config.h", crt_config_dir / "crt_config.h"
)

# Unpack the MLF and copy the relevant files
metadata = self._disassemble_mlf(model_library_format_path, source_dir)
shutil.copy2(model_library_format_path, source_dir / "model")
Expand Down
2 changes: 1 addition & 1 deletion apps/microtvm/zephyr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
<!--- specific language governing permissions and limitations -->
<!--- under the License. -->

This directory code to interface microTVM with the [Zephyr RTOS](https://zephyrproject.org/).
This directory contains code to interface microTVM with the [Zephyr RTOS](https://zephyrproject.org/).

4 changes: 2 additions & 2 deletions docker/install/ubuntu_install_qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ apt update
apt-get -y build-dep qemu

gpg --keyserver keyserver.ubuntu.com --recv-keys 0x3353C9CEF108B584
cat <<EOF | gpg --dearmor >qemu-5.1.0.tar.xz.sig
cat <<EOF | gpg --dearmor >${QEMU_SIG_FILE}
-----BEGIN PGP ARMORED FILE-----
Comment: Use "gpg --dearmor" for unpacking
Expand All @@ -68,7 +68,7 @@ p5ez/+2k4VAIwIQoP5DoO06waLBffvLIAdPPKYsx71K67OoGG2svc7duC/+5qf1x
=hCS7
-----END PGP ARMORED FILE-----
EOF
curl -OLs https://download.qemu.org/qemu-5.1.0.tar.xz
curl -OLs https://download.qemu.org/${QEMU_TAR_FILE}
gpg --verify ${QEMU_SIG_FILE}

tar -xf ${QEMU_TAR_FILE}
Expand Down
Loading

0 comments on commit be20086

Please sign in to comment.