triggerflow 0.2.5__py3-none-any.whl → 0.2.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,8 +2,6 @@
2
2
  #include "emulator.h"
3
3
  #include "NN/nnet_utils/nnet_common.h"
4
4
  #include <any>
5
- #include <array>
6
- #include <utility>
7
5
  #include "ap_fixed.h"
8
6
  #include "ap_int.h"
9
7
  #include "scales.h"
@@ -14,40 +12,45 @@ class {{MODEL_NAME}}_emulator : public hls4mlEmulator::Model {
14
12
 
15
13
  private:
16
14
  typedef {{UNSCALED_TYPE}} unscaled_t;
17
- static const int N_INPUT_SIZE = {{N_INPUTS}};
15
+ static const int N_INPUT_SIZE = {{N_INPUTS}};
16
+ static const int N_OUTPUT_SIZE = {{N_OUTPUTS}};
18
17
 
19
18
  unscaled_t _unscaled_input[N_INPUT_SIZE];
20
- {{MODEL_NAME}}::input_t _scaled_input;
21
- {{MODEL_NAME}}::result_t _result;
19
+ {{MODEL_NAME}}::input_t _scaled_input[N_INPUT_SIZE];
20
+ {{MODEL_NAME}}::result_t _result[N_OUTPUT_SIZE];
22
21
 
23
- // Scale the raw input array to the model input type
24
- virtual void _scaleNNInputs(unscaled_t unscaled[N_INPUT_SIZE], {{MODEL_NAME}}::input_t &scaled)
22
+ virtual void _scaleNNInputs(unscaled_t unscaled[N_INPUT_SIZE],
23
+ {{MODEL_NAME}}::input_t scaled[N_INPUT_SIZE])
25
24
  {
26
- for (int i = 0; i < N_INPUT_SIZE; i++)
27
- {
25
+ for (int i = 0; i < N_INPUT_SIZE; i++) {
28
26
  unscaled_t tmp0 = unscaled[i] - hls4ml_{{MODEL_NAME}}::ad_offsets[i];
29
- {{UNSCALED_TYPE}} tmp1 = tmp0 >> hls4ml_{{MODEL_NAME}}::ad_shift[i];
27
+ {{MODEL_NAME}}::input_t tmp1 = tmp0 >> hls4ml_{{MODEL_NAME}}::ad_shift[i];
30
28
  scaled[i] = tmp1;
31
29
  }
32
30
  }
33
31
 
34
32
  public:
35
- virtual void prepare_input(std::any input) {
36
- unscaled_t *unscaled_input_p = std::any_cast<unscaled_t*>(input);
33
+ virtual void prepare_input(std::any input) override {
34
+ unscaled_t* unscaled_input_p = std::any_cast<unscaled_t*>(input);
35
+
37
36
  for (int i = 0; i < N_INPUT_SIZE; i++) {
38
37
  _unscaled_input[i] = unscaled_input_p[i];
39
38
  }
39
+
40
40
  _scaleNNInputs(_unscaled_input, _scaled_input);
41
41
  }
42
42
 
43
- virtual void predict() {
44
- // Call the io_parallel model function; pass pointers
45
- {{MODEL_NAME}}::{{MODEL_NAME}}_project(&_scaled_input, &_result);
43
+ virtual void predict() override {
44
+ {{MODEL_NAME}}::{{MODEL_NAME}}_project(_scaled_input, _result);
46
45
  }
47
46
 
48
- virtual void read_result(std::any result) {
49
- {{MODEL_NAME}}::result_t *result_p = std::any_cast<{{MODEL_NAME}}::result_t*>(result);
50
- *result_p = _result;
47
+ virtual void read_result(std::any result) override {
48
+ {{MODEL_NAME}}::result_t* result_p =
49
+ std::any_cast<{{MODEL_NAME}}::result_t*>(result);
50
+
51
+ for (int i = 0; i < N_OUTPUT_SIZE; i++) {
52
+ result_p[i] = _result[i];
53
+ }
51
54
  }
52
55
  };
53
56
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: triggerflow
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: Utilities for ML models targeting hardware triggers
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -93,10 +93,10 @@ triggerflow/templates/data_types.h,sha256=m7_jLsRixSVjp8auxHZUUNAcSO777C5TTZl__9
93
93
  triggerflow/templates/makefile,sha256=A-aetsLC51Bop0T_-yPY8Z8Hg29ApN4YPvKx_jjPuHw,970
94
94
  triggerflow/templates/makefile_version,sha256=6kFc_u2oiM9l2rH7RK_BLzdZu1ZEK8PQTQKGBLRY0v4,328
95
95
  triggerflow/templates/model-gt.cpp,sha256=qZwuTtsvrKB_mOB-HDb2uOD7mDo4-20EjFiQzRjMdPo,2969
96
- triggerflow/templates/model_template.cpp,sha256=jMNRcO7NgC6I9Wd2BV3Bim-P1qPsAl_oeVQ8KofQGEw,1807
96
+ triggerflow/templates/model_template.cpp,sha256=Uh80AwDAcFlseonEwV7_HqD85ALs0IPG5JfVT204d5k,1887
97
97
  triggerflow/templates/scales.h,sha256=MFcB5S0DEvfzHuUhyZqILR0O4ktugOG-fLnuCDUUewM,373
98
- triggerflow-0.2.5.dist-info/METADATA,sha256=_psSoh10cZrBvYTjQIKQVw8m4VohIVsjdxlN1MYQazY,5535
99
- triggerflow-0.2.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
- triggerflow-0.2.5.dist-info/entry_points.txt,sha256=5QSV9YDseB_FqgVh9q10BdL4b1I6t68rGwPLXgVL60g,53
101
- triggerflow-0.2.5.dist-info/top_level.txt,sha256=cX0jkuM9tfxGp002ZBQ1AYgx-6D_NgBtomgPL0WA9bE,43
102
- triggerflow-0.2.5.dist-info/RECORD,,
98
+ triggerflow-0.2.7.dist-info/METADATA,sha256=vp6187RdnsGgdanBTqvY6jifqZmOZ8JoN92wGT7tBbM,5535
99
+ triggerflow-0.2.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
+ triggerflow-0.2.7.dist-info/entry_points.txt,sha256=5QSV9YDseB_FqgVh9q10BdL4b1I6t68rGwPLXgVL60g,53
101
+ triggerflow-0.2.7.dist-info/top_level.txt,sha256=cX0jkuM9tfxGp002ZBQ1AYgx-6D_NgBtomgPL0WA9bE,43
102
+ triggerflow-0.2.7.dist-info/RECORD,,