11import os
2- import sys
32import subprocess
3+ import sys
4+
45import numpy as np
56
67from hls4ml .backends import VitisBackend , VivadoBackend
@@ -23,7 +24,7 @@ def create_initial_config(
2324 num_thread = 1 ,
2425 batchsize = 8192 ,
2526 hw_quant = False ,
26- vivado_directives = [] ,
27+ vivado_directives = None ,
2728 ):
2829 """
2930 Create initial accelerator config with default parameters
@@ -64,15 +65,18 @@ def build(
6465 if "linux" in sys .platform :
6566 if "XILINX_VITIS" not in os .environ :
6667 raise Exception (
67- "XILINX_VITIS environmental variable missing. Please install XRT and Vitis, and run the setup scripts before building"
68+ "XILINX_VITIS environmental variable missing."
69+ " Please install XRT and Vitis, and run the setup scripts before building"
6870 )
6971 if "XILINX_XRT" not in os .environ :
7072 raise Exception (
71- "XILINX_XRT environmental variable missing. Please install XRT and Vitis, and run the setup scripts before building"
73+ "XILINX_XRT environmental variable missing."
74+ " Please install XRT and Vitis, and run the setup scripts before building"
7275 )
7376 if "XILINX_VIVADO" not in os .environ :
7477 raise Exception (
75- "XILINX_VIVADO environmental variable missing. Please install XRT and Vitis, and run the setup scripts before building"
78+ "XILINX_VIVADO environmental variable missing."
79+ " Please install XRT and Vitis, and run the setup scripts before building"
7680 )
7781
7882 curr_dir = os .getcwd ()
@@ -106,14 +110,10 @@ def build(
106110 command = "make " + target
107111
108112 # Pre-loading libudev
109- ldconfig_output = subprocess .check_output (["ldconfig" , "-p" ]).decode (
110- "utf-8"
111- )
113+ ldconfig_output = subprocess .check_output (["ldconfig" , "-p" ]).decode ("utf-8" )
112114 for line in ldconfig_output .split ("\n " ):
113115 if "libudev.so" in line and "x86" in line :
114- command = (
115- "LD_PRELOAD=" + line .split ("=>" )[1 ].strip () + " " + command
116- )
116+ command = "LD_PRELOAD=" + line .split ("=>" )[1 ].strip () + " " + command
117117 break
118118 os .system (command )
119119
@@ -129,9 +129,7 @@ def numpy_to_dat(self, model, x):
129129 expected_shape = model .get_input_variables ()[0 ].size ()
130130 actual_shape = np .prod (x .shape [1 :])
131131 if expected_shape != actual_shape :
132- raise Exception (
133- f"Input shape mismatch, got { x .shape } , expected (_, { expected_shape } )"
134- )
132+ raise Exception (f"Input shape mismatch, got { x .shape } , expected (_, { expected_shape } )" )
135133
136134 # Write to tb_data/tb_input_features.dat
137135 samples = x .reshape (x .shape [0 ], - 1 )
@@ -175,18 +173,10 @@ def _register_flows(self):
175173 )
176174
177175 writer_passes = ["make_stamp" , "vitisaccelerator:write_hls" ]
178- self ._writer_flow = register_flow (
179- "write" , writer_passes , requires = ["vitis:ip" ], backend = self .name
180- )
176+ self ._writer_flow = register_flow ("write" , writer_passes , requires = ["vitis:ip" ], backend = self .name )
181177
182178 ip_flow_requirements = get_flow ("vivado:ip" ).requires .copy ()
183- ip_flow_requirements .insert (
184- ip_flow_requirements .index ("vivado:init_layers" ), validation_flow
185- )
186- ip_flow_requirements .insert (
187- ip_flow_requirements .index ("vivado:apply_templates" ), template_flow
188- )
179+ ip_flow_requirements .insert (ip_flow_requirements .index ("vivado:init_layers" ), validation_flow )
180+ ip_flow_requirements .insert (ip_flow_requirements .index ("vivado:apply_templates" ), template_flow )
189181
190- self ._default_flow = register_flow (
191- "ip" , None , requires = ip_flow_requirements , backend = self .name
192- )
182+ self ._default_flow = register_flow ("ip" , None , requires = ip_flow_requirements , backend = self .name )
0 commit comments