EDM4eic
EIC data model
Loading...
Searching...
No Matches
MutableTensor.h
Go to the documentation of this file.
1// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2
3#ifndef EDM4EIC_MutableTensor_H
4#define EDM4EIC_MutableTensor_H
5
6#include "edm4eic/TensorObj.h"
7// Make the immutable class available from its mutable version but not vice versa
8#include "edm4eic/Tensor.h"
9
10#include "podio/RelationRange.h"
11#include <cstdint>
12#include <vector>
13
14#include "podio/utilities/MaybeSharedPtr.h"
15
16#include <ostream>
17#include <cstddef>
18
19#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
20#include "nlohmann/json_fwd.hpp"
21#endif
22
23
24
25namespace edm4eic {
26
27
28/** @class MutableTensor
29 * Tensor type for use in training in inference of ML models
30 * @author: D. Kalinkin
31 */
33
34 friend class TensorCollection;
36 friend class Tensor;
37
38public:
41
42 /// default constructor
44
45 /// Constructor initializing all members
46 MutableTensor(std::int32_t elementType);
47
48 /// copy constructor
49 MutableTensor(const MutableTensor& other) = default;
50
51 /// copy-assignment operator
53
54 /// create a mutable deep-copy of the object with identical relations
55 MutableTensor clone() const;
56
57 /// destructor
58 ~MutableTensor() = default;
59
60
61 /// conversion to const object
62 operator Tensor() const;
63
64public:
65
66 /// Access the Data type in the same encoding as "ONNXTensorElementDataType", 1 - float, 7 - int64
67 std::int32_t getElementType() const;
68
69
70
71 /// Set the Data type in the same encoding as "ONNXTensorElementDataType", 1 - float, 7 - int64
72 void setElementType(std::int32_t value);
73
74
75
76 void addToShape(std::int64_t);
77 std::size_t shape_size() const;
78 std::int64_t getShape(std::size_t) const;
79 std::vector<std::int64_t>::const_iterator shape_begin() const;
80 std::vector<std::int64_t>::const_iterator shape_end() const;
81 podio::RelationRange<std::int64_t> getShape() const;
82 void addToFloatData(float);
83 std::size_t floatData_size() const;
84 float getFloatData(std::size_t) const;
85 std::vector<float>::const_iterator floatData_begin() const;
86 std::vector<float>::const_iterator floatData_end() const;
87 podio::RelationRange<float> getFloatData() const;
88 void addToInt64Data(std::int64_t);
89 std::size_t int64Data_size() const;
90 std::int64_t getInt64Data(std::size_t) const;
91 std::vector<std::int64_t>::const_iterator int64Data_begin() const;
92 std::vector<std::int64_t>::const_iterator int64Data_end() const;
93 podio::RelationRange<std::int64_t> getInt64Data() const;
94
95
96
97 /// check whether the object is actually available
98 bool isAvailable() const;
99 /// disconnect from TensorObj instance
100 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TensorObj>{nullptr}; }
101
102 bool operator==(const MutableTensor& other) const { return m_obj == other.m_obj; }
103 bool operator==(const Tensor& other) const;
104
105 // less comparison operator, so that objects can be e.g. stored in sets.
106 bool operator<(const MutableTensor& other) const { return m_obj < other.m_obj; }
107
108 podio::ObjectID id() const { return getObjectID(); }
109
110 const podio::ObjectID getObjectID() const;
111
112 friend void swap(MutableTensor& a, MutableTensor& b) {
113 using std::swap;
114 swap(a.m_obj, b.m_obj); // swap out the internal pointers
115 }
116
117private:
118 /// constructor from existing TensorObj
119 explicit MutableTensor(podio::utils::MaybeSharedPtr<TensorObj> obj);
120
121 podio::utils::MaybeSharedPtr<TensorObj> m_obj{nullptr};
122};
123
124#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
125void to_json(nlohmann::json& j, const MutableTensor& value);
126#endif
127
128
129} // namespace edm4eic
130
131
132#endif
Definition MutableTensor.h:32
bool isAvailable() const
check whether the object is actually available
Definition MutableTensor.cc:160
void addToFloatData(float)
Definition MutableTensor.cc:83
friend class Tensor
Definition MutableTensor.h:36
MutableTensor(const MutableTensor &other)=default
copy constructor
bool operator<(const MutableTensor &other) const
Definition MutableTensor.h:106
std::vector< float >::const_iterator floatData_end() const
Definition MutableTensor.cc:94
MutableTensor & operator=(MutableTensor other)
copy-assignment operator
Definition MutableTensor.cc:29
void addToInt64Data(std::int64_t)
Definition MutableTensor.cc:119
podio::ObjectID id() const
Definition MutableTensor.h:108
friend class TensorCollection
Definition MutableTensor.h:34
MutableTensor()
default constructor
Definition MutableTensor.cc:21
podio::RelationRange< std::int64_t > getInt64Data() const
Definition MutableTensor.cc:147
friend void swap(MutableTensor &a, MutableTensor &b)
Definition MutableTensor.h:112
podio::RelationRange< float > getFloatData() const
Definition MutableTensor.cc:111
std::size_t floatData_size() const
Definition MutableTensor.cc:100
std::int32_t getElementType() const
Access the Data type in the same encoding as "ONNXTensorElementDataType", 1 - float,...
Definition MutableTensor.cc:41
~MutableTensor()=default
destructor
std::vector< std::int64_t >::const_iterator int64Data_end() const
Definition MutableTensor.cc:130
podio::RelationRange< std::int64_t > getShape() const
Definition MutableTensor.cc:75
std::vector< std::int64_t >::const_iterator int64Data_begin() const
Definition MutableTensor.cc:124
std::vector< std::int64_t >::const_iterator shape_begin() const
Definition MutableTensor.cc:52
bool operator==(const MutableTensor &other) const
Definition MutableTensor.h:102
std::size_t int64Data_size() const
Definition MutableTensor.cc:136
MutableTensor clone() const
create a mutable deep-copy of the object with identical relations
Definition MutableTensor.cc:34
void setElementType(std::int32_t value)
Set the Data type in the same encoding as "ONNXTensorElementDataType", 1 - float, 7 - int64.
Definition MutableTensor.cc:44
std::vector< float >::const_iterator floatData_begin() const
Definition MutableTensor.cc:88
std::size_t shape_size() const
Definition MutableTensor.cc:64
void addToShape(std::int64_t)
Definition MutableTensor.cc:47
std::vector< std::int64_t >::const_iterator shape_end() const
Definition MutableTensor.cc:58
void unlink()
disconnect from TensorObj instance
Definition MutableTensor.h:100
const podio::ObjectID getObjectID() const
Definition MutableTensor.cc:167
Definition TensorCollection.h:95
Definition Tensor.h:33
Definition TensorCollection.h:66
Definition CalorimeterHit.cc:18