Skip to content

Commit

Permalink
Merge branch 'main' into aluo/onnx/support-nllloss-tests
Browse files Browse the repository at this point in the history
* main: (37 commits)
  [ONNX] [Relay] Dynamic squeeze (apache#9095)
  [Meta Schedule][M3b] Database (apache#9061)
  [Bugfix] Add nullptr checking for `AttrStmt` with `coproc_uop_scope` attr key (apache#9123)
  [Codegen] Swap out analyzer when outlining (apache#9117)
  [CI] bash.sh, build.sh: add option to set the container name and hostname (apache#9110)
  Ensure google-mock is installed and setup (apache#9107)
  Arm(R) Ethos(TM)-U NPU TIR to CS for Conv2D (apache#8811)
  Frontend: add onnx GlobalLpPool op (apache#8845)
  [LLVM] Refactor MakeCallPacked, NFC (apache#9118)
  prevent casting handle to other types (apache#9114)
  fix annotation of tir generic (apache#9119)
  [Relay] Register layout conversion function to more reduce ops (apache#9048)
  Fix the missing `dtype` attribute of `tir.Shuffle` in Python level (apache#9131)
  add `multiply` and remove `subtract` for dnnl json runtime (apache#9120)
  relu of dnnl json runtime only support 4-dims input (apache#9122)
  [Meta Schedule][M3a] SpaceGenerator  (apache#9079)
  [TensorIR][Bugfix] Disallow fusing loops with dependency (apache#9112)
  adding Jorn to reviewers list (apache#9105)
  [BYOC] Fix incorrect conv2d padding handling of `dnnl with c source runtime` (apache#9097)
  [Frontend][TFLite] fix apache#9078 (apache#9099)
  ...
  • Loading branch information
AndrewZhaoLuo committed Sep 28, 2021
2 parents a718b2a + 5e46e75 commit ec71db0
Show file tree
Hide file tree
Showing 117 changed files with 4,879 additions and 747 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ We do encourage everyone to work anything they are interested in.
- [Jon Soifer](https://github.com/soiferj): @soiferj
- [Zhixun Tan](https://github.com/phisiart): @phisiart
- [Andrew Tulloch](https://github.com/ajtulloch): @ajtulloch
- [Jorn Tuyls](https://github.com/jtuyls): @jtuyls
- [Luis Vega](https://github.com/vegaluisjose): @vegaluisjose
- [Thomas Viehmann](https://github.com/t-vi): @t-vi
- [Yao Wang](https://github.com/kevinthesun): @kevinthesun
Expand Down
56 changes: 56 additions & 0 deletions apps/microtvm/zephyr/template_project/boards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"mps2_an521": {
"board": "mps2_an521",
"model": "mps2_an521",
"is_qemu": true,
"fpu": false
},
"nrf5340dk_nrf5340_cpuapp": {
"board": "nrf5340dk_nrf5340_cpuapp",
"model": "nrf5340dk",
"is_qemu": false,
"fpu": true
},
"nucleo_f746zg": {
"board": "nucleo_f746zg",
"model": "stm32f746xx",
"is_qemu": false,
"fpu": true
},
"nucleo_l4r5zi": {
"board": "nucleo_l4r5zi",
"model": "stm32l4r5zi",
"is_qemu": false,
"fpu": true
},
"qemu_cortex_r5": {
"board": "qemu_cortex_r5",
"model": "zynq_mp_r5",
"is_qemu": true,
"fpu": true
},
"qemu_riscv32": {
"board": "qemu_riscv32",
"model": "host",
"is_qemu": true,
"fpu": true
},
"qemu_riscv64": {
"board": "qemu_riscv64",
"model": "host",
"is_qemu": true,
"fpu": true
},
"qemu_x86": {
"board": "qemu_x86",
"model": "host",
"is_qemu": true,
"fpu": true
},
"stm32f746g_disco": {
"board": "stm32f746g_disco",
"model": "stm32f746xx",
"is_qemu": false,
"fpu": true
}
}
77 changes: 18 additions & 59 deletions apps/microtvm/zephyr/template_project/microtvm_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import tempfile
import threading
import time
import json

import serial
import serial.tools.list_ports
Expand All @@ -57,46 +58,16 @@

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.
BOARD_PROPERTIES = {
"qemu_x86": {
"board": "qemu_x86",
"model": "host",
},
"qemu_riscv32": {
"board": "qemu_riscv32",
"model": "host",
},
"qemu_riscv64": {
"board": "qemu_riscv64",
"model": "host",
},
"mps2_an521": {
"board": "mps2_an521",
"model": "mps2_an521",
},
"nrf5340dk_nrf5340_cpuapp": {
"board": "nrf5340dk_nrf5340_cpuapp",
"model": "nrf5340dk",
},
"stm32f746g_disco": {
"board": "stm32f746g_disco",
"model": "stm32f746xx",
},
"nucleo_f746zg": {
"board": "nucleo_f746zg",
"model": "stm32f746xx",
},
"nucleo_l4r5zi": {
"board": "nucleo_l4r5zi",
"model": "stm32l4r5zi",
},
"qemu_cortex_r5": {
"board": "qemu_cortex_r5",
"model": "zynq_mp_r5",
},
}
try:
with open(BOARDS) as boards:
BOARD_PROPERTIES = json.load(boards)
except FileNotFoundError:
raise FileNotFoundError(f"Board file {{{BOARDS}}} does not exist.")


def check_call(cmd_args, *args, **kwargs):
Expand Down Expand Up @@ -290,9 +261,8 @@ def _get_nrf_device_args(options):
help="Name of the Zephyr board to build for.",
),
server.ProjectOption(
"zephyr_model",
choices=[board["model"] for _, board in BOARD_PROPERTIES.items()],
help="Name of the model for each Zephyr board.",
"config_main_stack_size",
help="Sets CONFIG_MAIN_STACK_SIZE for Zephyr board.",
),
]

Expand Down Expand Up @@ -351,13 +321,9 @@ def _create_prj_conf(self, project_dir, options):
if self._has_fpu(options["zephyr_board"]):
f.write("# For models with floating point.\n" "CONFIG_FPU=y\n" "\n")

main_stack_size = None
if self._is_qemu(options) and options["project_type"] == "host_driven":
main_stack_size = 1536

# Set main stack size, if needed.
if main_stack_size is not None:
f.write(f"CONFIG_MAIN_STACK_SIZE={main_stack_size}\n")
if options.get("config_main_stack_size") is not None:
f.write(f"CONFIG_MAIN_STACK_SIZE={options['config_main_stack_size']}\n")

f.write("# For random number generation.\n" "CONFIG_TEST_RANDOM_GENERATOR=y\n")

Expand All @@ -384,6 +350,9 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec
# by launching the copy.
shutil.copy2(__file__, project_dir / os.path.basename(__file__))

# Copy boards.json file to generated project.
shutil.copy2(BOARDS, project_dir / BOARDS.name)

# Place Model Library Format tarball in the special location, which this script uses to decide
# whether it's being invoked in a template or generated project.
project_model_library_format_tar_path = project_dir / MODEL_LIBRARY_FORMAT_RELPATH
Expand Down Expand Up @@ -471,20 +440,10 @@ def _is_qemu(cls, options):
or options["zephyr_board"] in cls._KNOWN_QEMU_ZEPHYR_BOARDS
)

_KNOWN_FPU_ZEPHYR_BOARDS = (
"nucleo_f746zg",
"nucleo_l4r5zi",
"nrf5340dk_nrf5340_cpuapp",
"qemu_cortex_r5",
"qemu_riscv32",
"qemu_riscv64",
"qemu_x86",
"stm32f746g_disco",
)

@classmethod
def _has_fpu(cls, zephyr_board):
return zephyr_board in cls._KNOWN_FPU_ZEPHYR_BOARDS
fpu_boards = [name for name, board in BOARD_PROPERTIES.items() if board["fpu"]]
return zephyr_board in fpu_boards

def flash(self, options):
if self._is_qemu(options):
Expand Down
24 changes: 22 additions & 2 deletions docker/bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#
# Usage: docker/bash.sh [-i|--interactive] [--net=host] [-t|--tty]
# [--mount MOUNT_DIR] [--repo-mount-point REPO_MOUNT_POINT]
# [--dry-run]
# [--dry-run] [--name NAME]
# <DOCKER_IMAGE_NAME> [--] [COMMAND]
#
# Usage: docker/bash.sh <CONTAINER_NAME>
Expand All @@ -40,7 +40,7 @@ function show_usage() {
cat <<EOF
Usage: docker/bash.sh [-i|--interactive] [--net=host] [-t|--tty]
[--mount MOUNT_DIR] [--repo-mount-point REPO_MOUNT_POINT]
[--dry-run]
[--dry-run] [--name NAME]
<DOCKER_IMAGE_NAME> [--] [COMMAND]
-h, --help
Expand Down Expand Up @@ -85,6 +85,11 @@ Usage: docker/bash.sh [-i|--interactive] [--net=host] [-t|--tty]
Print the docker command to be run, but do not execute it.
--name
Set the name of the docker container, and the hostname that will
appear inside the container.
DOCKER_IMAGE_NAME
The name of the docker container to be run. This can be an
Expand Down Expand Up @@ -118,6 +123,7 @@ USE_NET_HOST=false
DOCKER_IMAGE_NAME=
COMMAND=bash
MOUNT_DIRS=( )
CONTAINER_NAME=

# TODO(Lunderberg): Remove this if statement and always set to
# "${REPO_DIR}". The consistent directory for Jenkins is currently
Expand Down Expand Up @@ -180,6 +186,15 @@ while (( $# )); do
shift
;;

--name)
if [[ -n "$2" ]]; then
CONTAINER_NAME="$2"
shift 2
else
parse_error 'ERROR: --name requires a non empty argument'
fi
;;

--dry-run)
DRY_RUN=true
shift
Expand Down Expand Up @@ -312,6 +327,11 @@ if ${TTY}; then
DOCKER_FLAGS+=( --tty )
fi

# Setup the docker name and the hostname inside the container
if [[ ! -z "${CONTAINER_NAME}" ]]; then
DOCKER_FLAGS+=( --name ${CONTAINER_NAME} --hostname ${CONTAINER_NAME})
fi

# Expose external directories to the docker container
for MOUNT_DIR in ${MOUNT_DIRS[@]+"${MOUNT_DIRS[@]}"}; do
DOCKER_MOUNT+=( --volume "${MOUNT_DIR}:${MOUNT_DIR}" )
Expand Down
12 changes: 11 additions & 1 deletion docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
# Usage: build.sh <CONTAINER_TYPE> [--tag <DOCKER_IMAGE_TAG>]
# [--dockerfile <DOCKERFILE_PATH>] [-it]
# [--net=host] [--cache-from <IMAGE_NAME>]
# [--context-path <CONTEXT_PATH>] [<COMMAND>]
# [--name CONTAINER_NAME] [--context-path <CONTEXT_PATH>]
# [<COMMAND>]
#
# CONTAINER_TYPE: Type of the docker container used the run the build,
# e.g. "ci_cpu", "ci_gpu"
Expand All @@ -38,6 +39,9 @@
# IMAGE_NAME: An image to be as a source for cached layers when building the
# Docker image requested.
#
# CONTAINER_NAME: The name of the docker container, and the hostname that will
# appear inside the container.
#
# CONTEXT_PATH: Path to be used for relative path resolution when building
# the Docker images.
#
Expand Down Expand Up @@ -95,6 +99,12 @@ else
echo "Using default context path: ${DOCKER_CONTEXT_PATH}"
fi

if [[ "$1" == "--name" ]]; then
CI_DOCKER_EXTRA_PARAMS+=("--name ${2} --hostname ${2}")
echo "Using container name ${2}"
shift 2
fi

if [[ ! -f "${DOCKERFILE_PATH}" ]]; then
echo "Invalid Dockerfile path: \"${DOCKERFILE_PATH}\""
exit 1
Expand Down
3 changes: 2 additions & 1 deletion docker/install/ubuntu_install_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ set -o pipefail

# install libraries for building c++ core on ubuntu
apt-get update && apt-get install -y --no-install-recommends \
git make libgtest-dev cmake wget unzip libtinfo-dev libz-dev\
git make google-mock libgtest-dev cmake wget unzip libtinfo-dev libz-dev \
libcurl4-openssl-dev libssl-dev libopenblas-dev g++ sudo \
apt-transport-https graphviz pkg-config curl


cd /usr/src/gtest && cmake CMakeLists.txt && make && cp *.a /usr/lib
cd /usr/src/gmock && cmake CMakeLists.txt && make && cp *.a /usr/lib
2 changes: 1 addition & 1 deletion docker/install/ubuntu_install_paddle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ set -e
set -u
set -o pipefail

pip install paddlepaddle==2.1.2
pip install paddlepaddle==2.1.3
Loading

0 comments on commit ec71db0

Please sign in to comment.