-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from cms-hls4ml/jmduarte-patch-1
Updates
- Loading branch information
Showing
71 changed files
with
9,701 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
TOoLLip_v1/NN/ | ||
.gitignore | ||
*.so | ||
*.o | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "TOoLLip_v1/L1JetTagger"] | ||
path = TOoLLip_v1/L1JetTagger | ||
path = TOoLLiP_v1/L1JetTagger | ||
url = https://github.com/ucsd-hep-ex/L1JetTagger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# TOoLLiP | ||
|
||
- Model training and conversion code: https://github.com/ucsd-hep-ex/L1JetTag | ||
- Emulator tutorial: https://gitlab.cern.ch/fastmachinelearning/cms_mlatl1t_tutorial/-/tree/master/part3 | ||
|
||
## v1 | ||
- Based on QKeras model: https://github.com/ucsd-hep-ex/L1JetTagger/blob/eb93e812690dcf1431bf5cb27bf063d154daed1e/qkL1JetTagModel.h5 | ||
- Convert script: https://github.com/ucsd-hep-ex/L1JetTagger/blob/eb93e812690dcf1431bf5cb27bf063d154daed1e/HLS_qk_Roc.py | ||
- Converted HLS project: https://github.com/ucsd-hep-ex/L1JetTagger/tree/eb93e812690dcf1431bf5cb27bf063d154daed1e | ||
- hls4ml version/commit used: https://github.com/jmduarte/hls4ml/tree/8dea6ad51f78be4662513c1d4482b4b0ab94c5de | ||
- Model: | ||
![model_summary](https://github.com/cms-hls4ml/TOoLLiP/assets/4932543/788b4d4b-4268-4ad4-94ab-26b4edadb0de) | ||
|
||
- Expected performance: | ||
|
||
![hls_Qk_ROCCurve](https://github.com/cms-hls4ml/TOoLLiP/assets/4932543/1470ab5b-ec51-4741-a500-ace2a7a14b5d) | ||
|
||
![profiling_sigmoid](https://github.com/cms-hls4ml/TOoLLiP/assets/4932543/48042a16-5a9c-4697-b891-a1b57fa899ac) |
Submodule L1JetTagger
added at
eb93e8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <iostream> | ||
|
||
#include "TOoLLiP_v1.h" | ||
#include "parameters.h" | ||
|
||
void TOoLLiP_v1( | ||
input_t input_1[N_INPUT_1_1*N_INPUT_2_1], | ||
result_t layer14_out[N_LAYER_12] | ||
) { | ||
|
||
// hls-fpga-machine-learning insert IO | ||
#pragma HLS ARRAY_RESHAPE variable=input_1 complete dim=0 | ||
#pragma HLS ARRAY_PARTITION variable=layer14_out complete dim=0 | ||
#pragma HLS INTERFACE ap_vld port=input_1,layer14_out | ||
#pragma HLS DATAFLOW | ||
|
||
#ifdef __HLS4ML_LOAD_TXT_WEIGHTS__ | ||
static bool loaded_weights = false; | ||
if (!loaded_weights) { | ||
// hls-fpga-machine-learning insert load weights | ||
nnet::load_weights_from_txt<weight15_t, 140>(w15, "w15.txt"); | ||
nnet::load_weights_from_txt<bias15_t, 10>(b15, "b15.txt"); | ||
nnet::load_weights_from_txt<weight16_t, 100>(w16, "w16.txt"); | ||
nnet::load_weights_from_txt<bias16_t, 10>(b16, "b16.txt"); | ||
nnet::load_weights_from_txt<weight9_t, 100>(w9, "w9.txt"); | ||
nnet::load_weights_from_txt<bias9_t, 10>(b9, "b9.txt"); | ||
nnet::load_weights_from_txt<weight12_t, 10>(w12, "w12.txt"); | ||
nnet::load_weights_from_txt<bias12_t, 1>(b12, "b12.txt"); | ||
loaded_weights = true; | ||
} | ||
#endif | ||
|
||
// **************************************** | ||
// NETWORK INSTANTIATION | ||
// **************************************** | ||
|
||
// hls-fpga-machine-learning insert layers | ||
|
||
layer15_t layer15_out[N_OUTPUTS_15*N_FILT_15]; | ||
#pragma HLS ARRAY_PARTITION variable=layer15_out complete dim=0 | ||
nnet::pointwise_conv_1d_cl<input_t, layer15_t, config15>(input_1, layer15_out, w15, b15); // q_conv1d | ||
|
||
layer4_t layer4_out[N_OUTPUTS_2*N_FILT_2]; | ||
#pragma HLS ARRAY_PARTITION variable=layer4_out complete dim=0 | ||
nnet::relu<layer15_t, layer4_t, relu_config4>(layer15_out, layer4_out); // q_activation | ||
|
||
layer16_t layer16_out[N_OUTPUTS_16*N_FILT_16]; | ||
#pragma HLS ARRAY_PARTITION variable=layer16_out complete dim=0 | ||
nnet::pointwise_conv_1d_cl<layer4_t, layer16_t, config16>(layer4_out, layer16_out, w16, b16); // q_conv1d_1 | ||
|
||
layer7_t layer7_out[N_OUTPUTS_5*N_FILT_5]; | ||
#pragma HLS ARRAY_PARTITION variable=layer7_out complete dim=0 | ||
nnet::relu<layer16_t, layer7_t, relu_config7>(layer16_out, layer7_out); // q_activation_1 | ||
|
||
layer8_t layer8_out[N_FILT_8]; | ||
#pragma HLS ARRAY_PARTITION variable=layer8_out complete dim=0 | ||
nnet::global_pooling1d_cl<layer7_t, layer8_t, config8>(layer7_out, layer8_out); // global_average_pooling1d | ||
|
||
layer9_t layer9_out[N_LAYER_9]; | ||
#pragma HLS ARRAY_PARTITION variable=layer9_out complete dim=0 | ||
nnet::dense<layer8_t, layer9_t, config9>(layer8_out, layer9_out, w9, b9); // q_dense | ||
|
||
layer11_t layer11_out[N_LAYER_9]; | ||
#pragma HLS ARRAY_PARTITION variable=layer11_out complete dim=0 | ||
nnet::relu<layer9_t, layer11_t, relu_config11>(layer9_out, layer11_out); // q_activation_2 | ||
|
||
layer12_t layer12_out[N_LAYER_12]; | ||
#pragma HLS ARRAY_PARTITION variable=layer12_out complete dim=0 | ||
nnet::dense<layer11_t, layer12_t, config12>(layer11_out, layer12_out, w12, b12); // q_dense_1 | ||
|
||
nnet::sigmoid<layer12_t, result_t, sigmoid_config14>(layer12_out, layer14_out); // sigmoid | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef TOOLLIP_V1_H_ | ||
#define TOOLLIP_V1_H_ | ||
|
||
#include "ap_fixed.h" | ||
#include "ap_int.h" | ||
#include "hls_stream.h" | ||
|
||
#include "defines.h" | ||
|
||
// Prototype of top level function for C-synthesis | ||
void TOoLLiP_v1( | ||
input_t input_1[N_INPUT_1_1*N_INPUT_2_1], | ||
result_t layer14_out[N_LAYER_12] | ||
); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#ifndef DEFINES_H_ | ||
#define DEFINES_H_ | ||
|
||
#include "ap_fixed.h" | ||
#include "ap_int.h" | ||
#include "nnet_utils/nnet_types.h" | ||
#include <cstddef> | ||
#include <cstdio> | ||
|
||
// hls-fpga-machine-learning insert numbers | ||
#define N_INPUT_1_1 10 | ||
#define N_INPUT_2_1 14 | ||
#define N_OUTPUTS_15 10 | ||
#define N_FILT_15 10 | ||
#define N_OUTPUTS_2 10 | ||
#define N_FILT_2 10 | ||
#define N_OUTPUTS_16 10 | ||
#define N_FILT_16 10 | ||
#define N_OUTPUTS_5 10 | ||
#define N_FILT_5 10 | ||
#define N_FILT_8 10 | ||
#define N_LAYER_9 10 | ||
#define N_LAYER_9 10 | ||
#define N_LAYER_12 1 | ||
#define N_LAYER_12 1 | ||
|
||
// hls-fpga-machine-learning insert layer-precision | ||
typedef ap_fixed<16,6> input_t; | ||
typedef ap_fixed<16,6> model_default_t; | ||
typedef ap_fixed<16,6> layer15_t; | ||
typedef ap_fixed<8,4> weight15_t; | ||
typedef ap_fixed<8,4> bias15_t; | ||
typedef ap_ufixed<8,0,AP_RND_CONV,AP_SAT> layer4_t; | ||
typedef ap_fixed<18,8> q_activation_table_t; | ||
typedef ap_fixed<16,6> layer16_t; | ||
typedef ap_fixed<8,4> weight16_t; | ||
typedef ap_fixed<8,4> bias16_t; | ||
typedef ap_ufixed<8,0,AP_RND_CONV,AP_SAT> layer7_t; | ||
typedef ap_fixed<18,8> q_activation_1_table_t; | ||
typedef ap_fixed<16,6> layer8_t; | ||
typedef ap_fixed<16,6> layer9_t; | ||
typedef ap_fixed<8,4> weight9_t; | ||
typedef ap_fixed<8,4> bias9_t; | ||
typedef ap_uint<1> layer9_index; | ||
typedef ap_ufixed<8,0,AP_RND_CONV,AP_SAT> layer11_t; | ||
typedef ap_fixed<18,8> q_activation_2_table_t; | ||
typedef ap_fixed<16,6> layer12_t; | ||
typedef ap_fixed<8,4> weight12_t; | ||
typedef ap_fixed<8,4> bias12_t; | ||
typedef ap_uint<1> layer12_index; | ||
typedef ap_fixed<16,6> result_t; | ||
typedef ap_fixed<18,8> sigmoid_table_t; | ||
|
||
#endif |
Oops, something went wrong.