Skip to content

Commit

Permalink
use constexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
mbluj committed May 17, 2024
1 parent d376eb3 commit 3f21c28
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ namespace lutNN {
LutLayer1;
LutLayer1 lutLayer1;

static const unsigned int noHitCntShift = layer1_output_I; //FIXME should be layer1_output_I ???
static constexpr unsigned int noHitCntShift = layer1_output_I; //FIXME should be layer1_output_I ???

static const int layer2_input_F = layer1_lut_F;
static constexpr int layer2_input_F = layer1_lut_F;

typedef LutNeuronLayerFixedPoint<layer2_input_I,
layer2_input_F,
Expand All @@ -77,7 +77,7 @@ namespace lutNN {
LutLayer2;
LutLayer2 lutLayer2;

static const int layer3_input_F = layer2_lut_F;
static constexpr int layer3_input_F = layer2_lut_F;

typedef LutNeuronLayerFixedPoint<layer3_input_I,
layer3_input_F,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ namespace lutNN {
template <int input_I, int input_F, size_t inputSize, int lut_I, int lut_F, int neurons, int output_I>
class LutNeuronLayerFixedPoint {
public:
static const int input_W = input_I + input_F;
static const int lut_W = lut_I + lut_F;
static constexpr int input_W = input_I + input_F;
static constexpr int lut_W = lut_I + lut_F;

//the lut out values sum
//static const int lutOutSum_I = lut_I + ceil(log2(inputSize)); //MB: ceil(log2(inputSize)) is not constexpr which makes issue for code-checks
static const int lutOutSum_I = lut_I + ceillog2(inputSize);
static const int lutOutSum_W = lutOutSum_I + lut_F;
static constexpr int lutOutSum_I = lut_I + ceillog2(inputSize);
static constexpr int lutOutSum_W = lutOutSum_I + lut_F;

static const int output_W = output_I + lut_F;
static constexpr int output_W = output_I + lut_F;

//static_assert( (1<<input_I) <= lutSize);
static const size_t lutSize = 1 << input_I;
static constexpr size_t lutSize = 1 << input_I;

typedef std::array<ap_ufixed<input_W, input_I, AP_TRN, AP_SAT>, inputSize> inputArrayType;

Expand Down
44 changes: 22 additions & 22 deletions L1Trigger/L1TMuonOverlapPhase2/src/PtAssignmentNNRegression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,35 @@
#include <fstream>

namespace lutNN {
static const int input_I = 10;
static const int input_F = 4;
static const std::size_t networkInputSize = 18;
static constexpr int input_I = 10;
static constexpr int input_F = 4;
static constexpr std::size_t networkInputSize = 18;

static const int layer1_neurons = 16;
static const int layer1_lut_I = 3;
static const int layer1_lut_F = 13;
static constexpr int layer1_neurons = 16;
static constexpr int layer1_lut_I = 3;
static constexpr int layer1_lut_F = 13;

static const int layer1_output_I = 4;
static constexpr int layer1_output_I = 4;
//4 bits are for the count of the noHit layers which goes to the input of the layer2
static const int layer2_input_I = 8;
static constexpr int layer2_input_I = 8;

static const int layer2_neurons = 9;
static const int layer2_lut_I = 5;
static const int layer2_lut_F = 11;
static constexpr int layer2_neurons = 9;
static constexpr int layer2_lut_I = 5;
static constexpr int layer2_lut_F = 11;

static const int layer3_input_I = 5;
static constexpr int layer3_input_I = 5;

static const int layer3_0_inputCnt = 8;
static const int layer3_0_lut_I = 5;
static const int layer3_0_lut_F = 11;
static const int output0_I = 8;
static const int output0_F = 2;
static constexpr int layer3_0_inputCnt = 8;
static constexpr int layer3_0_lut_I = 5;
static constexpr int layer3_0_lut_F = 11;
static constexpr int output0_I = 8;
static constexpr int output0_F = 2;

static const int layer3_1_inputCnt = 1;
static const int layer3_1_lut_I = 4;
static const int layer3_1_lut_F = 11;
static const int output1_I = 8;
static const int output1_F = 0; //Does not matter in principle - it is not used
static constexpr int layer3_1_inputCnt = 1;
static constexpr int layer3_1_lut_I = 4;
static constexpr int layer3_1_lut_F = 11;
static constexpr int output1_I = 8;
static constexpr int output1_F = 0; //Does not matter in principle - it is not used

typedef LutNetworkFixedPointRegression2Outputs<input_I,
input_F,
Expand Down

0 comments on commit 3f21c28

Please sign in to comment.