Skip to content

Commit

Permalink
Allow multiple includes of same LUT - needed for stream activations, …
Browse files Browse the repository at this point in the history
…to avoid generating same LUT twice.
  • Loading branch information
bo3z committed Jul 26, 2022
1 parent 19c541a commit 2233a68
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions hls4ml/writer/quartus_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,7 @@ def __get_table_size(self, model, activation):
return 1024

def __get_table_header(self, table_name, table_size):
table_header = '#ifndef {}_H_\n'.format(table_name.upper())
table_header += '#define {}_H_\n'.format(table_name.upper())
table_header += '\n'

table_header += '#ifdef __INTELFPGA_COMPILER__\n'
table_header = '#ifdef __INTELFPGA_COMPILER__\n'
table_header += 'hls_init_on_powerup\n'
table_header += '#endif\n'
table_header += 'static const typename CONFIG_T::table_t {}[{}] = {{'.format(table_name, table_size)
Expand All @@ -528,7 +524,6 @@ def __write_elu_table(self, model, path):
sep = ", "

h_file.write('};\n')
h_file.write('\n#endif\n')
h_file.close()

def __write_sigmoid_table(self, model, path):
Expand All @@ -551,7 +546,6 @@ def __write_sigmoid_table(self, model, path):
sep = ", "

h_file.write('};\n')
h_file.write('\n#endif\n')
h_file.close()

def __write_tanh_table(self, model, path):
Expand All @@ -574,7 +568,6 @@ def __write_tanh_table(self, model, path):
sep = ", "

h_file.write('};\n')
h_file.write('\n#endif\n')
h_file.close()

def __write_softplus_table(self, model, path):
Expand All @@ -592,7 +585,6 @@ def __write_softplus_table(self, model, path):
sep = ", "

h_file.write('};\n')
h_file.write('\n#endif\n')
h_file.close()

def __write_softsign_table(self, model, path):
Expand All @@ -610,7 +602,6 @@ def __write_softsign_table(self, model, path):
sep = ", "

h_file.write('};\n')
h_file.write('\n#endif\n')
h_file.close()

def __write_selu_table(self, model, path):
Expand All @@ -628,7 +619,6 @@ def __write_selu_table(self, model, path):
sep = ", "

h_file.write('};\n')
h_file.write('\n#endif\n')
h_file.close()

def __write_exp_table(self, model, path):
Expand Down Expand Up @@ -668,7 +658,6 @@ def __write_exp_table(self, model, path):
sep = ", "

h_file.write('};\n')
h_file.write('\n#endif\n')
h_file.close()

def __write_invert_table(self, model, path):
Expand Down Expand Up @@ -708,7 +697,6 @@ def __write_invert_table(self, model, path):
sep = ", "

h_file.write('};\n')
h_file.write('\n#endif\n')
h_file.close()

def __write_exp_table_latency(self, model, path):
Expand Down Expand Up @@ -748,7 +736,6 @@ def __write_exp_table_latency(self, model, path):
sep = ", "

h_file.write('};\n')
h_file.write('\n#endif\n')
h_file.close()

def __write_invert_table_latency(self, model, path):
Expand Down Expand Up @@ -788,7 +775,6 @@ def __write_invert_table_latency(self, model, path):
sep = ", "

h_file.write('};\n')
h_file.write('\n#endif\n')
h_file.close()

def __write_exp_table_legacy(self, model, path):
Expand All @@ -806,7 +792,6 @@ def __write_exp_table_legacy(self, model, path):
sep = ", "

h_file.write('};\n')
h_file.write('\n#endif\n')
h_file.close()

def __write_invert_table_legacy(self, model, path):
Expand All @@ -826,7 +811,6 @@ def __write_invert_table_legacy(self, model, path):
sep = ", "

h_file.write('};\n')
h_file.write('\n#endif\n')
h_file.close()

def write_activation_tables(self, model):
Expand Down

0 comments on commit 2233a68

Please sign in to comment.