diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h index 32727311dc56f..9cee64e216e95 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h @@ -3,9 +3,11 @@ #include #include +#include -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/tau_parameters.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h" +#include "ap_fixed.h" +#include "ap_int.h" +#include "hls4ml/emulator.h" #include "DataFormats/L1TParticleFlow/interface/layer1_emulator.h" #include "DataFormats/L1TParticleFlow/interface/PFCandidate.h" @@ -13,13 +15,15 @@ typedef ap_ufixed<16, 14> pt_t; typedef ap_fixed<10, 4> etaphi_t; -// Tau NN returns two values -struct Tau_NN_Result { - result_t nn_pt_correction; - result_t nn_id; -}; - namespace L1TauEmu { + // Input/output precision of the NNPuppiTauModel hls4ml network, matching the + // model's defines.h (kept here since the weights/layer code now live in the + // externally-built NNPuppiTauModel package, not in-tree). Named distinctively + // (not input_t/result_t) and namespaced to avoid clashing with the generic + // typedefs other hls4ml model headers define at global scope. + typedef ap_fixed<16, 10> tauinput_t; + typedef ap_fixed<16, 6> tauresult_t; + // Data types and constants used in the FPGA and FPGA-optimized functions //etaphi_base maps physical eta phi units onto bits //This way, the least significant bit of etaphi_t is exactly 0.01 @@ -132,14 +136,20 @@ namespace L1TauEmu { }; // namespace L1TauEmu +// Tau NN returns two values +struct Tau_NN_Result { + L1TauEmu::tauresult_t nn_pt_correction; + L1TauEmu::tauresult_t nn_id; +}; + class TauNNIdHW { public: - TauNNIdHW(); - ~TauNNIdHW(); + TauNNIdHW(const std::shared_ptr model); + ~TauNNIdHW() = default; void initialize(const std::string &iName, int iNParticles); void SetNNVectorVar(); - input_t *NNVectorVar() { return NNvectorVar_.data(); } + L1TauEmu::tauinput_t *NNVectorVar() { return NNvectorVar_.data(); } Tau_NN_Result EvaluateNN(); Tau_NN_Result compute(const l1t::PFCandidate &iSeed, std::vector &iParts); //void print(); @@ -153,7 +163,8 @@ class TauNNIdHW { //FILE *file_; private: - std::vector NNvectorVar_; + std::vector NNvectorVar_; + std::shared_ptr modelRef_; }; #endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h deleted file mode 100644 index 54ff10fbbd651..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef DEFINES_H_ -#define DEFINES_H_ - -#include "ap_fixed.h" -#include "ap_int.h" - -#include -#include - -// hls-fpga-machine-learning insert numbers -#define N_INPUT_1_1 80 -#define N_LAYER_2 25 -#define N_LAYER_2 25 -#define N_LAYER_5 25 -#define N_LAYER_5 25 -#define N_LAYER_8 15 -#define N_LAYER_8 15 -#define N_LAYER_11 15 -#define N_LAYER_11 15 -#define N_LAYER_14 10 -#define N_LAYER_14 10 -#define N_LAYER_17 1 -#define N_LAYER_17 1 -#define N_LAYER_20 1 - -// hls-fpga-machine-learning insert layer-precision -typedef ap_fixed<16, 10> input_t; -typedef ap_fixed<24, 12> input2_t; -typedef ap_fixed<16, 6> model_default_t; -typedef ap_fixed<16, 6> layer2_t; -typedef ap_fixed<9, 3> weight2_t; -typedef ap_fixed<9, 3> bias2_t; -typedef ap_uint<1> layer2_index; -typedef ap_ufixed<9, 0, AP_RND_CONV, AP_SAT> layer4_t; -typedef ap_fixed<18, 8> relu_1_table_t; -typedef ap_fixed<16, 6> layer5_t; -typedef ap_fixed<9, 3> weight5_t; -typedef ap_fixed<9, 3> bias5_t; -typedef ap_uint<1> layer5_index; -typedef ap_ufixed<9, 0, AP_RND_CONV, AP_SAT> layer7_t; -typedef ap_fixed<18, 8> relu_2_table_t; -typedef ap_fixed<16, 6> layer8_t; -typedef ap_fixed<9, 3> weight8_t; -typedef ap_fixed<9, 3> bias8_t; -typedef ap_uint<1> layer8_index; -typedef ap_ufixed<9, 0, AP_RND_CONV, AP_SAT> layer10_t; -typedef ap_fixed<18, 8> relu_3_table_t; -typedef ap_fixed<16, 6> layer11_t; -typedef ap_fixed<9, 3> weight11_t; -typedef ap_fixed<9, 3> bias11_t; -typedef ap_uint<1> layer11_index; -typedef ap_ufixed<9, 0, AP_RND_CONV, AP_SAT> layer13_t; -typedef ap_fixed<18, 8> relu_4_table_t; -typedef ap_fixed<16, 6> layer14_t; -typedef ap_fixed<9, 3> weight14_t; -typedef ap_fixed<9, 3> bias14_t; -typedef ap_uint<1> layer14_index; -typedef ap_ufixed<9, 0, AP_RND_CONV, AP_SAT> layer16_t; -typedef ap_fixed<18, 8> relu_5_table_t; -typedef ap_fixed<16, 6> layer17_t; -typedef ap_fixed<16, 7> weight17_t; -typedef ap_fixed<16, 7> bias17_t; -typedef ap_uint<1> layer17_index; -typedef ap_fixed<16, 6> result_t; -typedef ap_fixed<18, 8> jetID_output_table_t; -typedef ap_fixed<16, 7> weight20_t; -typedef ap_fixed<16, 7> bias20_t; -typedef ap_uint<1> layer20_index; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_activation.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_activation.h deleted file mode 100644 index e5413aedf5fc5..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_activation.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef NNET_ACTIVATION_H_ -#define NNET_ACTIVATION_H_ - -#include -#include "ap_fixed.h" -#include "nnet_common.h" - -namespace nnet { - - struct activ_config { - // IO size - static const unsigned n_in = 10; - - // Internal info - static const unsigned table_size = 1024; - - // Resource reuse info - static const unsigned io_type = io_parallel; - static const unsigned reuse_factor = 1; - - // Internal data type definitions - typedef ap_fixed<18, 8> table_t; - }; - - // ************************************************* - // LINEAR Activation -- See Issue 53 - // ************************************************* - template - void linear(data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in]) { - for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) { - res[ii] = data[ii]; - } - } - - // ************************************************* - // RELU Activation - // ************************************************* - template - void relu(data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in]) { - data_T datareg; - for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) { - datareg = data[ii]; - if (datareg > 0) - res[ii] = datareg; - else - res[ii] = 0; - } - } - - // ************************************************* - // Sigmoid Activation - // ************************************************* - template - inline out_T sigmoid_fcn_float(float input) { - return 1.0 / (1 + exp(-input)); - } - - template - void init_sigmoid_table(res_T table_out[N_TABLE]) { - // Default logistic sigmoid function: - // result = 1/(1+e^(-x)) - for (unsigned ii = 0; ii < N_TABLE; ii++) { - // First, convert from table index to X-value (signed 8-bit, range -8 to +8) - float in_val = 2 * 8.0 * (ii - float(N_TABLE) / 2.0) / float(N_TABLE); - // Next, compute lookup table function - res_T real_val = sigmoid_fcn_float(in_val); - //std::cout << "Lookup table In Value: " << in_val << " Result: " << real_val << std::endl; - table_out[ii] = (res_T)real_val; - } - } - - template - void sigmoid(data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in]) { - // Initialize the lookup table - res_T sigmoid_table[CONFIG_T::table_size]; - init_sigmoid_table(sigmoid_table); - - // Index into the lookup table based on data - int data_round; - unsigned index; - for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) { - data_round = data[ii] * CONFIG_T::table_size / 16; - index = data_round + 8 * CONFIG_T::table_size / 16; - /*if (index < 0) - index = 0;*/ - if (index > CONFIG_T::table_size - 1) - index = CONFIG_T::table_size - 1; - res[ii] = (res_T)sigmoid_table[index]; - } - } - -} // namespace nnet - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_common.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_common.h deleted file mode 100644 index 8441cca4412c2..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_common.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef NNET_COMMON_H_ -#define NNET_COMMON_H_ - -#include "ap_fixed.h" - -// This is a substitute for "ceil(n/(float)d)". -#define DIV_ROUNDUP(n, d) ((n + d - 1) / d) -#define MIN(n, d) (n > d ? d : n) -#define MAX(n, d) (n > d ? n : d) - -#define STRINGIFY(x) #x -#define EXPAND_STRING(x) STRINGIFY(x) - -namespace nnet { - - // Common type definitions - enum io_type { io_parallel = 0, io_stream }; - enum strategy { latency, resource }; - - template - class Op_add { - public: - T operator()(T a, T b) { return a + b; } - }; - - template - class Op_and { - public: - T operator()(T a, T b) { return a && b; } - }; - - template - class Op_or { - public: - T operator()(T a, T b) { return a || b; } - }; - - template - class Op_max { - public: - T operator()(T a, T b) { return a >= b ? a : b; } - }; - - template - class Op_min { - public: - T operator()(T a, T b) { return a <= b ? a : b; } - }; - -} // namespace nnet - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_dense.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_dense.h deleted file mode 100644 index 22edbcbf501bd..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_dense.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef NNET_DENSE_H_ -#define NNET_DENSE_H_ - -#include "nnet_common.h" -#include "nnet_mult.h" -#include - -namespace nnet { - - struct dense_config { - // Internal data type definitions - typedef float bias_t; - typedef float weight_t; - typedef float accum_t; - - // Layer Sizes - static const unsigned n_in = 10; - static const unsigned n_out = 10; - - // Resource reuse info - int io_type = io_parallel; - int strategy = latency; - int reuse_factor = 1; - static const bool store_weights_in_bram = false; - int n_zeros = 0; - // partitioning arrays cyclically to go with roll factors? - // Product function to use - template - using product = nnet::product::mult; - }; - - template - void dense(data_T data[CONFIG_T::n_in], - res_T res[CONFIG_T::n_out], - typename CONFIG_T::weight_t weights[CONFIG_T::n_in * CONFIG_T::n_out], - typename CONFIG_T::bias_t biases[CONFIG_T::n_out]) { - data_T cache; - typename CONFIG_T::accum_t mult[CONFIG_T::n_in * CONFIG_T::n_out]; - typename CONFIG_T::accum_t acc[CONFIG_T::n_out]; - - // Do the matrix-multiply - for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) { - cache = data[ii]; - for (unsigned jj = 0; jj < CONFIG_T::n_out; jj++) { - unsigned index = ii * CONFIG_T::n_out + jj; - mult[index] = CONFIG_T::template product::product(cache, weights[index]); - } - } - - // Initialize accumulator with input biases - for (unsigned iacc = 0; iacc < CONFIG_T::n_out; iacc++) { - acc[iacc] = (typename CONFIG_T::accum_t)biases[iacc]; - } - - // Accumulate multiplication result - for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) { - for (unsigned jj = 0; jj < CONFIG_T::n_out; jj++) { - unsigned index = ii * CONFIG_T::n_out + jj; - acc[jj] += mult[index]; - } - } - - // Cast to "res_t" type - for (unsigned ires = 0; ires < CONFIG_T::n_out; ires++) { - // res[ires] = (res_T) (acc[ires]); - res[ires] = cast(acc[ires]); - } - } - -} // namespace nnet - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_mult.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_mult.h deleted file mode 100644 index 3e2ce5b84b080..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_mult.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef NNET_MULT_H_ -#define NNET_MULT_H_ - -#include "nnet_common.h" -#include -#include - -namespace nnet { - - constexpr int ceillog2(int x) { return (x <= 2) ? 1 : 1 + ceillog2((x + 1) / 2); } - - namespace product { - - /* --- - * different methods to perform the product of input and weight, depending on the - * types of each. - * --- */ - - class Product {}; - - template - class both_binary : public Product { - public: - static x_T product(x_T a, w_T w) { return a == w; } - }; - - template - class weight_binary : public Product { - public: - static auto product(x_T a, w_T w) -> decltype(-a) { - if (w == 0) - return -a; - else - return a; - } - }; - - template - class data_binary : public Product { - public: - static auto product(x_T a, w_T w) -> decltype(-w) { - if (a == 0) - return -w; - else - return w; - } - }; - - template - class weight_ternary : public Product { - public: - static auto product(x_T a, w_T w) -> decltype(-a) { - if (w == 0) - return 0; - else if (w == -1) - return -a; - else - return a; // if(w == 1) - } - }; - - template - class mult : public Product { - public: - static auto product(x_T a, w_T w) -> decltype(a * w) { return a * w; } - }; - - template - class weight_exponential : public Product { - public: - using r_T = - ap_fixed<2 * (decltype(w_T::weight)::width + x_T::width), (decltype(w_T::weight)::width + x_T::width)>; - static r_T product(x_T a, w_T w) { - // Shift by the exponent. Negative weights shift right - r_T y = static_cast(a) << w.weight; - - // Negate or not depending on weight sign - return w.sign == 1 ? y : static_cast(-y); - } - }; - - } // namespace product - - template - inline typename std::enable_if>::value && - std::is_same>::value, - ap_int>::type - cast(typename CONFIG_T::accum_t x) { - return (ap_int)(x - CONFIG_T::n_in / 2) * 2; - } - - template - inline typename std::enable_if>::value && - !std::is_same>::value, - res_T>::type - cast(typename CONFIG_T::accum_t x) { - return (res_T)x; - } - - template - inline typename std::enable_if<(!std::is_same>::value), res_T>::type cast( - typename CONFIG_T::accum_t x) { - return (res_T)x; - } - -} // namespace nnet - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/tau_parameters.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/tau_parameters.h deleted file mode 100644 index 95ac948a8d6cd..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/tau_parameters.h +++ /dev/null @@ -1,218 +0,0 @@ -#ifndef PARAMETERS_H_ -#define PARAMETERS_H_ - -#include "ap_fixed.h" -#include "ap_int.h" - -#include - -// Tau NN components -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_activation.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/nnet_utils/nnet_dense.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h" - -// Load the NN weights -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w2.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b2.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w5.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b5.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w8.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b8.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w11.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b11.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w14.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b14.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w17.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b17.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w20.h" -#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b20.h" - -// hls-fpga-machine-learning insert layer-config -// Dense_1 -struct config2 : nnet::dense_config { - static const unsigned n_in = 80; - static const unsigned n_out = 25; - static const unsigned io_type = nnet::io_parallel; - static const unsigned strategy = nnet::latency; - static const unsigned reuse_factor = 1; - static const unsigned n_zeros = 1205; - static const unsigned n_nonzeros = 795; - static const unsigned multiplier_limit = DIV_ROUNDUP(n_in * n_out, reuse_factor) - n_zeros / reuse_factor; - static const bool store_weights_in_bram = false; - typedef model_default_t accum_t; - typedef bias2_t bias_t; - typedef weight2_t weight_t; - typedef layer2_index index_t; - template - using product = nnet::product::mult; -}; - -// relu_1 -struct relu_config4 : nnet::activ_config { - static const unsigned n_in = 25; - static const unsigned table_size = 1024; - static const unsigned io_type = nnet::io_parallel; - static const unsigned reuse_factor = 1; - typedef relu_1_table_t table_t; -}; - -// Dense_2 -struct config5 : nnet::dense_config { - static const unsigned n_in = 25; - static const unsigned n_out = 25; - static const unsigned io_type = nnet::io_parallel; - static const unsigned strategy = nnet::latency; - static const unsigned reuse_factor = 1; - static const unsigned n_zeros = 375; - static const unsigned n_nonzeros = 250; - static const unsigned multiplier_limit = DIV_ROUNDUP(n_in * n_out, reuse_factor) - n_zeros / reuse_factor; - static const bool store_weights_in_bram = false; - typedef model_default_t accum_t; - typedef bias5_t bias_t; - typedef weight5_t weight_t; - typedef layer5_index index_t; - template - using product = nnet::product::mult; -}; - -// relu_2 -struct relu_config7 : nnet::activ_config { - static const unsigned n_in = 25; - static const unsigned table_size = 1024; - static const unsigned io_type = nnet::io_parallel; - static const unsigned reuse_factor = 1; - typedef relu_2_table_t table_t; -}; - -// Dense_3 -struct config8 : nnet::dense_config { - static const unsigned n_in = 25; - static const unsigned n_out = 15; - static const unsigned io_type = nnet::io_parallel; - static const unsigned strategy = nnet::latency; - static const unsigned reuse_factor = 1; - static const unsigned n_zeros = 225; - static const unsigned n_nonzeros = 150; - static const unsigned multiplier_limit = DIV_ROUNDUP(n_in * n_out, reuse_factor) - n_zeros / reuse_factor; - static const bool store_weights_in_bram = false; - typedef model_default_t accum_t; - typedef bias8_t bias_t; - typedef weight8_t weight_t; - typedef layer8_index index_t; - template - using product = nnet::product::mult; -}; - -// relu_3 -struct relu_config10 : nnet::activ_config { - static const unsigned n_in = 15; - static const unsigned table_size = 1024; - static const unsigned io_type = nnet::io_parallel; - static const unsigned reuse_factor = 1; - typedef relu_3_table_t table_t; -}; - -// Dense_4 -struct config11 : nnet::dense_config { - static const unsigned n_in = 15; - static const unsigned n_out = 15; - static const unsigned io_type = nnet::io_parallel; - static const unsigned strategy = nnet::latency; - static const unsigned reuse_factor = 1; - static const unsigned n_zeros = 135; - static const unsigned n_nonzeros = 90; - static const unsigned multiplier_limit = DIV_ROUNDUP(n_in * n_out, reuse_factor) - n_zeros / reuse_factor; - static const bool store_weights_in_bram = false; - typedef model_default_t accum_t; - typedef bias11_t bias_t; - typedef weight11_t weight_t; - typedef layer11_index index_t; - template - using product = nnet::product::mult; -}; - -// relu_4 -struct relu_config13 : nnet::activ_config { - static const unsigned n_in = 15; - static const unsigned table_size = 1024; - static const unsigned io_type = nnet::io_parallel; - static const unsigned reuse_factor = 1; - typedef relu_4_table_t table_t; -}; - -// Dense_5 -struct config14 : nnet::dense_config { - static const unsigned n_in = 15; - static const unsigned n_out = 10; - static const unsigned io_type = nnet::io_parallel; - static const unsigned strategy = nnet::latency; - static const unsigned reuse_factor = 1; - static const unsigned n_zeros = 90; - static const unsigned n_nonzeros = 60; - static const unsigned multiplier_limit = DIV_ROUNDUP(n_in * n_out, reuse_factor) - n_zeros / reuse_factor; - static const bool store_weights_in_bram = false; - typedef model_default_t accum_t; - typedef bias14_t bias_t; - typedef weight14_t weight_t; - typedef layer14_index index_t; - template - using product = nnet::product::mult; -}; - -// relu_5 -struct relu_config16 : nnet::activ_config { - static const unsigned n_in = 10; - static const unsigned table_size = 1024; - static const unsigned io_type = nnet::io_parallel; - static const unsigned reuse_factor = 1; - typedef relu_5_table_t table_t; -}; - -// Dense_6 -struct config17 : nnet::dense_config { - static const unsigned n_in = 10; - static const unsigned n_out = 1; - static const unsigned io_type = nnet::io_parallel; - static const unsigned strategy = nnet::latency; - static const unsigned reuse_factor = 1; - static const unsigned n_zeros = 6; - static const unsigned n_nonzeros = 4; - static const unsigned multiplier_limit = DIV_ROUNDUP(n_in * n_out, reuse_factor) - n_zeros / reuse_factor; - static const bool store_weights_in_bram = false; - typedef model_default_t accum_t; - typedef bias17_t bias_t; - typedef weight17_t weight_t; - typedef layer17_index index_t; - template - using product = nnet::product::mult; -}; - -// jetID_output -struct sigmoid_config19 : nnet::activ_config { - static const unsigned n_in = 1; - static const unsigned table_size = 1024; - static const unsigned io_type = nnet::io_parallel; - static const unsigned reuse_factor = 1; - typedef jetID_output_table_t table_t; -}; - -// pT_output -struct config20 : nnet::dense_config { - static const unsigned n_in = 10; - static const unsigned n_out = 1; - static const unsigned io_type = nnet::io_parallel; - static const unsigned strategy = nnet::latency; - static const unsigned reuse_factor = 1; - static const unsigned n_zeros = 6; - static const unsigned n_nonzeros = 4; - static const unsigned multiplier_limit = DIV_ROUNDUP(n_in * n_out, reuse_factor) - n_zeros / reuse_factor; - static const bool store_weights_in_bram = false; - typedef model_default_t accum_t; - typedef bias20_t bias_t; - typedef weight20_t weight_t; - typedef layer20_index index_t; - template - using product = nnet::product::mult; -}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b11.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b11.h deleted file mode 100644 index 289d5b76f7f7f..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b11.h +++ /dev/null @@ -1,25 +0,0 @@ -//Numpy array shape [15] -//Min -0.062500000000 -//Max 0.250000000000 -//Number of zeros 3 - -#ifndef B11_H_ -#define B11_H_ - -bias11_t b11[15] = {0.031250, - 0.000000, - 0.000000, - 0.078125, - 0.234375, - -0.062500, - 0.093750, - 0.000000, - 0.062500, - 0.109375, - -0.062500, - -0.015625, - 0.250000, - 0.109375, - -0.046875}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b14.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b14.h deleted file mode 100644 index 9de3170588cec..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b14.h +++ /dev/null @@ -1,12 +0,0 @@ -//Numpy array shape [10] -//Min -0.031250000000 -//Max 0.250000000000 -//Number of zeros 0 - -#ifndef B14_H_ -#define B14_H_ - -bias14_t b14[10] = { - 0.031250, 0.015625, 0.046875, -0.015625, -0.031250, 0.046875, 0.203125, 0.015625, 0.250000, -0.015625}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b17.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b17.h deleted file mode 100644 index 540e383f1cdf0..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b17.h +++ /dev/null @@ -1,11 +0,0 @@ -//Numpy array shape [1] -//Min -0.714843750000 -//Max -0.714843750000 -//Number of zeros 0 - -#ifndef B17_H_ -#define B17_H_ - -bias17_t b17[1] = {-0.714844}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b2.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b2.h deleted file mode 100644 index b9cf57fb0c52d..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b2.h +++ /dev/null @@ -1,13 +0,0 @@ -//Numpy array shape [25] -//Min -0.640625000000 -//Max 1.328125000000 -//Number of zeros 0 - -#ifndef B2_H_ -#define B2_H_ - -bias2_t b2[25] = {-0.312500, -0.281250, 0.687500, -0.250000, -0.640625, 0.656250, 0.500000, 0.265625, 0.171875, - -0.046875, -0.093750, 0.156250, -0.156250, -0.093750, -0.171875, 0.234375, 0.046875, 0.125000, - -0.140625, 0.187500, 0.937500, -0.046875, -0.250000, -0.250000, 1.328125}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b20.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b20.h deleted file mode 100644 index 8887c33e169f4..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b20.h +++ /dev/null @@ -1,11 +0,0 @@ -//Numpy array shape [1] -//Min 0.238281250000 -//Max 0.238281250000 -//Number of zeros 0 - -#ifndef B20_H_ -#define B20_H_ - -bias20_t b20[1] = {0.238281}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b5.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b5.h deleted file mode 100644 index 82ab448e8b98e..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b5.h +++ /dev/null @@ -1,13 +0,0 @@ -//Numpy array shape [25] -//Min -0.125000000000 -//Max 0.265625000000 -//Number of zeros 1 - -#ifndef B5_H_ -#define B5_H_ - -bias5_t b5[25] = {-0.015625, 0.046875, -0.109375, 0.078125, 0.171875, 0.156250, 0.062500, 0.171875, 0.109375, - 0.265625, 0.234375, 0.125000, -0.046875, -0.062500, 0.015625, -0.062500, 0.156250, 0.093750, - 0.078125, -0.109375, 0.109375, 0.093750, 0.000000, -0.125000, 0.140625}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b8.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b8.h deleted file mode 100644 index 2cfe199fc7265..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/b8.h +++ /dev/null @@ -1,25 +0,0 @@ -//Numpy array shape [15] -//Min -0.109375000000 -//Max 0.265625000000 -//Number of zeros 0 - -#ifndef B8_H_ -#define B8_H_ - -bias8_t b8[15] = {0.093750, - 0.046875, - -0.015625, - 0.265625, - 0.046875, - -0.078125, - 0.031250, - -0.062500, - -0.015625, - 0.015625, - 0.062500, - 0.062500, - -0.109375, - -0.046875, - 0.140625}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w11.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w11.h deleted file mode 100644 index ba69fb192e297..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w11.h +++ /dev/null @@ -1,34 +0,0 @@ -//Numpy array shape [15, 15] -//Min -0.984375000000 -//Max 1.203125000000 -//Number of zeros 135 - -#ifndef W11_H_ -#define W11_H_ - -weight11_t w11[225] = { - 0.734375, 0.000000, 0.000000, 1.015625, -0.781250, 0.000000, 1.203125, 0.687500, 0.000000, 0.000000, - 0.593750, 0.281250, 0.843750, 0.000000, -0.343750, 0.000000, 0.000000, 0.000000, -0.937500, 0.531250, - 0.000000, 0.000000, 0.000000, -0.453125, 0.000000, 0.484375, 0.000000, 0.546875, -0.671875, -0.296875, - 0.000000, 0.000000, 0.375000, -0.625000, 0.203125, 0.000000, -0.734375, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, -0.515625, 0.000000, 0.000000, 0.500000, -0.453125, 0.000000, 0.000000, 0.500000, - -0.359375, 0.000000, 0.000000, 0.000000, 0.468750, 0.000000, 0.000000, 0.000000, 0.328125, -0.406250, - 0.000000, 0.359375, 0.359375, -0.375000, 0.000000, 0.000000, -0.296875, 0.406250, 0.000000, 0.000000, - 0.406250, 0.328125, -0.515625, 0.421875, 0.000000, 0.000000, 0.000000, -0.281250, 0.000000, 0.000000, - 0.000000, 0.312500, 0.000000, 0.000000, 0.000000, -0.453125, 0.000000, 0.000000, 0.000000, -0.375000, - 0.000000, -0.453125, -0.984375, 0.000000, -0.406250, 0.000000, 0.421875, -0.343750, 0.000000, 0.000000, - 0.000000, -0.437500, 0.000000, 0.343750, 0.000000, 0.375000, -0.453125, 0.000000, -0.343750, 0.000000, - -0.421875, 0.000000, 0.406250, 0.000000, 0.328125, 0.343750, 0.375000, 0.000000, -0.343750, 0.000000, - 0.328125, 0.000000, -0.359375, 0.000000, 0.000000, -0.453125, 0.000000, 0.000000, 0.000000, 0.000000, - 0.328125, 0.000000, 0.468750, 0.000000, 0.000000, 0.000000, 0.000000, 0.375000, 0.000000, 0.000000, - 0.000000, 0.531250, -0.281250, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - -0.671875, 0.000000, 0.000000, 0.000000, 0.437500, 0.000000, 0.000000, 0.000000, -0.765625, 0.000000, - 0.421875, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.421875, 0.000000, - 0.000000, 0.000000, 0.000000, 0.343750, 0.000000, -0.437500, -0.375000, 0.000000, 0.000000, 0.375000, - 0.296875, 0.000000, 0.000000, 0.000000, 0.000000, 0.375000, 0.000000, 0.000000, 0.390625, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - -0.328125, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.562500, 0.000000, - -0.421875, 0.000000, 0.000000, 0.312500, -0.140625, 0.359375, -0.390625, -0.359375, 0.406250, 0.625000, - -0.484375, 0.000000, 0.000000, 0.687500, -0.406250}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w14.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w14.h deleted file mode 100644 index f4103cee867e2..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w14.h +++ /dev/null @@ -1,26 +0,0 @@ -//Numpy array shape [15, 10] -//Min -0.921875000000 -//Max 1.031250000000 -//Number of zeros 90 - -#ifndef W14_H_ -#define W14_H_ - -weight14_t w14[150] = { - -0.296875, -0.843750, 0.000000, 0.000000, -0.406250, 0.000000, -0.281250, 1.031250, 0.000000, 0.000000, - 0.453125, 0.000000, 0.359375, 0.375000, 0.406250, -0.421875, 0.000000, 0.000000, 0.375000, 0.000000, - 0.000000, 0.828125, 0.000000, 0.000000, 0.000000, 0.000000, -0.312500, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, -0.406250, 0.796875, 0.421875, 0.640625, 0.546875, 0.000000, 0.000000, 0.000000, - -0.328125, 0.000000, 0.000000, 0.000000, -0.328125, -0.890625, 0.000000, 0.859375, 0.750000, 0.000000, - 0.453125, 0.000000, 0.000000, 0.000000, 0.000000, -0.328125, 0.000000, 0.000000, -0.328125, -0.359375, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.750000, 0.640625, 0.000000, 0.000000, - 0.000000, -0.484375, 0.000000, 0.000000, -0.421875, 0.000000, -0.421875, 0.781250, 0.000000, 0.000000, - 0.437500, 0.000000, 0.328125, 0.000000, 0.359375, 0.000000, 0.000000, 0.000000, -0.546875, 0.000000, - 0.484375, 0.640625, 0.531250, 0.000000, 0.000000, 0.000000, 0.625000, -0.296875, 0.000000, -0.437500, - 0.000000, 0.000000, 0.000000, 0.000000, 0.421875, 0.000000, 0.000000, 0.000000, 0.000000, 0.375000, - 0.000000, 0.000000, 0.000000, -0.296875, -0.390625, 0.375000, 0.000000, 0.000000, -0.328125, 0.000000, - 0.000000, 0.000000, -0.671875, 0.000000, -0.921875, 0.000000, -0.875000, 0.000000, 0.000000, 0.000000, - 0.468750, 0.718750, 0.484375, 0.812500, 0.000000, 0.375000, 0.000000, 0.000000, -0.390625, 0.000000, - -0.390625, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.390625, 0.000000}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w17.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w17.h deleted file mode 100644 index 0ce1c2b014117..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w17.h +++ /dev/null @@ -1,12 +0,0 @@ -//Numpy array shape [10, 1] -//Min -2.798828125000 -//Max 1.773437500000 -//Number of zeros 6 - -#ifndef W17_H_ -#define W17_H_ - -weight17_t w17[10] = { - 0.000000, 1.773438, 1.755859, 0.000000, 0.000000, 0.000000, 1.603516, 0.000000, -2.798828, 0.000000}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w2.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w2.h deleted file mode 100644 index cd94ddd044393..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w2.h +++ /dev/null @@ -1,211 +0,0 @@ -//Numpy array shape [80, 25] -//Min -1.515625000000 -//Max 1.312500000000 -//Number of zeros 1205 - -#ifndef W2_H_ -#define W2_H_ - -weight2_t w2[2000] = { - 0.000000, 0.000000, 0.000000, 0.109375, 0.046875, 0.078125, 0.000000, 0.281250, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, -0.046875, -0.125000, 0.000000, 0.703125, 0.031250, 0.000000, - 0.000000, -0.203125, 0.000000, -1.296875, -0.656250, 0.000000, 0.000000, 0.390625, 0.000000, 0.000000, - 0.203125, 0.125000, 0.000000, 0.000000, 0.000000, 0.234375, -0.343750, 0.000000, 0.203125, 0.000000, - 0.359375, -1.515625, 1.312500, 0.546875, 0.000000, -0.046875, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, -0.156250, -0.125000, -0.250000, 0.000000, 0.187500, 0.000000, -0.906250, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.718750, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.578125, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.093750, 0.000000, 0.390625, - 0.406250, 0.625000, 0.000000, 0.000000, -0.140625, 0.000000, -0.125000, 0.000000, 0.000000, 0.000000, - -0.546875, -0.109375, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.218750, - 0.000000, 0.000000, 0.000000, 0.390625, -0.265625, -0.234375, 0.000000, -0.265625, 0.000000, 0.000000, - 0.562500, 0.000000, 0.140625, 0.000000, 0.000000, 0.296875, 0.000000, -0.812500, 0.000000, -0.375000, - 0.000000, 0.000000, 0.062500, 0.234375, 0.000000, 0.000000, 0.062500, 0.000000, 0.000000, 0.062500, - -0.140625, -0.078125, 0.187500, -0.906250, 0.000000, 0.000000, 0.000000, 0.000000, -0.281250, 0.000000, - 0.718750, 0.296875, -0.937500, -0.937500, 0.000000, 0.000000, 0.000000, -0.062500, 0.843750, 0.031250, - 0.000000, 0.468750, 0.000000, 0.000000, -0.484375, 0.000000, -0.656250, 0.875000, 0.000000, -0.109375, - -0.015625, 0.000000, 0.000000, 0.140625, -0.343750, -0.421875, 0.343750, 0.078125, 0.000000, 0.000000, - 0.171875, 0.000000, 0.000000, -0.531250, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - -0.375000, 0.000000, 0.000000, 0.000000, 0.218750, 0.546875, 0.015625, -0.109375, 0.000000, 0.000000, - -0.125000, 0.000000, 0.000000, 0.000000, -0.078125, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.046875, 0.578125, 0.000000, 0.000000, 0.000000, -0.093750, 0.000000, 0.000000, 0.000000, 0.000000, - 0.093750, 0.000000, -0.078125, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.312500, 0.000000, 0.000000, 0.000000, 0.062500, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.031250, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.171875, 0.000000, -0.031250, 0.000000, 0.453125, 0.000000, 0.000000, 0.000000, 0.703125, - 0.125000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.265625, 0.000000, - 0.000000, -0.484375, 0.000000, -0.031250, 0.000000, 0.000000, -0.156250, 0.000000, 0.187500, 0.484375, - 0.343750, 0.000000, 0.000000, 0.000000, 0.000000, 0.015625, 0.000000, 0.000000, 0.156250, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.140625, 0.000000, 0.000000, -0.062500, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.390625, 0.000000, -0.125000, -0.156250, - 0.000000, 0.000000, 0.000000, -0.062500, 0.000000, 0.218750, -0.671875, 0.000000, 0.281250, 0.000000, - 0.000000, 0.000000, 0.125000, -0.125000, 0.000000, 0.000000, 0.000000, 0.000000, 0.203125, 0.593750, - 0.000000, 0.000000, 0.000000, 0.000000, 0.281250, 0.000000, -0.140625, -0.171875, -0.265625, 0.000000, - 0.437500, -0.343750, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.140625, 0.000000, 0.000000, - 0.000000, -0.281250, -0.125000, 0.000000, 1.234375, -0.171875, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.234375, 0.078125, 0.000000, -0.546875, 0.421875, 0.000000, -0.312500, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.250000, -0.375000, 0.000000, - 0.000000, 0.515625, 0.000000, 0.000000, 0.000000, -0.171875, 0.000000, -0.515625, -0.156250, 0.000000, - 0.171875, -0.453125, 0.000000, 0.000000, -0.500000, 0.000000, 0.171875, -0.187500, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.296875, 0.187500, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.156250, 0.062500, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.156250, 0.187500, 0.000000, 0.000000, 0.000000, - -0.421875, 0.000000, -0.281250, 0.000000, 0.000000, 0.000000, -0.187500, 0.000000, 0.000000, 0.187500, - 0.000000, 0.000000, 0.359375, 0.000000, 0.000000, 0.187500, -0.093750, 0.000000, 0.000000, 0.046875, - -0.250000, 0.000000, 0.000000, 0.156250, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.031250, 0.000000, 0.000000, - -0.250000, 0.000000, 0.000000, -0.125000, 0.000000, 0.000000, 0.000000, 0.000000, -0.078125, 0.000000, - -0.078125, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.015625, 0.000000, 0.000000, - -0.406250, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.109375, 0.000000, 0.000000, - -0.218750, -0.359375, 0.000000, 0.421875, 0.000000, 0.062500, 0.000000, -0.421875, -0.046875, 0.000000, - 0.093750, 0.000000, 0.000000, 0.000000, -0.515625, 0.000000, 0.000000, 0.015625, 0.000000, 0.000000, - -0.218750, 0.281250, 0.000000, 0.281250, -0.156250, 0.250000, 0.000000, 0.000000, 0.109375, 0.015625, - 0.000000, 0.000000, 0.187500, 0.000000, 0.406250, -0.062500, -0.281250, -0.078125, 0.000000, 0.000000, - 0.000000, -0.250000, -0.453125, -0.046875, 0.421875, 0.000000, -0.109375, 0.109375, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.281250, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.218750, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.656250, 0.000000, 0.000000, 0.000000, 0.046875, 0.000000, 0.484375, -0.546875, -0.031250, -0.421875, - 0.000000, -0.781250, 0.000000, 0.000000, -0.546875, 0.265625, 0.171875, -0.203125, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, -0.062500, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.171875, 0.125000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.328125, 0.000000, - 0.140625, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.062500, 0.171875, 0.000000, 0.015625, - 0.000000, 0.000000, 0.000000, 0.000000, -0.234375, 0.000000, 0.000000, 0.000000, 0.000000, -0.078125, - 0.000000, 0.000000, 0.000000, 0.093750, 0.203125, -0.140625, 0.000000, -0.328125, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, -0.359375, 0.000000, 0.187500, -0.171875, -0.187500, 0.000000, 0.031250, - 0.000000, 0.000000, 0.125000, 0.015625, 0.000000, 0.000000, 0.000000, 0.000000, -0.109375, 0.000000, - -0.296875, 0.000000, -0.187500, 0.250000, 0.000000, 0.000000, 0.390625, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.078125, 0.000000, 0.000000, -0.015625, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.093750, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.250000, 0.000000, -0.109375, -0.296875, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.234375, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.187500, 0.000000, - 0.125000, 0.000000, 0.109375, -0.750000, 0.125000, 0.000000, -0.187500, 0.156250, 0.000000, 0.109375, - 0.000000, 0.109375, 0.000000, -0.265625, -0.031250, 0.000000, 0.125000, 0.000000, 0.203125, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.187500, 0.000000, -0.203125, - 0.000000, 0.000000, 0.187500, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.062500, 0.031250, - 0.015625, 0.000000, 0.078125, -0.328125, -0.031250, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.015625, 0.000000, -0.468750, -0.031250, 0.000000, - 0.000000, -0.046875, 0.703125, 0.000000, -0.093750, 0.265625, 0.312500, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.328125, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.375000, 0.000000, -0.187500, - 0.109375, 0.000000, 0.000000, 0.125000, 0.000000, -0.078125, 0.000000, 0.000000, 0.000000, -0.250000, - -0.156250, 0.000000, 0.250000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, -0.187500, 0.000000, 0.109375, 0.000000, 0.031250, 0.031250, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.234375, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.171875, 0.000000, -0.328125, 0.000000, 0.000000, 0.000000, 0.000000, -0.281250, - 0.000000, 0.000000, -0.265625, 0.000000, 0.125000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - -0.312500, 0.000000, 0.000000, 0.000000, 0.000000, -0.031250, 0.000000, 0.390625, 0.000000, 0.000000, - -0.343750, 0.000000, 0.000000, -0.015625, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.046875, - -0.109375, 0.171875, -0.031250, 0.125000, 0.000000, 0.000000, -0.359375, -0.171875, -0.328125, 0.000000, - 0.000000, 0.218750, 0.281250, -0.437500, 0.000000, 0.000000, 0.109375, -0.093750, 0.000000, -0.125000, - 0.000000, 0.000000, 0.140625, 0.156250, 0.000000, 0.000000, 0.375000, 0.000000, 0.156250, 0.000000, - 0.000000, 0.265625, 0.000000, 0.000000, 0.296875, 0.000000, 0.000000, -0.140625, 0.000000, -0.250000, - 0.000000, -0.187500, 0.296875, 0.000000, -0.218750, 0.000000, 0.218750, 0.000000, -0.171875, -0.218750, - 0.000000, -0.328125, 0.000000, 0.062500, 0.000000, 0.234375, 0.000000, 0.000000, 0.000000, -0.062500, - 0.000000, 0.000000, 0.265625, 0.000000, 0.000000, 0.000000, 0.046875, 0.000000, 0.000000, 0.093750, - -0.265625, 0.000000, 0.265625, -0.359375, 0.000000, 0.000000, 0.062500, 0.000000, 0.140625, 0.000000, - 0.046875, 0.000000, 0.000000, 0.000000, 0.156250, 0.000000, 0.203125, 0.000000, 0.000000, -0.203125, - 0.000000, 0.000000, 0.328125, 0.000000, -0.484375, 0.000000, 0.281250, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.390625, 0.000000, 0.000000, - 0.000000, 0.000000, -0.031250, 0.000000, -0.375000, -0.156250, 0.000000, -0.015625, 0.000000, -0.421875, - 0.000000, 0.093750, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.312500, 0.000000, - 0.015625, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.390625, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.125000, 0.046875, 0.000000, 0.000000, 0.000000, - -0.296875, 0.000000, 0.000000, 0.000000, 0.078125, 0.000000, 0.000000, 0.281250, 0.156250, 0.000000, - 0.000000, -0.156250, 0.218750, 0.375000, 0.000000, 0.000000, 0.000000, -0.015625, -0.125000, 0.015625, - 0.359375, 0.171875, 0.000000, -0.078125, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.031250, - 0.000000, 0.187500, 0.000000, 0.000000, 0.000000, 0.000000, 0.281250, 0.171875, 0.000000, 0.171875, - 0.000000, -0.078125, -0.312500, 0.000000, 0.000000, 0.000000, 0.000000, -0.250000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.031250, 0.000000, 0.296875, 0.000000, 0.000000, -0.265625, 0.000000, - 0.000000, 0.343750, 0.250000, 0.000000, -0.265625, 0.000000, 0.000000, 0.000000, 0.000000, -0.109375, - 0.000000, 0.078125, 0.000000, -0.140625, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.187500, 0.000000, 0.078125, -0.156250, 0.234375, -0.031250, 0.000000, 0.234375, 0.000000, 0.109375, - 0.031250, 0.000000, -0.187500, 0.000000, 0.093750, 0.343750, -0.062500, 0.000000, -0.015625, 0.093750, - 0.000000, 0.000000, 0.000000, 0.015625, 0.015625, 0.000000, 0.140625, 0.234375, 0.156250, 0.000000, - 0.000000, -0.062500, 0.187500, 0.000000, 0.000000, 0.000000, 0.015625, -0.125000, 0.000000, 0.234375, - -0.234375, -0.171875, 0.171875, 0.015625, 0.000000, 0.375000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.171875, -0.218750, 0.000000, 0.171875, 0.000000, 0.000000, -0.718750, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, -0.328125, 0.000000, 0.218750, -0.265625, 0.000000, 0.000000, - 0.000000, 0.187500, 0.000000, 0.109375, 0.000000, -0.171875, 0.062500, 0.000000, 0.000000, 0.093750, - 0.000000, 0.000000, -0.078125, 0.000000, -0.328125, 0.000000, 0.000000, 0.187500, 0.000000, -0.359375, - -0.015625, 0.000000, 0.000000, 0.000000, 0.000000, 0.203125, -0.093750, 0.000000, 0.078125, 0.000000, - 0.000000, -0.187500, 0.000000, 0.000000, 0.000000, -0.109375, 0.000000, 0.312500, 0.187500, 0.000000, - 0.000000, -0.078125, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.203125, -0.171875, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.140625, 0.156250, 0.187500, 0.000000, 0.109375, - 0.000000, 0.000000, 0.000000, 0.000000, 0.078125, 0.000000, 0.000000, 0.000000, 0.000000, 0.140625, - 0.000000, -0.156250, 0.000000, 0.312500, 0.000000, 0.000000, 0.000000, 0.000000, 0.031250, -0.031250, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, -0.046875, 0.062500, 0.000000, 0.000000, 0.000000, -0.015625, -0.125000, 0.000000, 0.000000, - 0.000000, -0.156250, -0.015625, 0.250000, -0.109375, -0.171875, 0.000000, 0.000000, 0.000000, 0.000000, - 0.343750, 0.437500, -0.031250, 0.093750, 0.000000, -0.250000, 0.031250, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.078125, 0.031250, 0.000000, 0.000000, 0.437500, - 0.000000, 0.140625, 0.296875, 0.125000, 0.000000, -0.078125, -0.156250, 0.000000, 0.000000, -0.109375, - 0.000000, -0.156250, -0.062500, 0.203125, -0.062500, 0.000000, 0.140625, -0.125000, 0.218750, 0.000000, - 0.000000, -0.421875, 0.000000, 0.000000, 0.312500, 0.000000, 0.000000, 0.234375, 0.250000, 0.000000, - 0.000000, 0.000000, 0.406250, 0.000000, -0.062500, 0.000000, 0.015625, 0.000000, 0.000000, 0.000000, - -0.281250, 0.000000, 0.515625, 0.000000, 0.000000, 0.484375, 0.187500, 0.000000, -0.218750, 0.000000, - 0.312500, 0.000000, 0.125000, 0.062500, 0.125000, 0.000000, 0.468750, -0.578125, 0.000000, -0.546875, - -0.265625, 0.000000, 0.000000, 0.000000, -0.328125, 0.234375, 0.296875, -0.468750, 0.000000, 0.000000, - 0.187500, 0.000000, 0.000000, 0.046875, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.093750, - 0.000000, 0.640625, -0.421875, 0.000000, -0.296875, 0.000000, 0.000000, 0.093750, 0.000000, -0.234375, - 0.000000, 0.000000, -0.281250, -0.265625, 0.000000, -0.250000, 0.250000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.046875, 0.015625, 0.000000, 0.000000, 0.156250, 0.000000, 0.000000, 0.250000, - -0.062500, 0.000000, 0.000000, 0.000000, 0.187500, 0.000000, 0.000000, 0.000000, 0.250000, 0.000000, - -0.140625, -0.125000, 0.000000, 0.250000, 0.000000, 0.000000, -0.343750, 0.000000, 0.343750, 0.000000, - 0.000000, -0.140625, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.281250, 0.000000, 0.000000, - 0.234375, 0.000000, 0.078125, -0.515625, 0.000000, -0.234375, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.375000, 0.000000, -0.046875, 0.000000, 0.296875, 0.296875, 0.000000, 0.109375, - 0.312500, 0.000000, -0.281250, 0.000000, 0.109375, 0.218750, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.281250, 0.000000, -0.109375, 0.000000, 0.203125, 0.000000, -0.046875, 0.000000, - 0.000000, 0.000000, -0.281250, 0.000000, -0.234375, 0.515625, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.109375, 0.109375, 0.000000, -0.031250, -0.156250, -0.296875, 0.000000, -0.390625, - 0.000000, 0.171875, -0.093750, 0.000000, 0.312500, 0.312500, 0.000000, -0.125000, 0.000000, 0.171875, - -0.093750, 0.125000, 0.000000, 0.000000, 0.000000, 0.203125, 0.000000, 0.046875, 0.000000, -0.281250, - -0.281250, -0.265625, 0.000000, 0.000000, 0.000000, 0.343750, 0.000000, 0.000000, 0.000000, -0.140625, - 0.000000, 0.359375, 0.203125, 0.000000, -0.125000, 0.000000, 0.000000, -0.140625, -0.046875, 0.171875, - 0.421875, -0.078125, 0.187500, 0.000000, 0.000000, 0.250000, 0.156250, 0.000000, -0.234375, -0.500000, - 0.031250, 0.265625, 0.390625, -0.453125, 0.000000, 0.000000, 0.000000, -0.296875, -0.109375, -0.390625, - 0.000000, -0.250000, 0.000000, 0.000000, -0.203125, 0.000000, 0.250000, -0.234375, 0.000000, -0.078125, - 0.265625, 0.140625, -0.140625, 0.000000, 0.000000, 0.000000, 0.281250, 0.546875, 0.000000, 0.000000, - 0.000000, 0.000000, -0.359375, 0.000000, -0.328125, 0.156250, -0.296875, 0.171875, 0.000000, 0.000000, - 0.171875, 0.000000, -0.625000, 0.000000, 0.000000, 0.000000, 0.000000, 0.171875, -0.140625, 0.000000, - -0.187500, 0.000000, 0.078125, -0.281250, 0.187500, 0.000000, 0.125000, -0.093750, 0.000000, 0.203125, - -0.203125, 0.000000, -0.187500, 0.031250, 0.000000, -0.156250, -0.078125, -0.078125, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.281250, 0.000000, 0.078125, 0.000000, 0.296875, 0.000000, 0.000000, - -0.234375, 0.000000, -0.015625, 0.000000, 0.078125, 0.281250, 0.000000, 0.171875, 0.109375, 0.000000, - 0.203125, -0.406250, -0.187500, 0.000000, 0.000000, 0.000000, -0.328125, 0.046875, 0.000000, 0.296875, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.234375, - 0.265625, -0.156250, -0.203125, 0.000000, -0.281250, 0.171875, 0.000000, 0.000000, 0.375000, -0.062500, - 0.000000, 0.406250, 0.000000, 0.296875, -0.031250, -0.046875, 0.000000, 0.328125, 0.000000, 0.000000, - 0.000000, 0.218750, -0.109375, 0.000000, 0.000000, 0.125000, -0.093750, -0.125000, 0.000000, -0.171875, - 0.234375, -0.140625, 0.000000, 0.062500, -0.015625, 0.000000, 0.156250, -0.453125, 0.000000, 0.000000, - 0.109375, -0.140625, 0.109375, 0.000000, 0.312500, 0.000000, -0.171875, 0.125000, -0.250000, 0.000000, - 0.187500, -0.078125, 0.156250, 0.000000, 0.125000, 0.203125, 0.000000, -0.281250, 0.000000, 0.000000, - 0.000000, 0.000000, 0.109375, 0.000000, 0.000000, 0.250000, 0.187500, 0.000000, 0.171875, -0.109375, - 0.000000, 0.000000, -0.031250, 0.000000, 0.187500, 0.203125, 0.000000, 0.000000, 0.000000, 0.062500, - 0.093750, 0.156250, 0.000000, 0.015625, 0.000000, 0.515625, 0.328125, 0.000000, -0.015625, 0.000000, - 0.000000, 0.312500, 0.484375, 0.000000, 0.000000, -0.312500, 0.000000, -0.531250, -0.250000, -0.140625, - 0.125000, 0.000000, 0.406250, 0.000000, 0.000000, 0.171875, 0.296875, -0.875000, 0.000000, -0.281250, - 0.359375, 0.000000, 0.000000, 0.000000, -0.375000, 0.000000, 0.250000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, -0.500000, 0.000000, -0.140625, 0.000000, -0.156250, 0.000000, 0.000000, -0.218750, - 0.296875, 0.000000, -1.109375, 0.000000, 0.000000, 0.000000, 0.250000, 0.000000, -0.046875, 0.062500, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.328125, 0.000000, 0.109375, 0.000000, -0.109375, - 0.531250, 0.203125, 0.000000, 0.000000, 0.156250, -0.203125, -0.484375, 0.000000, 0.000000, -0.281250, - 0.000000, 0.000000, -0.156250, 0.000000, 0.000000, -0.078125, 0.203125, -0.109375, 0.000000, 0.000000, - 0.000000, -0.062500, -0.062500, 0.000000, 0.000000, 0.000000, -0.109375, -0.250000, 0.000000, 0.000000, - 0.000000, -0.046875, -0.281250, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.093750, - 0.328125, 0.000000, 0.312500, 0.000000, 0.000000, 0.000000, 0.515625, -0.187500, 0.000000, 0.062500, - -0.031250, -0.250000, 0.281250, -0.015625, -0.312500, 0.000000, 0.140625, 0.000000, 0.000000, 0.000000, - 0.218750, 0.375000, -0.203125, 0.343750, 0.000000, 0.125000, 0.125000, 0.359375, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.093750, 0.312500, 0.000000, 0.000000, 0.250000, 0.000000, - 0.359375, -0.015625, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.312500, 0.000000, 0.000000, - -0.125000, 0.156250, 0.000000, -0.781250, 0.000000, 0.000000, -0.093750, 0.156250, -0.328125, 0.078125, - 0.125000, 0.140625, 0.000000, 0.109375, -0.187500, 0.171875, 0.140625, -0.265625, -0.234375, 0.000000, - 0.000000, 0.000000, 0.000000, -0.093750, 0.000000, 0.000000, 0.171875, 0.000000, 0.078125, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.218750, -0.171875, 0.000000, -0.187500, - -0.234375, 0.000000, 0.140625, 0.156250, 0.000000, 0.484375, 0.406250, -0.234375, 0.343750, -0.812500, - 0.000000, 0.000000, 0.000000, -1.265625, 0.000000, 0.000000, 0.000000, -0.421875, 0.000000, 0.000000, - 0.000000, -0.265625, 0.000000, 0.000000, 0.000000, 0.281250, 0.000000, 0.000000, -0.843750, 0.000000}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w20.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w20.h deleted file mode 100644 index 25d75a1880f14..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w20.h +++ /dev/null @@ -1,12 +0,0 @@ -//Numpy array shape [10, 1] -//Min -0.931640625000 -//Max 1.476562500000 -//Number of zeros 6 - -#ifndef W20_H_ -#define W20_H_ - -weight20_t w20[10] = { - 0.000000, 0.000000, 0.000000, 1.185547, 0.000000, 1.476562, -0.931641, 0.769531, 0.000000, 0.000000}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w5.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w5.h deleted file mode 100644 index f001160129b86..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w5.h +++ /dev/null @@ -1,74 +0,0 @@ -//Numpy array shape [25, 25] -//Min -1.203125000000 -//Max 1.078125000000 -//Number of zeros 375 - -#ifndef W5_H_ -#define W5_H_ - -weight5_t w5[625] = { - -0.578125, 0.515625, 0.000000, -0.796875, 0.359375, -0.562500, 0.000000, 0.000000, 0.359375, 0.000000, - 0.390625, 0.000000, 0.000000, -0.281250, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, -0.484375, -0.718750, 0.000000, 0.000000, 0.000000, -0.578125, 0.000000, 0.000000, - 0.000000, 0.343750, 0.000000, 0.421875, 0.000000, 0.218750, 0.000000, 0.000000, -0.281250, 0.000000, - 0.218750, 0.000000, 0.000000, 0.000000, 0.000000, -0.625000, 0.250000, -0.375000, 0.000000, 0.000000, - 0.000000, 0.000000, -1.062500, 0.000000, 0.515625, 0.000000, -0.203125, -0.546875, 0.828125, 0.734375, - 0.000000, 0.500000, 0.000000, 0.000000, -1.203125, 0.000000, -1.062500, 0.375000, 0.000000, 0.000000, - 0.000000, 0.000000, -0.375000, 0.703125, 0.000000, 0.000000, 0.000000, 0.000000, 0.390625, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.375000, 0.000000, 0.000000, -0.250000, 0.265625, - -0.312500, 0.000000, 0.171875, 0.312500, 0.000000, 0.000000, 0.250000, 0.000000, 0.000000, 0.203125, - 0.000000, 0.000000, -0.328125, 0.546875, 0.000000, 0.000000, 0.000000, 0.000000, -0.343750, 0.000000, - 0.000000, 0.000000, 0.000000, -0.218750, 0.281250, -0.296875, 0.000000, -0.187500, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, -0.468750, 0.000000, 0.328125, 0.000000, -0.234375, 0.000000, - 0.421875, 0.000000, 0.000000, 0.312500, 0.000000, 0.000000, 0.000000, 0.140625, 0.000000, 0.000000, - 0.296875, -0.390625, 0.000000, 0.000000, 0.000000, -0.593750, 0.421875, 0.250000, 0.000000, -0.234375, - 0.000000, 0.078125, 0.000000, 0.328125, 0.000000, 0.000000, -0.187500, -0.156250, 0.000000, -0.281250, - 0.000000, 0.000000, 0.359375, 0.000000, 0.218750, -0.281250, 0.000000, -0.171875, 0.218750, 0.000000, - 0.000000, 0.000000, 0.000000, 0.312500, 0.000000, 0.000000, 0.406250, 0.000000, 0.000000, 0.000000, - 0.312500, -0.468750, 0.000000, 0.000000, 0.421875, 0.000000, 0.000000, 0.000000, 0.000000, -0.281250, - -0.218750, -0.484375, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.156250, 0.328125, - 0.421875, 0.000000, 0.218750, 0.640625, 0.000000, 0.187500, 0.000000, 0.000000, -0.234375, -0.531250, - 0.671875, 0.000000, -0.250000, 0.000000, 0.000000, -0.375000, 0.000000, 0.390625, -0.203125, 0.000000, - 0.000000, -0.375000, 0.390625, -0.468750, -0.421875, -0.015625, 0.437500, 0.000000, -0.531250, -0.781250, - 0.500000, 0.000000, 0.671875, 0.421875, 0.000000, 0.000000, -0.359375, 0.000000, 0.000000, 0.359375, - 0.000000, -0.156250, 0.000000, 0.000000, 0.218750, -0.328125, 0.000000, 0.000000, 0.000000, 0.000000, - -0.281250, 0.093750, -0.328125, 0.000000, 0.312500, 0.000000, -0.171875, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.343750, -0.234375, 0.125000, -0.250000, - 0.000000, 0.000000, 0.421875, 0.437500, -0.343750, 0.375000, 0.000000, -0.390625, 0.000000, 0.281250, - 0.000000, 0.203125, 0.000000, 0.000000, 0.000000, 0.000000, -0.234375, -0.312500, -0.312500, 0.000000, - 0.000000, -0.250000, 0.234375, 0.000000, 0.000000, 0.000000, 0.000000, -0.187500, 0.000000, 0.000000, - 0.000000, 0.000000, 0.281250, 0.000000, 0.000000, -0.359375, 0.453125, 0.000000, 0.000000, -0.093750, - -0.406250, 0.250000, 0.000000, -0.281250, 0.000000, 0.000000, -0.250000, -0.250000, 0.000000, -0.234375, - -0.125000, -0.171875, 0.468750, -0.484375, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.375000, 0.000000, 0.000000, 0.140625, - -0.156250, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.187500, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.218750, 0.000000, 0.000000, 0.000000, - -0.125000, 0.390625, 0.000000, -0.328125, 1.078125, 0.234375, 0.312500, 0.000000, 0.000000, 0.000000, - 0.781250, -0.218750, 0.000000, 0.312500, 0.000000, 0.000000, 0.000000, -0.500000, -0.906250, -0.687500, - 0.000000, 0.500000, 0.437500, 0.000000, 0.000000, 0.000000, -0.265625, 0.078125, 0.000000, 0.000000, - 0.000000, -0.500000, 0.265625, 0.000000, 0.000000, 0.000000, -0.562500, 0.000000, 0.656250, 0.000000, - 0.468750, 0.000000, 0.000000, 0.000000, 0.140625, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, -0.562500, 0.000000, 0.000000, -0.343750, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.671875, -0.328125, 0.468750, 0.000000, 0.468750, 0.000000, - 0.062500, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.203125, 0.109375, 0.000000, 0.000000, - -0.328125, 0.000000, 0.218750, 0.000000, 0.000000, -0.328125, -0.187500, 0.000000, 0.203125, 0.296875, - -0.671875, 0.031250, -0.546875, -0.234375, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.812500, - 0.000000, 0.250000, 0.000000, 0.265625, -0.468750, 0.234375, 0.000000, 0.281250, 0.000000, 0.000000, - -0.828125, -0.671875, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.031250, - -0.203125, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.421875, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.656250, 0.000000, 0.453125, 0.343750, 0.343750, 0.000000, 0.000000, - 0.000000, 0.265625, 0.218750, 0.000000, -0.546875, 0.000000, 0.000000, -0.296875, 0.296875, 0.000000, - 0.000000, 0.000000, 0.281250, -0.234375, 0.234375, 0.203125, 0.000000, 0.000000, 0.000000, 0.359375, - 0.000000, -1.078125, 0.000000, 0.000000, 0.000000, -0.187500, 0.437500, 0.000000, 0.000000, -0.500000, - 0.484375, 0.000000, 0.000000, 0.281250, 0.000000, 0.359375, 0.000000, 0.000000, -0.187500, 0.000000, - 0.000000, 0.000000, 0.000000, -0.437500, 0.203125, 0.203125, 0.000000, -0.328125, 0.000000, 0.000000, - -0.250000, 0.000000, 0.000000, 0.000000, 0.390625, 0.000000, 0.328125, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.125000, 0.000000, -0.265625, 0.171875, 0.000000, 0.000000, 0.000000, 0.000000, - -0.421875, 0.359375, 0.000000, -0.390625, -0.093750, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, -0.156250, 0.000000, 0.296875, 0.187500, 0.406250, 0.000000, 0.000000, 0.281250, 0.000000, - 0.000000, -0.046875, 0.000000, 0.000000, 0.000000, -0.265625, -0.250000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.375000, 0.000000, -0.375000, 0.000000, 0.000000, 0.000000, 0.000000, -0.968750, - -0.640625, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.500000, 0.000000, 0.000000, 0.515625, - 0.531250, 0.000000, 0.000000, 0.000000, 0.000000}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w8.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w8.h deleted file mode 100644 index 30533952a7b8f..0000000000000 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/weights/w8.h +++ /dev/null @@ -1,49 +0,0 @@ -//Numpy array shape [25, 15] -//Min -0.859375000000 -//Max 0.750000000000 -//Number of zeros 225 - -#ifndef W8_H_ -#define W8_H_ - -weight8_t w8[375] = { - 0.000000, -0.250000, 0.000000, 0.000000, 0.000000, 0.000000, 0.562500, -0.187500, 0.312500, 0.234375, - 0.234375, 0.140625, -0.203125, 0.000000, 0.000000, -0.218750, -0.281250, 0.000000, 0.000000, 0.000000, - 0.187500, 0.296875, 0.000000, -0.296875, 0.000000, -0.203125, 0.328125, -0.390625, 0.000000, 0.000000, - 0.593750, -0.234375, 0.000000, 0.000000, -0.375000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.265625, 0.000000, 0.000000, 0.000000, 0.000000, -0.343750, 0.000000, 0.000000, 0.062500, - 0.000000, 0.000000, 0.000000, 0.312500, 0.000000, 0.000000, 0.406250, -0.265625, -0.421875, 0.000000, - 0.171875, 0.000000, 0.000000, 0.000000, 0.000000, -0.328125, 0.000000, 0.000000, -0.468750, 0.000000, - 0.000000, 0.000000, 0.000000, 0.562500, 0.453125, 0.453125, 0.000000, 0.000000, 0.421875, -0.437500, - -0.296875, -0.250000, -0.359375, 0.000000, -0.234375, -0.625000, 0.000000, -0.328125, 0.000000, -0.359375, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.343750, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, -0.859375, 0.000000, 0.000000, 0.671875, 0.000000, 0.000000, 0.203125, - 0.218750, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.468750, -0.234375, 0.296875, 0.000000, - -0.640625, 0.359375, 0.000000, 0.000000, 0.000000, 0.000000, -0.343750, 0.203125, -0.312500, -0.234375, - 0.000000, 0.250000, 0.187500, 0.000000, 0.000000, 0.000000, 0.000000, 0.531250, 0.000000, 0.000000, - -0.250000, 0.000000, 0.000000, -0.187500, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.468750, -0.218750, 0.375000, 0.000000, -0.265625, 0.000000, -0.218750, -0.296875, 0.265625, - -0.562500, 0.281250, 0.000000, 0.390625, 0.437500, 0.000000, 0.000000, 0.218750, 0.625000, 0.000000, - 0.000000, 0.218750, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.203125, 0.000000, 0.750000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.187500, -0.234375, - 0.265625, 0.171875, -0.328125, 0.328125, 0.000000, 0.250000, 0.000000, 0.000000, -0.218750, 0.000000, - 0.000000, -0.281250, 0.000000, -0.312500, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.500000, 0.125000, 0.000000, 0.265625, 0.312500, 0.203125, 0.562500, 0.000000, -0.234375, 0.187500, - 0.000000, 0.000000, 0.203125, 0.000000, 0.000000, -0.156250, 0.515625, 0.000000, 0.000000, 0.000000, - -0.187500, 0.000000, 0.000000, -0.296875, 0.000000, -0.093750, -0.296875, 0.000000, 0.484375, 0.000000, - 0.453125, 0.000000, -0.203125, 0.000000, 0.000000, -0.406250, 0.000000, -0.187500, 0.250000, -0.343750, - 0.000000, 0.000000, 0.000000, -0.343750, 0.000000, 0.000000, 0.000000, 0.000000, 0.578125, 0.000000, - 0.000000, 0.000000, 0.000000, 0.250000, 0.000000, 0.000000, 0.171875, 0.218750, 0.000000, 0.000000, - 0.000000, -0.281250, 0.000000, 0.468750, -0.375000, 0.000000, 0.000000, 0.000000, 0.000000, -0.343750, - 0.000000, 0.453125, 0.000000, 0.000000, 0.000000, 0.281250, 0.609375, 0.000000, 0.000000, 0.000000, - -0.218750, 0.000000, -0.406250, 0.000000, -0.328125, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, -0.734375, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.250000, 0.000000, - 0.000000, 0.000000, -0.328125, 0.000000, 0.640625, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, -0.593750, -0.375000, 0.000000, 0.312500, 0.312500, 0.000000, 0.562500, - 0.000000, 0.000000, -0.593750, 0.000000, 0.281250, 0.218750, 0.359375, 0.000000, 0.000000, -0.296875, - 0.000000, 0.000000, -0.296875, -0.250000, 0.000000, -0.500000, 0.000000, 0.000000, 0.593750, 0.000000, - 0.000000, 0.000000, 0.000000, -0.328125, -0.343750, 0.531250, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, -0.234375, 0.000000, 0.000000, 0.000000, 0.000000, -0.421875, -0.250000, - 0.000000, 0.000000, -0.375000, -0.437500, -0.437500}; - -#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc index 7bd218b4d2cac..5d3766c7f402e 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc @@ -8,6 +8,7 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/Exception.h" #include "DataFormats/L1TParticleFlow/interface/PFTau.h" #include "DataFormats/L1TParticleFlow/interface/PFCandidate.h" @@ -17,8 +18,13 @@ #include "ap_int.h" #include "ap_fixed.h" +#include "hls4ml/emulator.h" + using namespace l1t; +// Intermediate precision for the seed-cone clustering math below (mass/pt sums). +typedef ap_fixed<24, 12> input2_t; + class L1NNTauProducer : public edm::stream::EDProducer> { public: explicit L1NNTauProducer(const edm::ParameterSet&, const tensorflow::SessionCache*); @@ -53,6 +59,9 @@ class L1NNTauProducer : public edm::stream::EDProducer> fL1PFToken_; + + hls4mlEmulator::ModelLoader loader_; + std::shared_ptr model_; }; static constexpr float track_trigger_eta_max = 2.5; @@ -66,10 +75,17 @@ L1NNTauProducer::L1NNTauProducer(const edm::ParameterSet& cfg, const tensorflow: fHW(cfg.getParameter("HW")), fEMSeed(cfg.getParameter("emseed")), fDebug(cfg.getParameter("debug")), - fL1PFToken_(consumes>(cfg.getParameter("L1PFObjects"))) { + fL1PFToken_(consumes>(cfg.getParameter("L1PFObjects"))), + loader_(hls4mlEmulator::ModelLoader(cfg.getParameter("tauModelPath"))) { std::string lNNFile = cfg.getParameter("NNFileName"); //,"L1Trigger/Phase2L1Taus/data/tau_3layer.pb"); if (fHW) { - fTauNNIdHW_ = std::make_unique(); + try { + model_ = loader_.load_model(); + } catch (std::runtime_error& e) { + throw cms::Exception("ModelError") << " ERROR: failed to load NNPuppiTau model version \"" << loader_.model_name() + << "\". Model version not found in cms-hls4ml externals."; + } + fTauNNIdHW_ = std::make_unique(model_); fTauNNIdHW_->initialize("input_1:0", fNParticles_); } else { fTauNNId_ = std::make_unique(lNNFile.find("v0") == std::string::npos ? "input_1:0" : "dense_1_input:0", @@ -177,6 +193,7 @@ void L1NNTauProducer::fillDescriptions(edm::ConfigurationDescriptions& descripti // L1NNTauProducer edm::ParameterSetDescription desc; desc.add("NNFileName", "L1Trigger/Phase2L1ParticleFlow/data/tau_3layer.pb"); + desc.add("tauModelPath", std::string("NNPuppiTauModel_v1")); desc.add("tausize", 0.1); desc.add("maxtaus", 5); desc.add("nparticles", 10); @@ -202,8 +219,8 @@ void L1NNTauProducer::makeTau_HW(const l1t::PFCandidate& seed, input2_t p1y_tot = 0; input2_t p1z_tot = 0; - input_t e1ta_1 = seed.eta(); - input_t p1hi_1 = seed.phi(); + L1TauEmu::tauinput_t e1ta_1 = seed.eta(); + L1TauEmu::tauinput_t p1hi_1 = seed.phi(); L1TauEmu::pt_t pt = 0; L1TauEmu::z0_t z0 = 0; L1TauEmu::dxy_t dxy = 0; @@ -216,10 +233,10 @@ void L1NNTauProducer::makeTau_HW(const l1t::PFCandidate& seed, lId++; pt = pt + L1TauEmu::pt_t(parts[i0].pt()); - input2_t d1eta = input_t(parts[i0].eta()) - e1ta_1; - input2_t d1phi = input_t(parts[i0].phi()) - p1hi_1; + input2_t d1eta = L1TauEmu::tauinput_t(parts[i0].eta()) - e1ta_1; + input2_t d1phi = L1TauEmu::tauinput_t(parts[i0].phi()) - p1hi_1; input2_t d1r2 = d1eta * d1eta + d1phi * d1phi; - input2_t tmppt = input_t(parts[i0].pt()); + input2_t tmppt = L1TauEmu::tauinput_t(parts[i0].pt()); input2_t half = 0.5; p1z_tot = p1z_tot + tmppt * (1 - d1r2 * half); p1y_tot = p1y_tot + tmppt * d1phi; @@ -247,7 +264,7 @@ void L1NNTauProducer::makeTau_HW(const l1t::PFCandidate& seed, Tau_NN_Result NN_ouput = fTauNNIdHW_->compute(seed, parts); // Needed for making PFTau - input_t* lNNVector = fTauNNIdHW_->NNVectorVar(); + L1TauEmu::tauinput_t* lNNVector = fTauNNIdHW_->NNVectorVar(); float pNNVec[80]; for (unsigned i0 = 0; i0 < 80; i0++) pNNVec[i0] = float(lNNVector[i0]); diff --git a/L1Trigger/Phase2L1ParticleFlow/python/L1NNTauProducer_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/L1NNTauProducer_cff.py index 8aa876c19775a..109d1289d1050 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/L1NNTauProducer_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/L1NNTauProducer_cff.py @@ -2,6 +2,8 @@ from L1Trigger.Phase2L1ParticleFlow.l1ctLayer1_cff import l1tLayer1Barrel,l1tLayer1HGCal,l1tLayer1 +nnPuppiTauModelName = "NNPuppiTauModel_v1" + #from L1Trigger.Phase2L1ParticleFlow.L1NNTauProducer_cfi import * #L1NNTauProducerPuppi = L1NNTauProducer.clone( @@ -19,7 +21,8 @@ emseed = cms.bool(True), debug = cms.bool(False), L1PFObjects = cms.InputTag('l1tLayer2Deregionizer:Puppi'), #1pfCandidates:Puppi"),#l1pfCandidates - NNFileName = cms.string("L1Trigger/Phase2L1ParticleFlow/data/tau_3layer_puppi.pb") + NNFileName = cms.string("L1Trigger/Phase2L1ParticleFlow/data/tau_3layer_puppi.pb"), + tauModelPath = cms.string(nnPuppiTauModelName) ) l1tNNTauProducerPF = cms.EDProducer("L1NNTauProducer", @@ -29,6 +32,7 @@ maxtaus = cms.int32(5), nparticles = cms.int32(10), L1PFObjects = cms.InputTag("l1tLayer1:PF"),#l1pfCandidates - NNFileName = cms.string("L1Trigger/Phase2L1ParticleFlow/data/tau_3layer.pb") + NNFileName = cms.string("L1Trigger/Phase2L1ParticleFlow/data/tau_3layer.pb"), + tauModelPath = cms.string(nnPuppiTauModelName) ) diff --git a/L1Trigger/Phase2L1ParticleFlow/src/taus/TauNNIdHW.cc b/L1Trigger/Phase2L1ParticleFlow/src/taus/TauNNIdHW.cc index f4e996f6a665e..1b36604e47a8a 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/taus/TauNNIdHW.cc +++ b/L1Trigger/Phase2L1ParticleFlow/src/taus/TauNNIdHW.cc @@ -1,8 +1,9 @@ +#include #include +#include #include "L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h" -TauNNIdHW::TauNNIdHW() { NNvectorVar_.clear(); } -TauNNIdHW::~TauNNIdHW() {} +TauNNIdHW::TauNNIdHW(const std::shared_ptr model) : modelRef_(model) { NNvectorVar_.clear(); } void TauNNIdHW::initialize(const std::string &iInput, int iNParticles) { fNParticles_ = iNParticles; @@ -17,9 +18,9 @@ void TauNNIdHW::initialize(const std::string &iInput, int iNParticles) { void TauNNIdHW::SetNNVectorVar() { NNvectorVar_.clear(); for (unsigned i0 = 0; i0 < fNParticles_; i0++) { - input_t pPt = input_t(fPt_.get()[i0]); - input_t pEta = input_t(fEta_.get()[i0]); - input_t pPhi = input_t(fPhi_.get()[i0]); + L1TauEmu::tauinput_t pPt = L1TauEmu::tauinput_t(fPt_.get()[i0]); + L1TauEmu::tauinput_t pEta = L1TauEmu::tauinput_t(fEta_.get()[i0]); + L1TauEmu::tauinput_t pPhi = L1TauEmu::tauinput_t(fPhi_.get()[i0]); NNvectorVar_.push_back(pPt); NNvectorVar_.push_back(pEta); @@ -37,56 +38,27 @@ void TauNNIdHW::SetNNVectorVar() { } } -// Main architecture of the NN here +// Main architecture of the NN here: delegates to the externally-built +// NNPuppiTauModel package (loaded via hls4mlEmulator::Model) instead of +// in-tree weight arrays, avoiding ELF symbol clashes between hls4ml models +// loaded into the same process (cms-sw/cmssw#49632). Tau_NN_Result TauNNIdHW::EvaluateNN() { - input_t model_input[N_INPUT_1_1]; + constexpr unsigned kNInputs = 80; + L1TauEmu::tauinput_t model_input[kNInputs]; for (unsigned int i = 0; i < NNvectorVar_.size(); i++) { - model_input[i] = input_t(NNvectorVar_[i]); + model_input[i] = L1TauEmu::tauinput_t(NNvectorVar_[i]); } - layer2_t layer2_out[N_LAYER_2]; - nnet::dense(model_input, layer2_out, w2, b2); // Dense_1 - - layer4_t layer4_out[N_LAYER_2]; - nnet::relu(layer2_out, layer4_out); // relu_1 - - layer5_t layer5_out[N_LAYER_5]; - nnet::dense(layer4_out, layer5_out, w5, b5); // Dense_2 - - layer7_t layer7_out[N_LAYER_5]; - nnet::relu(layer5_out, layer7_out); // relu_2 - - layer8_t layer8_out[N_LAYER_8]; - nnet::dense(layer7_out, layer8_out, w8, b8); // Dense_3 - - layer10_t layer10_out[N_LAYER_8]; - nnet::relu(layer8_out, layer10_out); // relu_3 - - layer11_t layer11_out[N_LAYER_11]; - nnet::dense(layer10_out, layer11_out, w11, b11); // Dense_4 - - layer13_t layer13_out[N_LAYER_11]; - nnet::relu(layer11_out, layer13_out); // relu_4 - - layer14_t layer14_out[N_LAYER_14]; - nnet::dense(layer13_out, layer14_out, w14, b14); // Dense_5 - - layer16_t layer16_out[N_LAYER_14]; - nnet::relu(layer14_out, layer16_out); // relu_5 - - layer17_t layer17_out[N_LAYER_17]; - nnet::dense(layer16_out, layer17_out, w17, b17); // Dense_6 - - result_t layer19_out[N_LAYER_17]; - nnet::sigmoid(layer17_out, layer19_out); // jetID_output - - result_t layer20_out[N_LAYER_20]; - nnet::dense(layer16_out, layer20_out, w20, b20); // pT_output + typedef std::pair, std::array> pairtype; + pairtype modelResult; + modelRef_->prepare_input(model_input); + modelRef_->predict(); + modelRef_->read_result(&modelResult); // Return both pT correction and the NN ID Tau_NN_Result nn_out; - nn_out.nn_pt_correction = layer20_out[0]; - nn_out.nn_id = layer19_out[0]; + nn_out.nn_pt_correction = modelResult.first[0]; + nn_out.nn_id = modelResult.second[0]; return nn_out; } @@ -95,10 +67,10 @@ Tau_NN_Result TauNNIdHW::EvaluateNN() { // Uncomment for debugging purposes void TauNNIdHW::print() { for (unsigned i0 = 0; i0 < fNParticles_; i0++) { - input_t pPt = input_t(fPt_.get()[i0]); - input_t pEta = input_t(fEta_.get()[i0]); - input_t pPhi = input_t(fPhi_.get()[i0]); - input_t pId = input_t(fId_.get()[i0]); + tauinput_t pPt = tauinput_t(fPt_.get()[i0]); + tauinput_t pEta = tauinput_t(fEta_.get()[i0]); + tauinput_t pPhi = tauinput_t(fPhi_.get()[i0]); + tauinput_t pId = tauinput_t(fId_.get()[i0]); fprintf(file_, " %08x", pPt.to_uint()); fprintf(file_, " %08x", pEta.to_uint()); fprintf(file_, " %08x", pPhi.to_uint()); diff --git a/L1Trigger/Phase2L1ParticleFlow/test/BuildFile.xml b/L1Trigger/Phase2L1ParticleFlow/test/BuildFile.xml new file mode 100644 index 0000000000000..950ed6837762f --- /dev/null +++ b/L1Trigger/Phase2L1ParticleFlow/test/BuildFile.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/L1Trigger/Phase2L1ParticleFlow/test/testNNPuppiTauModel.cppunit.cc b/L1Trigger/Phase2L1ParticleFlow/test/testNNPuppiTauModel.cppunit.cc new file mode 100644 index 0000000000000..1353b1b4c523b --- /dev/null +++ b/L1Trigger/Phase2L1ParticleFlow/test/testNNPuppiTauModel.cppunit.cc @@ -0,0 +1,68 @@ +//Test of the externally-built NNPuppiTauModel hls4ml emulator: model +//loading (incl. multiple versions/instances in the same process, the +//scenario that used to clash on un-namespaced weight symbols, see +//cms-sw/cmssw#49632) and a basic predict() sanity check. + +#include "ap_fixed.h" +#include "hls4ml/emulator.h" + +#include "cppunit/extensions/HelperMacros.h" +#include +#include +#include "Utilities/Testing/interface/CppUnit_testdriver.icpp" + +namespace { + typedef ap_fixed<16, 10> tauinput_t; + typedef ap_fixed<16, 6> tauresult_t; + constexpr int kNInputs = 80; + constexpr char const* kModelName = "NNPuppiTauModel_v1"; +} // namespace + +class test_NNPuppiTauModel : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(test_NNPuppiTauModel); + CPPUNIT_TEST(doModelLoad); + CPPUNIT_TEST(doMultiModelLoad); + CPPUNIT_TEST(doPredictSanity); + CPPUNIT_TEST_SUITE_END(); + +public: + void doModelLoad(); + void doMultiModelLoad(); + void doPredictSanity(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(test_NNPuppiTauModel); + +void test_NNPuppiTauModel::doModelLoad() { + auto loader = hls4mlEmulator::ModelLoader(kModelName); + auto model = loader.load_model(); +} + +void test_NNPuppiTauModel::doMultiModelLoad() { + auto loader_a = hls4mlEmulator::ModelLoader(kModelName); + auto loader_b = hls4mlEmulator::ModelLoader(kModelName); + auto model_a = loader_a.load_model(); + auto model_b = loader_b.load_model(); +} + +void test_NNPuppiTauModel::doPredictSanity() { + auto loader = hls4mlEmulator::ModelLoader(kModelName); + auto model = loader.load_model(); + + // All-zero input: not physically representative, but exercises the full + // dense/relu/sigmoid layer sequence and checks the returned values land in + // the expected output ranges. + tauinput_t input[kNInputs]; + for (int i = 0; i < kNInputs; ++i) + input[i] = tauinput_t(0); + + typedef std::pair, std::array> pairtype; + pairtype result; + model->prepare_input(input); + model->predict(); + model->read_result(&result); + + // nn_id (result.second) is the output of a sigmoid layer: must lie in [0, 1]. + double nn_id = double(result.second[0]); + CPPUNIT_ASSERT(nn_id >= 0. && nn_id <= 1.); +}