hls4ml 的这个问题如何解决?

问题描述 投票:0回答:2

免责声明:我在研究编译错误详细信息之前问了这个问题。 这个问题包含了这里解释的问题的答案。简而言之,异常定义中的变量类型定义错误会阻止综合的正确发生。

除非您愿意找到正确的

gcc
编译器来运行 Vivado Synthesis 而不会出现错误,否则我建议您使用 Linux 来完成此任务。


我正在尝试运行示例代码,如 hls4ml 的文档页面所示,但运行以下命令:

import hls4ml

#Fetch a keras model from our example repository
#This will download our example model to your working directory and return an example configuration file
config = hls4ml.utils.fetch_example_model('KERAS_3layer.json')

print(config) #You can print it to see some default parameters

#Convert it to a hls project
hls_model = hls4ml.converters.keras_to_hls(config)

#Use Vivado HLS to synthesize the model
#This might take several minutes
hls_model.build()

#Print out the report if you want
hls4ml.report.read_vivado_report('my-hls-test')

输出是

Downloading example model files ...
{'OutputDir': 'my-hls-test', 'ProjectName': 'myproject', 'XilinxPart': 'xcku115-flvb2104-2-i', 'ClockPeriod': 5, 'Backend': 'Vivado', 'IOType': 'io_parallel', 'HLSConfig': {'Model': {'Precision': 'ap_fixed<16,6>', 'ReuseFactor': '1'}}, 'KerasJson': 'KERAS_3layer.json', 'KerasH5': 'KERAS_3layer_weights.h5'}
Interpreting Model
Topology:
Layer name: input_1, layer type: InputLayer, current shape: [[None, 16]]
Layer name: fc1_relu, layer type: Dense, current shape: [[None, 16]]
Layer name: fc2_relu, layer type: Dense, current shape: [[None, 64]]
Layer name: fc3_relu, layer type: Dense, current shape: [[None, 32]]
Layer name: output_softmax, layer type: Dense, current shape: [[None, 32]]
Creating HLS model
Synthesis report not found.
Found 1 solution(s) in my-hls-test/myproject_prj.
Reports for solution "solution1":

C SIMULATION RESULT:
INFO: [SIM 2] *************** CSIM start ***************
INFO: [SIM 4] CSIM will launch GCC as the compiler.
make: 'csim.exe' is up to date.
INFO: Unable to open input/predictions file, using default input.
0.0292969 0.756836 0.0546875 0.139648 0.0371094 
INFO: Saved inference results to file: tb_data/csim_results.log
INFO: [SIM 1] CSim done with 0 errors.
INFO: [SIM 3] *************** CSIM finish ***************

Synthesis report not found.
Co-simulation report not found.

请注意,最后两行指的是构建过程和报告的返回。

我通过 Anaconda Navigator 在 Jupyter Notebook (6.0.3) 上运行它,Python 版本是 3.6.9,hls4ml 版本是 0.5.0

我不明白这是由于安装错误还是由于代码等等原因。

对于造成这种情况的原因有什么想法吗?


我认为这是 hls4ml 特有的,但遗憾的是它在 StackOverflow 中不作为标签存在。

更新

我遇到的最初问题(即我的目录有一个空格

' '
,这是非法字符)让我运行了
vivado_hls -f build_prj.tcl "csim=1 synth=1 cosim=1 export=1"
,这向我展示了一系列新的问题。也就是说,我收到这些错误:

***** C/RTL SYNTHESIS *****
INFO: [SCHED 204-61] Option 'relax_ii_for_timing' is enabled, will increase II to preserve clock frequency constraints.
INFO: [HLS 200-10] Analyzing design file 'firmware/myproject.cpp' ...
ERROR: [HLS 200-70] Compilation errors found: In file included from firmware/myproject.cpp:1:
In file included from firmware/myproject.cpp:19:
In file included from D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\iostream:39:
In file included from D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\ostream:39:
In file included from D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\ios:39:
In file included from D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\exception:151:
D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\exception_ptr.h:132:13: error: unknown type name 'type_info'
      const type_info*
            ^
In file included from firmware/myproject.cpp:1:
In file included from firmware/myproject.cpp:19:
In file included from D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\iostream:39:
In file included from D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\ostream:39:
In file included from D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\ios:39:
In file included from D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\exception:151:
D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\nested_exception.h:62:5: error: the parameter for this explicitly-defaulted copy constructor is const, but a member or base requires it to be non-const
    nested_exception(const nested_exception&) = default;
    ^
D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\nested_exception.h:64:23: error: the parameter for this explicitly-defaulted copy assignment operator is const, but a member or base requires it to be non-const
    nested_exception& operator=(const nested_exception&) = default;
                      ^
D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\nested_exception.h:77:28: error: exception specification in declaration does not match previous declaration
  inline nested_exception::~nested_exception() = default;
                           ^
D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\nested_exception.h:66:20: note: previous declaration is here
    inline virtual ~nested_exception();
                   ^
D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\nested_exception.h:122:61: error: redefinition of default argument
    __throw_with_nested(_Ex&& __ex, const nested_exception* = 0)
                                                            ^ ~
D:/Tools/Xilinx/Vivado/2019.2/win64/tools/clang/bin\..\lib\clang\3.1/../../../include/c++/4.5.2\nested_exception.h:110:56: note: previous definition is here
    __throw_with_nested(_Ex&&, const nested_exception* = 0)
                                                       ^ ~
In file included from firmware/myproject.cpp:1:
In file included from firmware/myproject.cpp:21:
In file included from firmware/myproject.h:23:
In file included from D:/Tools/Xilinx/Vivado/2019.2/common/technology/autopilot\ap_int.h:367:
In file included from D:/Tools/Xilinx/Vivado/2019.2/common/technology/autopilot\ap_fixed.h:55:
D:/Tools/Xilinx/Vivado/2019.2/common/technology/autopilot\ap_fixed_base.h:838:13: warning: shift count is negative [-Wshift-count-negative]
      ret.V <<= (_AP_I - _AP_W);
            ^   ~~~~~~~~~~~~~~~
D:/Tools/Xilinx/Vivado/2019.2/common/technology/autopilot\ap_fixed_base.h:869:69: note: in instantiation of member function 'ap_fixed_base<50, 40, true, 5, 3, 0>::to_ap_int_base' requested here
  inline __attribute__((always_inline)) int to_int() const { return to_ap_int_base().to_int(); }
                                                                    ^
D:/Tools/Xilinx/Vivado/2019.2/common/technology/autopilot\ap_fixed_base.h:1042:71: note: in instantiation of member function 'ap_fixed_base<50, 40, true, 5, 3, 0>::to_int' requested here
  inline __attribute__((always_inline)) operator int() const { return to_int(); }
                                                                      ^
firmware/nnet_utils/nnet_activation.h:389:17: note: in instantiation of member function 'ap_fixed_base<50, 40, true, 5, 3, 0>::operator int' requested here
   data_round = (data_cache[jj]-data_cache[ii])*CONFIG_T::table_size/16;
                ^
firmware/nnet_utils/nnet_activation.h:421:9: note: in instantiation of function template specialization 'nnet::softmax_legacy<ap_fixed<16, 6, 5, 3, 0>, ap_fixed<16, 6, 5, 3, 0>, softmax_config9>' requested here
        softmax_legacy<data_T, res_T, CONFIG_T>(data, res);
        ^
firmware/myproject.cpp:90:5: note: in instantiation of function template specialization 'nnet::softmax<ap_fixed<16, 6, 5, 3, 0>, ap_fixed<16, 6, 5, 3, 0>, softmax_config9>' requested here
    nnet::softmax<layer8_t, result_t, softmax_config9>(layer8_out, layer9_out);
    ^
In file included from firmware/myproject.cpp:1:
In file included from firmware/myproject.cpp:21:
In file included from firmware/myproject.h:23:
In file included from D:/Tools/Xilinx/Vivado/2019.2/common/technology/autopilot\ap_int.h:367:
In file included from D:/Tools/Xilinx/Vivado/2019.2/common/technology/autopilot\ap_fixed.h:55:
D:/Tools/Xilinx/Vivado/2019.2/common/technology/autopilot\ap_fixed_base.h:838:13: warning: shift count is negative [-Wshift-count-negative]
      ret.V <<= (_AP_I - _AP_W);
            ^   ~~~~~~~~~~~~~~~
D:/Tools/Xilinx/Vivado/2019.2/common/technology/autopilot\ap_fixed_base.h:869:69: note: in instantiation of member function 'ap_fixed_base<51, 41, true, 5, 3, 0>::to_ap_int_base' requested here
  inline __attribute__((always_inline)) int to_int() const { return to_ap_int_base().to_int(); }
                                                                    ^
D:/Tools/Xilinx/Vivado/2019.2/common/technology/autopilot\ap_fixed_base.h:1042:71: note: in instantiation of member function 'ap_fixed_base<51, 41, true, 5, 3, 0>::to_int' requested here
  inline __attribute__((always_inline)) operator int() const { return to_int(); }
                                                                      ^
firmware/nnet_utils/nnet_activation.h:401:27: note: in instantiation of member function 'ap_fixed_base<51, 41, true, 5, 3, 0>::operator int' requested here
      int exp_res_index = exp_res[ii]*CONFIG_T::table_size/64;
                          ^
firmware/nnet_utils/nnet_activation.h:421:9: note: in instantiation of function template specialization 'nnet::softmax_legacy<ap_fixed<16, 6, 5, 3, 0>, ap_fixed<16, 6, 5, 3, 0>, softmax_config9>' requested here
        softmax_legacy<data_T, res_T, CONFIG_T>(data, res);
        ^
firmware/myproject.cpp:90:5: note: in instantiation of function template specialization 'nnet::softmax<ap_fixed<16, 6, 5, 3, 0>, ap_fixed<16, 6, 5, 3, 0>, softmax_config9>' requested here
    nnet::softmax<layer8_t, result_t, softmax_config9>(layer8_out, layer9_out);
    ^
2 warnings and 5 errors generated.
Failed during preprocessing.
    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 Fri Apr  2 16:14:58 2021...

我在新版和旧版 Vivado HLS 上都遇到过这个问题。我该如何解决这个问题?

python python-3.x vivado
2个回答
1
投票

我遇到了同样的问题,hls4ml 是 Linux 的后端 Vivado(截至目前)。这在 Ubuntu 中不是问题。 不支持Windows,有一个文件专门在合成前验证操作系统。

如果您转到构建 hls 模型的目录,则在

build_lib.sh
文件中

我不知道为什么它不起作用,但他们正在根据操作系统设置C++编译器here

#!/bin/bash

CC=g++
if [[ "$OSTYPE" == "linux-gnu" ]]; then
    CFLAGS="-O3 -fPIC -std=c++11 -fno-gnu-unique"
elif [[ "$OSTYPE" == "darwin"* ]]; then
    CFLAGS="-O3 -fPIC -std=c++11"
fi
LDFLAGS=
INCFLAGS="-Ifirmware/ap_types/"
PROJECT=myproject
LIB_STAMP=1F075F4e

${CC} ${CFLAGS} ${INCFLAGS} -c firmware/${PROJECT}.cpp -o ${PROJECT}.o
${CC} ${CFLAGS} ${INCFLAGS} -c ${PROJECT}_bridge.cpp -o ${PROJECT}_bridge.o
${CC} ${CFLAGS} ${INCFLAGS} -shared ${PROJECT}.o ${PROJECT}_bridge.o -o firmware/${PROJECT}-${LIB_STAMP}.so
rm -f *.o

0
投票

我有同样的问题:未找到联合模拟。有谁能解决这个问题吗?

谢谢。

© www.soinside.com 2019 - 2024. All rights reserved.