-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathProcessors.h
More file actions
88 lines (76 loc) · 2.47 KB
/
Processors.h
File metadata and controls
88 lines (76 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// @file Processors.h
/// @author SwirtaB
///
#ifndef O2_ZDC_FAST_SIMULATIONS_PROCESSORS_H
#define O2_ZDC_FAST_SIMULATIONS_PROCESSORS_H
#if __has_include(<onnxruntime/core/session/onnxruntime_cxx_api.h>)
#include <onnxruntime/core/session/onnxruntime_cxx_api.h>
#else
#include <onnxruntime_cxx_api.h>
#endif
#include <optional>
#include <vector>
namespace o2::zdc::fastsim::processors
{
class StandardScaler
{
public:
StandardScaler() = default;
~StandardScaler() = default;
/**
* @brief Scales data with standard scale algorithm
*
* @param data
* @return std::optional<std::vector<float>>
*/
[[nodiscard]] std::optional<std::vector<float>> scale(const std::vector<float>& data) const;
/**
* @brief Scales batch of data with standard scale algorithm
*
* @param data
* @return std::optional<std::vector<std::vector<float>>>
*/
[[nodiscard]] std::optional<std::vector<std::vector<float>>> scale_batch(
const std::vector<std::vector<float>>& data) const;
/**
* @brief Sets scales for standard scaler. Checks if sizes of scales are equal.
*
* @param means
* @param scales
* @return true on success
* @return false on fail
*/
bool setScales(const std::vector<float>& means, const std::vector<float>& scales);
private:
std::vector<float> mMeans;
std::vector<float> mScales;
};
/**
* @brief Reads predicted class as int
*
* @param value model prediction
* @param batchSize
* @return std::vector<int> casted results
*/
std::vector<int> readClassifier(const Ort::Value& value, size_t batchSize);
/**
* @brief Calculate 5 channels values from 44x44 float array (for every batch)
*
* @param value model prediction
* @param batchSize
* @return std::vector<std::array<long, 5>> calculated results
*/
std::vector<std::array<long, 5>> calculateChannels(const Ort::Value& value, size_t batchSize);
} // namespace o2::zdc::fastsim::processors
#endif // O2_ZDC_FAST_SIMULATIONS_PROCESSORS_H