sipeed / MaixPy-v1

MicroPython for K210 RISC-V, let's play with edge AI easier
https://wiki.sipeed.com/maixpy
Other
1.68k stars 438 forks source link

MaixPy project build error for TensorFlow Lite Micro Hello world example #414

Open marconi1964 opened 3 years ago

marconi1964 commented 3 years ago

Describe the bug I tried to build MaixPy with TensorFlow Lite Micro hello world example, but fail in finding *.h in MaixPy build. I am not familiar with cmake build, does not know how to add "include" directory in source directory CMakeLists.txt. The (partial of) CMakeLists.txt in source directory is listed below.

A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Build TensorFlow Lite Micro (TFLM) source code, and copy source code from TFLM to maixpy directory.
    
    # download MaixPy
    $ git clone https://github.com/sipeed/maixpy
    # Create a new directory for TFLM hello world
    $ mkdir -p maixpy/projects/TFLM_hello_world
    # Copy MaixPy hello world template directory to TLFM hello world
    $ cp -r maixpy/projects/hello_world/ maixpy/projects/TLFM_hello_world/
    # download TensorFlow
    $ git clone https://github.com/tensorflow/tensorflow.git
    $ cd tensorflow
    # TensorFlow Lite Micro build source files structure
    $ make -f tensorflow/lite/micro/tools/make/Makefile TARGET=riscv32_mcu generate_hello_world_make_project
    $ cd tensorflow/lite/micro/tools/make/gen/riscv32_mcu_riscv32_mcu_micro/prj/hello_world/make
    $ ls -l
    total 40
    -rw-r--r-- 1 ubuntu ubuntu 15503 Apr 20 07:43 LICENSE
    -rw-r--r-- 1 ubuntu ubuntu 11291 Apr 20 07:43 Makefile
    -rw-r--r-- 1 ubuntu ubuntu   810 Apr 20 07:43 README_MAKE.md
    drwxr-xr-x 3 ubuntu ubuntu  4096 Apr 20 07:43 tensorflow
    drwxr-xr-x 6 ubuntu ubuntu  4096 Apr 20 07:43 third_party

$ cp -r ./ ~/maixpy/projects/TFLM_hello_world

2. Modify source directory CMakeLists.txt "Add source files", based on TFLM Makefile content (SRCS:= \.....)

$ cd maixpy/TFLM_hello_world/main/ $ cat CMakeLists.txt ############### Add include ################### list(APPEND ADD_INCLUDE "." )

list(APPEND ADD_PRIVATE_INCLUDE "")

###############################################

############ Add source files ################# list(APPEND ADD_SRCS "tensorflow/lite/micro/simple_memory_allocator.cc" "tensorflow/lite/micro/simple_memory_allocator.h" "tensorflow/lite/micro/micro_error_reporter.cc" "tensorflow/lite/micro/all_ops_resolver.cc" "tensorflow/lite/micro/memory_helpers.cc" .... "tensorflow/lite/micro/examples/hello_world/main.cc" "tensorflow/lite/micro/examples/hello_world/main_functions.cc" "tensorflow/lite/micro/examples/hello_world/model.cc" "tensorflow/lite/micro/examples/hello_world/output_handler.cc" "tensorflow/lite/micro/examples/hello_world/constants.cc" "tensorflow/lite/micro/tools/make/downloads/sifive_fe310_lib/bsp/libwrap/misc/write_hex.c" "tensorflow/lite/micro/tools/make/downloads/sifive_fe310_lib/bsp/libwrap/stdlib/malloc.c" "tensorflow/lite/micro/tools/make/downloads/sifive_fe310_lib/bsp/env/start.S" "tensorflow/lite/micro/tools/make/downloads/sifive_fe310_lib/bsp/env/entry.S" "tensorflow/lite/micro/tools/make/downloads/sifive_fe310_lib/bsp/env/freedom-e300-hifive1/init.c" "tensorflow/lite/micro/arduino/abi.cc" )

aux_source_directory(src ADD_SRCS)

list(REMOVE_ITEM COMPONENT_SRCS "src/test2.c")

###############################################

Add required/dependent components

list(APPEND ADD_REQUIREMENTS kendryte_sdk) ###############################################

############ Add static libs ##################

list(APPEND ADD_STATIC_LIB "lib/libtest.a")

###############################################

register_component()


3. MaixPy build and error occurs

$ cd ~/maixpy/projects/TFLM_hello_world $ python3 project.py build ..... In file included from /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/quantization_util.h:23, from /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/quantization_util.cc:16: /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/cppmath.h: In function 'T tflite::TfLiteRound(T)': /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/cppmath.h:36:41: error: 'round' is not a member of 'std' DECLARE_STD_GLOBAL_SWITCH1(TfLiteRound, round); ^~~~~ /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/cppmath.h:33:39: note: in definition of macro 'DECLARE_STD_GLOBAL_SWITCH1' return TF_LITE_GLOBAL_STD_PREFIX::std_name(x); \ ^~~~ /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/cppmath.h:36:41: note: suggested alternative: DECLARE_STD_GLOBAL_SWITCH1(TfLiteRound, round); ^~~~~ /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/cppmath.h:33:39: note: in definition of macro 'DECLARE_STD_GLOBAL_SWITCH1' return TF_LITE_GLOBAL_STD_PREFIX::std_name(x); \ ^~~~ In file included from /opt/kendryte-toolchain/riscv64-unknown-elf/include/c++/8.2.0/cmath:45, from /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/quantization_util.h:18, from /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/quantization_util.cc:16: /opt/kendryte-toolchain/riscv64-unknown-elf/include/math.h:308:15: note: 'round' extern double round (double); ^~~~~ In file included from /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/quantization_util.h:23, from /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/quantization_util.cc:16: /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/cppmath.h: In function 'T tflite::TfLiteExpm1(T)': /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/cppmath.h:37:41: error: 'expm1' is not a member of 'std' DECLARE_STD_GLOBAL_SWITCH1(TfLiteExpm1, expm1); ^~~~~ /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/cppmath.h:33:39: note: in definition of macro 'DECLARE_STD_GLOBAL_SWITCH1' return TF_LITE_GLOBAL_STD_PREFIX::std_name(x); \ ^~~~ /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/cppmath.h:37:41: note: suggested alternative: 'exp' DECLARE_STD_GLOBAL_SWITCH1(TfLiteExpm1, expm1); ^~~~~ /home/ubuntu/maixpy/projects/amigo_tflm/main/tensorflow/lite/kernels/internal/cppmath.h:33:39: note: in definition of macro 'DECLARE_STD_GLOBAL_SWITCH1' return TF_LITE_GLOBAL_STD_PREFIX::std_name(x); \ ^~~~



**Please complete the following information**
 - IDE version: 
 - Firmware version:
 - Board: Maix Amigo
 - OS: Linux Ubuntu 18.04
zhongpanwu commented 2 years ago

Hi, have you solved this problem , could you give me some clues, thank you

Neutree commented 2 years ago

uset python project.py rebuild --verbose to see what dependence or something wrong