ATLAS Offline Software
Loading...
Searching...
No Matches
TileNNEmulator.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TILERECUTILS_TILENNEMULATOR_H
6#define TILERECUTILS_TILENNEMULATOR_H
7#include <cstdint>
8#include <string>
9#include <vector>
10
16 public:
17
26 bool load(const std::string& jsonText, std::string& error);
27 int nSamples() const { return m_nSamples; }
28
30 float sValue(float hg, float lg) const;
31
35 int64_t run(const float* s) const;
36
38 int outFracBits() const { return m_layers.back().outT.frac(); }
39 double amplitudeScale() const { return m_ampScale; }
40
41 private:
42 enum class Round { RND_CONV, TRN };
43 enum class Sat { SAT, SAT_SYM, WRAP };
44
45 struct FixSpec {
46 int w = 0;
47 int i = 0;
50 int frac() const { return w - i; }
51 };
52
53 enum class Op { Dense, LeakyRelu };
54
55 struct Layer {
57 int nIn = 0;
58 int nOut = 0;
59 int alphaShift = 0;
61 std::vector<int64_t> w, b;
62 };
63
64 static int64_t rshiftRoundHalfEven(int64_t v, int k);
65 static int64_t castTo(int64_t v, int fracFrom, const FixSpec& spec);
66 int m_nSamples = 0;
67 double m_lgScale = 0.0;
68 double m_denominator = 0.0;
69 double m_ampScale = 0.0;
71 std::vector<Layer> m_layers;
72};
73
74#endif // TILERECUTILS_TILENNEMULATOR_H
Bit-exact software emulator of the TilePPr neural-network energy reconstruction.
double amplitudeScale() const
static int64_t castTo(int64_t v, int fracFrom, const FixSpec &spec)
float sValue(float hg, float lg) const
Combined dual-gain input sample S = (hg + lgScale*lg) / denominator.
static int64_t rshiftRoundHalfEven(int64_t v, int k)
std::vector< Layer > m_layers
int64_t run(const float *s) const
int outFracBits() const
Fractional bits of the output word (code * 2^-outFracBits() = value).
int nSamples() const
bool load(const std::string &jsonText, std::string &error)
std::vector< int64_t > w
std::vector< int64_t > b