Skip to content

Build TFLite Micro for riscv32_mcu #50347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chuantunglin opened this issue Jun 18, 2021 · 4 comments
Closed

Build TFLite Micro for riscv32_mcu #50347

chuantunglin opened this issue Jun 18, 2021 · 4 comments
Assignees
Labels
comp:micro Related to TensorFlow Lite Microcontrollers stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.4 for issues related to TF 2.4 type:build/install Build and install issues

Comments

@chuantunglin
Copy link

chuantunglin commented Jun 18, 2021

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 20.04
  • TensorFlow installed from (source or binary): N/A
  • TensorFlow version: Tensorflow 2.4.2
  • Python version: 3.8.5
  • Installed using virtualenv? pip? conda?: N/A
  • Bazel version (if compiling from source): N/A
  • GCC/Compiler version (if compiling from source): gcc 9.3.0, riscv64-unknown-elf-gcc (GCC) 10.2.0
  • CUDA/cuDNN version: N/A
  • GPU model and memory: N/A
  • Target platform (e.g. Arm Mbed OS, Arduino Nano 33 etc.): RISC-V

Describe the problem
Cannot build TFLite Micro for RISC-V target (TARGET=riscv32_mcu). The error message is shown at the bottom.
The command below doesn't work since the file riscv32_mcu_makefile.inc doesn't exist.
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=riscv32_mcu hello_world

Does anyone successfully build the hello_world example for RISCV (riscv32_mcu)?
What are the exact commands and steps?

Provide the exact sequence of commands / steps that you executed before running into the problem

  1. git clone --depth 1 https://github.com/tensorflow/tensorflow.git
  2. cd tensorflow
  3. vi tensorflow/lite/micro/tools/make/targets/mcu_riscv_makefile.inc
  4. change ifeq ($(TARGET), riscv32_mcu) to ifeq ($(TARGET), mcu_riscv)
  5. Move two FLAGS (-fno-threadsafe-statics and -fno-use-cxa-atexit) from PLATFORM_FLAGS to CXXFLAGS
  6. make -f tensorflow/lite/micro/tools/make/Makefile TARGET=mcu_riscv TARGET_ARCH=riscv32_mcu hello_world

Any other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

$ make -f tensorflow/lite/micro/tools/make/Makefile TARGET=mcu_riscv TARGET_ARCH=riscv32_mcu hello_world
tensorflow/lite/micro/tools/make/downloads/flatbuffers already exists, skipping the download.
tensorflow/lite/micro/tools/make/downloads/pigweed already exists, skipping the download.
tensorflow/lite/micro/tools/make/downloads/person_model_int8 already exists, skipping the download.
riscv64-unknown-elf-g++ -std=c++11 -fno-rtti -fno-exceptions -fno-threadsafe-statics -Werror -fno-unwind-tables -ffunction-sections -fdata-sections -fmessage-length=0 -DTF_LITE_STATIC_MEMORY -DTF_LITE_DISABLE_X86_NEON -O3 -Wsign-compare -Wdouble-promotion -Wshadow -Wunused-variable -Wmissing-field-initializers -Wunused-function -Wswitch -Wvla -Wall -Wextra -Wstrict-aliasing -Wno-unused-parameter -DMCU_RISCV -march=rv32imac -mabi=ilp32 -mcmodel=medany -mexplicit-relocs -fno-builtin-printf -fno-exceptions -DTF_LITE_MCU_DEBUG_LOG -DTF_LITE_USE_GLOBAL_CMATH_FUNCTIONS -fno-unwind-tables -ffunction-sections -fdata-sections -funsigned-char -Wvla -Wall -Wextra -Wsign-compare -Wdouble-promotion -Wshadow -Wunused-variable -Wmissing-field-initializers -Wno-unused-parameter -Wno-write-strings -Wunused-function -fno-delete-null-pointer-checks -fomit-frame-pointer -Os -fpermissive -fno-rtti -fno-threadsafe-statics -fno-use-cxa-atexit --std=gnu++11 -I. -Itensorflow/lite/micro/tools/make/downloads/gemmlowp -Itensorflow/lite/micro/tools/make/downloads/flatbuffers/include -Itensorflow/lite/micro/tools/make/downloads/ruy -Itensorflow/lite/micro/tools/make/downloads/sifive_fe310_lib/bsp/include -Itensorflow/lite/micro/tools/make/downloads/sifive_fe310_lib/bsp/drivers/ -Itensorflow/lite/micro/tools/make/downloads/sifive_fe310_lib/bsp/env -Itensorflow/lite/micro/tools/make/downloads/sifive_fe310_lib/bsp/env/freedom-e300-hifive1 -Itensorflow/lite/micro/tools/make/downloads/kissfft -o tensorflow/lite/micro/tools/make/gen/mcu_riscv_riscv32_mcu_micro/bin/hello_world tensorflow/lite/micro/tools/make/gen/mcu_riscv_riscv32_mcu_micro/obj/tensorflow/lite/micro/examples/hello_world/main.o tensorflow/lite/micro/tools/make/gen/mcu_riscv_riscv32_mcu_micro/obj/tensorflow/lite/micro/examples/hello_world/main_functions.o tensorflow/lite/micro/tools/make/gen/mcu_riscv_riscv32_mcu_micro/obj/tensorflow/lite/micro/examples/hello_world/model.o tensorflow/lite/micro/tools/make/gen/mcu_riscv_riscv32_mcu_micro/obj/tensorflow/lite/micro/examples/hello_world/output_handler.o tensorflow/lite/micro/tools/make/gen/mcu_riscv_riscv32_mcu_micro/obj/tensorflow/lite/micro/examples/hello_world/constants.o tensorflow/lite/micro/tools/make/gen/mcu_riscv_riscv32_mcu_micro/lib/libtensorflow-microlite.a -Wl,--fatal-warnings -Wl,--gc-sections -Ttensorflow/lite/micro/tools/make/downloads/sifive_fe310_lib/bsp/env/freedom-e300-hifive1/flash.lds -nostartfiles -Ltensorflow/lite/micro/tools/make/downloads/sifive_fe310_lib/bsp/env --specs=nano.specs -lm
/opt/riscv/lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: warning: cannot find entry symbol _start; not setting start address
collect2: error: ld returned 1 exit status
make: *** [tensorflow/lite/micro/examples/hello_world/Makefile.inc:44: tensorflow/lite/micro/tools/make/gen/mcu_riscv_riscv32_mcu_micro/bin/hello_world] Error 1

@chuantunglin chuantunglin added the type:build/install Build and install issues label Jun 18, 2021
@ymodak
Copy link
Contributor

ymodak commented Jun 18, 2021

I see tf-lite-micro has its own standalone repository now.
I see makefile inside respective example folders.
https://github.com/tensorflow/tflite-micro/blob/main/tensorflow/lite/micro/examples/hello_world/riscv32_mcu/Makefile.inc

@saikumarchalla saikumarchalla added the comp:micro Related to TensorFlow Lite Microcontrollers label Jun 19, 2021
@saikumarchalla saikumarchalla added TF 2.4 for issues related to TF 2.4 stat:awaiting response Status - Awaiting response from author labels Jun 19, 2021
@chuantunglin
Copy link
Author

Thanks for sharing the link. However, these examples still can't be successfully built for riscv32_mcu in tf-lite-micro's own repository.

If we want to build the example in this repository, are there any steps/commands that work well?

@ymodak ymodak added stat:awaiting tensorflower Status - Awaiting response from tensorflower and removed stat:awaiting response Status - Awaiting response from author labels Jun 20, 2021
@ymodak
Copy link
Contributor

ymodak commented Aug 25, 2021

Closing this issue in the light of tensorflow/tflite-micro#203
Thanks!

@ymodak ymodak closed this as completed Aug 25, 2021
@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:micro Related to TensorFlow Lite Microcontrollers stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.4 for issues related to TF 2.4 type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

4 participants