Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions apps/microtvm/cmsisnn/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ PKG_CFLAGS = ${PKG_COMPILE_OPTS} \
-I${STANDALONE_CRT_PATH}/include \
-I${STANDALONE_CRT_PATH}/src/runtime/crt/include \
-I${PWD}/include \
-I${CORSTONE_300_PATH} \
-I${ETHOSU_PLATFORM_PATH}/drivers/uart/include \
-I${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Include/ \
-I${CMSIS_PATH}/CMSIS/Core/Include \
-I${CMSIS_PATH}/CMSIS-NN/Include \
-I${CMSIS_PATH}/CMSIS/DSP/Include \
-I$(abspath $(BUILD_DIR))/codegen/host/include
CMSIS_NN_CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=$(abspath $(BUILD_DIR))/../arm-none-eabi-gcc.cmake \
-DTARGET_CPU=cortex-m55 \
-DBUILD_CMSIS_NN_FUNCTIONS=YES
CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=$(abspath $(BUILD_DIR))/../arm-none-eabi-gcc.cmake \
-DTARGET_CPU=cortex-m55
PKG_LDFLAGS = -lm -specs=nosys.specs -static -T corstone300.ld

$(ifeq VERBOSE,1)
Expand All @@ -57,7 +56,7 @@ CODEGEN_SRCS = $(wildcard $(abspath $(BUILD_DIR))/codegen/host/src/*.c)
CODEGEN_OBJS = $(subst .c,.o,$(CODEGEN_SRCS))
CMSIS_STARTUP_SRCS = $(wildcard ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/*.c)
CMSIS_NN_SRCS = $(shell find ${CMSIS_PATH}/CMSIS-NN/Source/*/*.c)
UART_SRCS = $(wildcard ${CORSTONE_300_PATH}/*.c)
CORSTONE_300_SRCS = $(wildcard ${CORSTONE_300_PATH}/*.c)

demo: $(BUILD_DIR)/demo

Expand Down Expand Up @@ -89,9 +88,15 @@ ${BUILD_DIR}/libcmsis_nn.a: $(CMSIS_NN_SRCS)
$(QUIET)$(AR) -cr $(abspath $(BUILD_DIR)/libcmsis_nn.a) $(abspath $(BUILD_DIR))/libcmsis_nn/*.o
$(QUIET)$(RANLIB) $(abspath $(BUILD_DIR)/libcmsis_nn.a)

# Build UART driver
${BUILD_DIR}/ethosu_core_platform/libethosu_uart_cmsdk_apb.a:
$(QUIET)mkdir -p $(@D)
$(QUIET)cd ${ETHOSU_PLATFORM_PATH}/drivers/uart && $(CMAKE) -B $(abspath $(BUILD_DIR)/ethosu_core_platform) $(CMAKE_FLAGS)
$(QUIET)cd $(abspath $(BUILD_DIR)/ethosu_core_platform) && $(MAKE)

# Build demo application
$(BUILD_DIR)/demo: $(DEMO_MAIN) $(UART_SRCS) $(BUILD_DIR)/stack_allocator.o $(BUILD_DIR)/crt_backend_api.o \
${BUILD_DIR}/libcodegen.a ${BUILD_DIR}/libcmsis_startup.a ${BUILD_DIR}/libcmsis_nn.a
$(BUILD_DIR)/demo: $(DEMO_MAIN) $(CORSTONE_300_SRCS) $(BUILD_DIR)/stack_allocator.o $(BUILD_DIR)/crt_backend_api.o \
${BUILD_DIR}/libcodegen.a ${BUILD_DIR}/libcmsis_startup.a ${BUILD_DIR}/libcmsis_nn.a ${BUILD_DIR}/ethosu_core_platform/libethosu_uart_cmsdk_apb.a
$(QUIET)mkdir -p $(@D)
$(QUIET)$(CC) $(PKG_CFLAGS) $(FREERTOS_FLAGS) -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive $(PKG_LDFLAGS)

Expand Down
4 changes: 2 additions & 2 deletions apps/microtvm/cmsisnn/src/demo_bare_metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
#include <tvm_runtime.h>
#include <tvmgen_detection.h>

#include "uart.h"
#include "uart_stdout.h"

// Header files generated by convert_image.py
#include "inputs.h"
#include "outputs.h"

int main(int argc, char** argv) {
uart_init();
UartStdOutInit();
printf("Starting Demo\n");

printf("Running detection inference\n");
Expand Down
24 changes: 14 additions & 10 deletions apps/microtvm/ethosu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,18 @@ PKG_CFLAGS = ${PKG_COMPILE_OPTS} \
-I${STANDALONE_CRT_PATH}/include \
-I${STANDALONE_CRT_PATH}/src/runtime/crt/include \
-I${PWD}/include \
-I${CORSTONE_300_PATH} \
-I${ETHOSU_PATH}/core_driver/include \
-I${ETHOSU_DRIVER_PATH}/include \
-I${ETHOSU_PLATFORM_PATH}/drivers/uart/include \
-I${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Include/ \
-I${CMSIS_PATH}/CMSIS/Core/Include \
-I${CMSIS_PATH}/CMSIS-NN/Include \
-I${CMSIS_PATH}/CMSIS/DSP/Include \
-I$(abspath $(BUILD_DIR))/codegen/host/include \
-DETHOSU_TEST_RUNNER_TOL=${ETHOSU_TEST_RUNNER_TOL}
DRIVER_CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=$(abspath $(BUILD_DIR))/../arm-none-eabi-gcc.cmake \
-DETHOSU_LOG_SEVERITY=debug \
-DCMAKE_SYSTEM_PROCESSOR=cortex-m55
CMSIS_NN_CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=$(abspath $(BUILD_DIR))/../arm-none-eabi-gcc.cmake \
-DTARGET_CPU=cortex-m55 \
-DBUILD_CMSIS_NN_FUNCTIONS=YES
CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=$(abspath $(BUILD_DIR))/../arm-none-eabi-gcc.cmake \
-DTARGET_CPU=cortex-m55
DRIVER_CMAKE_FLAGS = $(CMAKE_FLAGS) \
-DETHOSU_LOG_SEVERITY=debug
PKG_LDFLAGS = -lm -specs=nosys.specs -static -T corstone300.ld

$(ifeq VERBOSE,1)
Expand Down Expand Up @@ -79,7 +77,7 @@ CODEGEN_SRCS = $(wildcard $(abspath $(BUILD_DIR))/codegen/host/src/*.c)
CODEGEN_OBJS = $(subst .c,.o,$(CODEGEN_SRCS))
CMSIS_STARTUP_SRCS = $(wildcard ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/*.c)
CMSIS_NN_SOFTMAX_SRCS = $(shell find ${CMSIS_PATH}/CMSIS-NN/Source/SoftmaxFunctions/*.c)
UART_SRCS = $(wildcard ${CORSTONE_300_PATH}/*.c)
CORSTONE_300_SRCS = $(wildcard ${CORSTONE_300_PATH}/*.c)

demo: $(BUILD_DIR)/demo

Expand Down Expand Up @@ -117,7 +115,13 @@ ${BUILD_DIR}/libcmsis_nn_softmax.a: $(CMSIS_NN_SOFTMAX_SRCS)
$(QUIET)$(AR) -cr $(abspath $(BUILD_DIR)/libcmsis_nn_softmax.a) $(abspath $(BUILD_DIR))/libcmsis_nn/*.o
$(QUIET)$(RANLIB) $(abspath $(BUILD_DIR)/libcmsis_nn_softmax.a)

$(BUILD_DIR)/demo: $(DEMO_MAIN) src/tvm_ethosu_runtime.c $(FREERTOS_SOURCES) $(UART_SRCS) $(BUILD_DIR)/stack_allocator.o $(BUILD_DIR)/crt_backend_api.o ${BUILD_DIR}/libcodegen.a ${BUILD_DIR}/libcmsis_startup.a ${BUILD_DIR}/ethosu_core_driver/libethosu_core_driver.a ${BUILD_DIR}/libcmsis_nn_softmax.a
# Build UART driver
${BUILD_DIR}/ethosu_core_platform/libethosu_uart_cmsdk_apb.a:
$(QUIET)mkdir -p $(@D)
$(QUIET)cd ${ETHOSU_PLATFORM_PATH}/drivers/uart && $(CMAKE) -B $(abspath $(BUILD_DIR)/ethosu_core_platform) $(CMAKE_FLAGS)
$(QUIET)cd $(abspath $(BUILD_DIR)/ethosu_core_platform) && $(MAKE)

$(BUILD_DIR)/demo: $(DEMO_MAIN) src/tvm_ethosu_runtime.c $(FREERTOS_SOURCES) $(CORSTONE_300_SRCS) $(BUILD_DIR)/stack_allocator.o $(BUILD_DIR)/crt_backend_api.o ${BUILD_DIR}/libcodegen.a ${BUILD_DIR}/libcmsis_startup.a ${BUILD_DIR}/ethosu_core_driver/libethosu_core_driver.a ${BUILD_DIR}/libcmsis_nn_softmax.a ${BUILD_DIR}/ethosu_core_platform/libethosu_uart_cmsdk_apb.a
$(QUIET)mkdir -p $(@D)
$(QUIET)$(CC) $(PKG_CFLAGS) $(FREERTOS_FLAGS) -o $@ $^ $(PKG_LDFLAGS)

Expand Down
4 changes: 2 additions & 2 deletions apps/microtvm/ethosu/src/demo_bare_metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <tvm_runtime.h>

#include "ethosu_mod.h"
#include "uart.h"
#include "uart_stdout.h"

// Header files generated by convert_image.py and convert_labels.py
#include "inputs.h"
Expand All @@ -31,7 +31,7 @@
int abs(int v) { return v * ((v > 0) - (v < 0)); }

int main(int argc, char** argv) {
uart_init();
UartStdOutInit();
printf("Starting Demo\n");
EthosuInit();

Expand Down
4 changes: 2 additions & 2 deletions apps/microtvm/ethosu/src/demo_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <tvm_runtime.h>

#include "ethosu_mod.h"
#include "uart.h"
#include "uart_stdout.h"

// Header files generated by convert_image.py and convert_labels.py
#include "inputs.h"
Expand All @@ -46,7 +46,7 @@ static QueueHandle_t xQueue = NULL;

int main(void) {
// Platform UART
uart_init();
UartStdOutInit();
// NPU
EthosuInit();

Expand Down
2 changes: 1 addition & 1 deletion ci/jenkins/docker-images.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# This data file is read during when Jenkins runs job to determine docker images.
[jenkins]
ci_arm: tlcpack/ci-arm:20221013-060115-61c9742ea
ci_cortexm: tlcpack/ci-cortexm:20230111-165944-a9c6f137d
ci_cortexm: tlcpack/ci-cortexm:20230116-133924-dad13d1c1
ci_cpu: tlcpack/ci-cpu:20230110-070003-d00168ffb
ci_gpu: tlcpack/ci-gpu:20221128-070141-ae4fd7df7
ci_hexagon: tlcpack/ci-hexagon:20221013-060115-61c9742ea
Expand Down
12 changes: 8 additions & 4 deletions docker/install/ubuntu_install_ethosu_driver_stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -o pipefail
fvp_dir="/opt/arm/FVP_Corstone_SSE-300"
cmake_dir="/opt/arm/cmake"
ethosu_dir="/opt/arm/ethosu"
ethosu_driver_ver="21.11"
ethosu_driver_ver="22.08"

mkdir -p /opt/arm

Expand Down Expand Up @@ -80,9 +80,13 @@ git clone --branch ${ethosu_driver_ver} "https://review.mlplatform.org/ml/ethos-
git clone --branch ${ethosu_driver_ver} "https://review.mlplatform.org/ml/ethos-u/ethos-u-core-platform" core_platform

# Build Driver
mkdir ${ethosu_dir}/core_driver/build && cd ${ethosu_dir}/core_driver/build
cmake -DCMAKE_TOOLCHAIN_FILE=${ethosu_dir}/core_platform/cmake/toolchain/arm-none-eabi-gcc.cmake -DETHOSU_LOG_SEVERITY=debug -DTARGET_CPU=cortex-m55 ..
make
NPU_VARIANTS=("u55" "u65")
for i in ${NPU_VARIANTS[*]}
do
mkdir ${ethosu_dir}/core_driver/build_${i} && cd ${ethosu_dir}/core_driver/build_${i}
cmake -DCMAKE_TOOLCHAIN_FILE=${ethosu_dir}/core_platform/cmake/toolchain/arm-none-eabi-gcc.cmake -DETHOSU_LOG_SEVERITY=debug -DTARGET_CPU=cortex-m55 -DETHOSU_TARGET_NPU_CONFIG=ethos-${i}-128 ..
make
done

# Build NN Library
mkdir ${CMSIS_PATH}/CMSIS-NN/build/ && cd ${CMSIS_PATH}/CMSIS-NN/build/
Expand Down
4 changes: 2 additions & 2 deletions gallery/how_to/work_with_microtvm/micro_ethosu.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
# #include <tvm_runtime.h>
#
# #include "ethosu_mod.h"
# #include "uart.h"
# #include "uart_stdout.h"
#
# // Header files generated by convert_image.py and convert_labels.py
# #include "inputs.h"
Expand All @@ -390,7 +390,7 @@
# int abs(int v) { return v * ((v > 0) - (v < 0)); }
#
# int main(int argc, char** argv) {
# uart_init();
# UartStdOutInit();
# printf("Starting Demo\n");
# EthosuInit();
#
Expand Down
8 changes: 4 additions & 4 deletions python/tvm/micro/testing/aot_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
AOT_CORSTONE300_RUNNER = AOTTestRunner(
makefile="corstone300",
prologue="""
uart_init();
UartStdOutInit();
""",
includes=["uart.h"],
includes=["uart_stdout.h"],
pass_config={
"relay.ext.cmsisnn.options": {
"mcpu": "cortex-m55",
Expand All @@ -54,9 +54,9 @@
AOT_USMP_CORSTONE300_RUNNER = AOTTestRunner(
makefile="corstone300",
prologue="""
uart_init();
UartStdOutInit();
""",
includes=["uart.h"],
includes=["uart_stdout.h"],
pass_config={
"relay.ext.cmsisnn.options": {
"mcpu": "cortex-m55",
Expand Down
4 changes: 2 additions & 2 deletions tests/python/contrib/test_cmsisnn/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ def create_test_runner(compiler_cpu="cortex-m55", cpu_flags=""):
return AOTTestRunner(
makefile="corstone300",
prologue="""
uart_init();
UartStdOutInit();
""",
includes=["uart.h"],
includes=["uart_stdout.h"],
pass_config={
"relay.ext.cmsisnn.options": {
"mcpu": compiler_cpu + cpu_flags,
Expand Down
4 changes: 2 additions & 2 deletions tests/python/contrib/test_ethosu/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def create_test_runner(
ethosu_variant = ethosu_variant.upper()

prologue = """
uart_init();
UartStdOutInit();
EthosuInit();

struct ethosu_driver* ethos_u = ethosu_reserve_driver();
Expand All @@ -158,7 +158,7 @@ def create_test_runner(
epilogue="""
ethosu_release_driver(ethos_u);
""",
includes=["uart.h", "ethosu_55.h", "ethosu_mod.h", "hard_fault.h"],
includes=["uart_stdout.h", "ethosu_55.h", "ethosu_mod.h", "hard_fault.h"],
parameters={
"ETHOSU_TEST_ROOT": test_root,
"NPU_MACS": ethosu_macs,
Expand Down
33 changes: 20 additions & 13 deletions tests/python/relay/aot/corstone300.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ DMLC_CORE=${TVM_ROOT}/3rdparty/dmlc-core
ETHOSU_PATH=/opt/arm/ethosu
DRIVER_PATH=${ETHOSU_PATH}/core_driver
CMSIS_PATH=${ETHOSU_PATH}/cmsis
PLATFORM_PATH=${ETHOSU_PATH}/core_platform/targets/corstone-300
ETHOSU_PLATFORM_PATH=/opt/arm/ethosu/core_platform
CORSTONE_300_PATH = ${ETHOSU_PLATFORM_PATH}/targets/corstone-300
PKG_COMPILE_OPTS = -g -Wall -O2 -Wno-incompatible-pointer-types -Wno-format -Werror-implicit-function-declaration -mcpu=${MCPU}${MCPU_FLAGS} -mthumb -mfloat-abi=${MFLOAT_ABI} -std=gnu99
CMAKE = /opt/arm/cmake/bin/cmake
CC = arm-none-eabi-gcc
Expand All @@ -53,16 +54,15 @@ PKG_CFLAGS = ${PKG_COMPILE_OPTS} \
-I$(build_dir)/../include \
-I${TVM_ROOT}/src/runtime/contrib/ethosu/bare_metal \
-I$(CODEGEN_ROOT)/host/include \
-I${PLATFORM_PATH} \
-I${ETHOSU_PLATFORM_PATH}/drivers/uart/include \
-I${DRIVER_PATH}/include \
-I${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Include/ \
-I${CMSIS_PATH}/CMSIS/Core/Include \
-I${CMSIS_PATH}/CMSIS-NN/Include \
-I${CMSIS_PATH}/CMSIS/DSP/Include \
-isystem$(STANDALONE_CRT_DIR)/include
DRIVER_CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=$(ETHOSU_TEST_ROOT)/arm-none-eabi-gcc.cmake \
-DETHOSU_LOG_SEVERITY=debug \
-DCMAKE_SYSTEM_PROCESSOR=cortex-m55
CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=${TVM_ROOT}/tests/python/contrib/test_ethosu/reference_system/arm-none-eabi-gcc.cmake \
-DCMAKE_SYSTEM_PROCESSOR=${MCPU}

PKG_LDFLAGS = -lm -specs=nosys.specs -static -T ${AOT_TEST_ROOT}/corstone300.ld

Expand All @@ -79,10 +79,11 @@ C_CODEGEN_OBJS = $(subst .c,.o,$(C_CODEGEN_SRCS))
CC_CODEGEN_OBJS = $(subst .cc,.o,$(CC_CODEGEN_SRCS))
CMSIS_STARTUP_SRCS = $(shell find ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/*.c)
CMSIS_NN_SRCS = $(shell find ${CMSIS_PATH}/CMSIS-NN/Source/*/*.c)
UART_SRCS = $(shell find ${PLATFORM_PATH}/*.c)
CORSTONE_300_SRCS = $(shell find ${CORSTONE_300_PATH}/*.c)

ifdef ETHOSU_TEST_ROOT
ETHOSU_DRIVER_LIBS = $(wildcard ${DRIVER_PATH}/build/*.a)
NPU=$(shell echo "${NPU_VARIANT}" | tr '[:upper:]' '[:lower:]')
ETHOSU_DRIVER_LIBS = ${DRIVER_PATH}/build_${NPU}/*.a
ETHOSU_RUNTIME=$(build_dir)/tvm_ethosu_runtime.o
ETHOSU_INCLUDE=-I$(ETHOSU_TEST_ROOT)
endif
Expand Down Expand Up @@ -118,13 +119,19 @@ ${build_dir}/libcmsis_nn.a: $(CMSIS_NN_SRCS)
$(QUIET)$(AR) -cr $(abspath $(build_dir)/libcmsis_nn.a) $(abspath $(build_dir))/libcmsis_nn/*.o
$(QUIET)$(RANLIB) $(abspath $(build_dir)/libcmsis_nn.a)

${build_dir}/libuart.a: $(UART_SRCS)
$(QUIET)mkdir -p $(abspath $(build_dir)/libuart)
$(QUIET)cd $(abspath $(build_dir)/libuart) && $(CC) -c $(PKG_CFLAGS) $^
$(QUIET)$(AR) -cr $(abspath $(build_dir)/libuart.a) $(abspath $(build_dir))/libuart/*.o
$(QUIET)$(RANLIB) $(abspath $(build_dir)/libuart.a)
${build_dir}/libcorstone.a: $(CORSTONE_300_SRCS)
$(QUIET)mkdir -p $(abspath $(build_dir)/libcorstone)
$(QUIET)cd $(abspath $(build_dir)/libcorstone) && $(CC) -c $(PKG_CFLAGS) $^
$(QUIET)$(AR) -cr $(abspath $(build_dir)/libcorstone.a) $(abspath $(build_dir))/libcorstone/*.o
$(QUIET)$(RANLIB) $(abspath $(build_dir)/libcorstone.a)

$(build_dir)/aot_test_runner: $(build_dir)/test.c $(build_dir)/crt_backend_api.o $(build_dir)/stack_allocator.o $(build_dir)/libcodegen.a ${build_dir}/libcmsis_startup.a ${build_dir}/libcmsis_nn.a ${build_dir}/libuart.a $(ETHOSU_DRIVER_LIBS) $(ETHOSU_RUNTIME)
# Build UART driver
${build_dir}/ethosu_core_platform/libethosu_uart_cmsdk_apb.a:
$(QUIET)mkdir -p $(@D)
$(QUIET)cd ${ETHOSU_PLATFORM_PATH}/drivers/uart && $(CMAKE) -B $(abspath $(build_dir)/ethosu_core_platform) $(CMAKE_FLAGS)
$(QUIET)cd $(abspath $(build_dir)/ethosu_core_platform) && $(MAKE)

$(build_dir)/aot_test_runner: $(build_dir)/test.c $(build_dir)/crt_backend_api.o $(build_dir)/stack_allocator.o $(build_dir)/libcodegen.a ${build_dir}/libcmsis_startup.a ${build_dir}/libcmsis_nn.a ${build_dir}/libcorstone.a ${build_dir}/ethosu_core_platform/libethosu_uart_cmsdk_apb.a $(ETHOSU_DRIVER_LIBS) $(ETHOSU_RUNTIME)
$(QUIET)mkdir -p $(@D)
$(QUIET)$(CC) $(PKG_CFLAGS) $(ETHOSU_INCLUDE) -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive $(PKG_LDFLAGS)

Expand Down