fastmachinelearning / hls4ml

Machine learning on FPGAs using HLS
https://fastmachinelearning.org/hls4ml
Apache License 2.0
1.22k stars 396 forks source link

error with windows implementation and absolute paths #121

Closed nhanvtran closed 4 years ago

nhanvtran commented 5 years ago

screenshot 1 1

vloncar commented 5 years ago

Is there any way to get the project directory with the generated files (my-hls-test)? This looks like a issue with space in the in the included path. On Linux, I can reproduce it by changing the cflags to -I/path/to/ nnet_utils Compiler interprets nnet_utils as another compilation unit next to myproject.cpp which doesn't exist. If the path was non-existent (but without the space) the error would be related missing .h files. The directory from Windows would be handy to see what was generated.

nhanvtran commented 5 years ago

thanks @vloncar I pinged the user who had the issue and requested a project that reproduces the error. I'll keep you posted.

yosukeueda33 commented 5 years ago

Sorry for my bad English. Below is my case. Maby that is the same situation with @nhanvtran . The environment was Windows10 Pro Japanese, Vivado HLS 2019.1, python 3.7, HLS4ML v0.1.3.

 PS C:\Users\user\Programs\hls4ml\HLS4ML\keras-to-hls\my-hls-test> vivado_hls -f .\build_prj.tcl

 ****** Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC v2019.1 (64-bit)
   **** SW Build 2552052 on Fri May 24 14:49:42 MDT 2019
   **** IP Build 2548770 on Fri May 24 18:01:18 MDT 2019
     ** Copyright 1986-2019 Xilinx, Inc. All Rights Reserved.

 source C:/Xilinx/Vivado/2019.1/scripts/vivado_hls/hls.tcl -notrace
 INFO: [HLS 200-10] Running 'C:/Xilinx/Vivado/2019.1/bin/unwrapped/win64.o/vivado_hls.exe'
 INFO: [HLS 200-10] For user 'user' on host 'desktop-hf0grnq' (Windows NT_amd64 version 6.2) on Thu Jul 18 16:39:11 +0900 20
 19
 INFO: [HLS 200-10] In directory 'C:/Users/user/Programs/hls4ml/HLS4ML/keras-to-hls/my-hls-test'
 Sourcing Tcl script '.\build_prj.tcl'
 INFO: [HLS 200-10] Opening and resetting project 'C:/Users/user/Programs/hls4ml/HLS4ML/keras-to-hls/my-hls-test/myproject_p
 rj'.
 INFO: [HLS 200-10] Adding design file 'firmware/myproject.cpp' to the project
 INFO: [HLS 200-10] Adding test bench file 'myproject_test.cpp' to the project
 INFO: [HLS 200-10] Adding test bench file 'firmware/weights' to the project
 INFO: [HLS 200-10] Opening and resetting solution 'C:/Users/user/Programs/hls4ml/HLS4ML/keras-to-hls/my-hls-test/myproject_
 prj/solution1'.
 INFO: [HLS 200-10] Cleaning up the solution database.
 INFO: [HLS 200-10] Setting target device to 'secret-device...'
 INFO: [SYN 201-201] Setting up clock 'default' with a period of 5ns.
 INFO: [SIM 211-2] *************** CSIM start ***************
 INFO: [SIM 211-4] CSIM will launch GCC as the compiler.
    Compiling ../../../../myproject_test.cpp in debug mode
 csim.mk:75: recipe for target 'obj/myproject_test.o' failed
 gcc.exe: error: net_utils: No such file or directory
 make: *** [obj/myproject_test.o] Error 1
 ERROR: [SIM 211-100] 'csim_design' failed: compilation error(s).
 INFO: [SIM 211-3] *************** CSIM finish ***************
 4
     while executing
 "source {.\build_prj.tcl}"
     ("uplevel" body line 1)
     invoked from within
 "uplevel \#0 [list source $arg] "

 INFO: [Common 17-206] Exiting vivado_hls at Thu Jul 18 16:39:13 2019...
 PS C:\Users\user\Programs\hls4ml\HLS4ML\keras-to-hls\my-hls-test>

I think there is a bug on hls_writer.py so the nnet_utils path is broken at build_prj.tcl. Below is my workaround by modification of build_prj.tcl line:5,6. This need to be done after python keras-to-hls.py -c keras-config.yml.

before:

add_files firmware/myproject.cpp -cflags "-I[file normalize ..\..\nnet_utils]"
add_files -tb myproject_test.cpp -cflags "-I[file normalize ..\..\nnet_utils]"

after:

add_files firmware/myproject.cpp -cflags "-I[file normalize ..\\..\\nnet_utils]"
add_files -tb myproject_test.cpp -cflags "-I[file normalize ..\\..\\nnet_utils]"

I'll try to modify & MR.

vloncar commented 5 years ago

@yosukeueda33 Can you try the fix from #131 ? It should fix the problem.

yosukeueda33 commented 5 years ago

Roger that!

vloncar commented 4 years ago

This is no longer an issue now that we bundle nnet_utils with generated projects.