Skip to content

Commit c085338

Browse files
committed
[tmva][sofie] Remove explicit function definitions that can be implicit
Follows up on 035cf0c. * Remove IO constructors of classes that don't support IO anyway because there is no `ClassDef` macro call, etc. * Use implicit move constructors and assignments for GNN RModel classes, because all data members can be correctly moved * Delete explicit destructors of helper classes that only reset the unique pointers, which would happen by default anyway * Don't delete copying of RModel and derived classes explicitly. Copying is already implicitly deleted because of the `std::unique_ptr` data members
1 parent 104a48f commit c085338

8 files changed

+4
-124
lines changed

Diff for: tmva/sofie/inc/TMVA/RModel.hxx

-7
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ private:
3838
std::unordered_map<std::string_view, size_t> fIntermediateTensorFrequencyLookup; ///<! lookup table for intermediate tensor frequency (transient)
3939

4040
public:
41-
// Rule of five: explicitly define move semantics, disallow copy
42-
RModel(RModel &&other) = default;
43-
RModel &operator=(RModel &&other) = default;
44-
RModel(const RModel &other) = delete;
45-
RModel &operator=(const RModel &other) = delete;
46-
~RModel() = default;
47-
4841
/**
4942
Default constructor. Needed to allow serialization of ROOT objects. See
5043
https://root.cern/manual/io_custom_classes/#restrictions-on-types-root-io-can-handle

Diff for: tmva/sofie/inc/TMVA/RModel_Base.hxx

-5
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ enum class FunctionRelation { INVALID = 0, NODES_EDGES = 1, NODES_GLOBALS = 2, E
101101

102102
class RModel_GNNBase : public RModel_Base {
103103
public:
104-
/**
105-
Default constructor. Needed to allow serialization of ROOT objects. See
106-
https://root.cern/manual/io_custom_classes/#restrictions-on-types-root-io-can-handle
107-
*/
108-
RModel_GNNBase() = default;
109104
virtual void Generate() = 0;
110105
virtual ~RModel_GNNBase() = default;
111106
};

Diff for: tmva/sofie/inc/TMVA/RModel_GNN.hxx

-23
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,6 @@ struct GNN_Init {
3939

4040
std::string filename;
4141

42-
~GNN_Init()
43-
{
44-
edges_update_block.reset();
45-
nodes_update_block.reset();
46-
globals_update_block.reset();
47-
48-
edge_node_agg_block.reset();
49-
edge_global_agg_block.reset();
50-
node_global_agg_block.reset();
51-
}
52-
5342
template <typename T>
5443
void createUpdateFunction(T &updateFunction)
5544
{
@@ -116,20 +105,8 @@ private:
116105
std::size_t num_global_features;
117106

118107
public:
119-
/**
120-
Default constructor. Needed to allow serialization of ROOT objects. See
121-
https://root.cern/manual/io_custom_classes/#restrictions-on-types-root-io-can-handle
122-
*/
123-
RModel_GNN() = default;
124108
RModel_GNN(GNN_Init &graph_input_struct);
125109

126-
// Rule of five: explicitly define move semantics, disallow copy
127-
RModel_GNN(RModel_GNN &&other);
128-
RModel_GNN &operator=(RModel_GNN &&other);
129-
RModel_GNN(const RModel_GNN &other) = delete;
130-
RModel_GNN &operator=(const RModel_GNN &other) = delete;
131-
~RModel_GNN() final = default;
132-
133110
void Generate() final;
134111
};
135112

Diff for: tmva/sofie/inc/TMVA/RModel_GraphIndependent.hxx

-19
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ struct GraphIndependent_Init {
5555
}
5656
}
5757
}
58-
59-
~GraphIndependent_Init()
60-
{
61-
edges_update_block.reset();
62-
nodes_update_block.reset();
63-
globals_update_block.reset();
64-
}
6558
};
6659

6760
class RModel_GraphIndependent final : public RModel_GNNBase {
@@ -80,20 +73,8 @@ private:
8073
std::size_t num_global_features;
8174

8275
public:
83-
/**
84-
Default constructor. Needed to allow serialization of ROOT objects. See
85-
https://root.cern/manual/io_custom_classes/#restrictions-on-types-root-io-can-handle
86-
*/
87-
RModel_GraphIndependent() = default;
8876
RModel_GraphIndependent(GraphIndependent_Init &graph_input_struct);
8977

90-
// Rule of five: explicitly define move semantics, disallow copy
91-
RModel_GraphIndependent(RModel_GraphIndependent &&other);
92-
RModel_GraphIndependent &operator=(RModel_GraphIndependent &&other);
93-
RModel_GraphIndependent(const RModel_GraphIndependent &other) = delete;
94-
RModel_GraphIndependent &operator=(const RModel_GraphIndependent &other) = delete;
95-
~RModel_GraphIndependent() final = default;
96-
9778
void Generate() final;
9879
};
9980

Diff for: tmva/sofie/inc/TMVA/SOFIE_common.hxx

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ namespace TMVA{
2525
namespace Experimental{
2626
namespace SOFIE{
2727

28-
//typedef RTensor tensor_t;
29-
3028
enum class ETensorType{
3129
UNDEFINED = 0, FLOAT = 1, UINT8 = 2, INT8 = 3, UINT16 = 4, INT16 = 5, INT32 = 6, INT64 = 7, STRING = 8, BOOL = 9, //order sensitive
3230
FLOAT16 = 10, DOUBLE = 11, UINT32 = 12, UINT64 = 13, COMPLEX64 = 14, COMPLEX28 = 15, BFLOAT16 = 16

Diff for: tmva/sofie/src/RModel.cxx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1298,13 +1298,13 @@ void RModel::OutputGenerated(std::string filename, bool append) {
12981298
void RModel::Streamer(TBuffer &R__b) {
12991299
if (R__b.IsReading()) {
13001300
RModel::Class()->ReadBuffer(R__b, this);
1301-
for(auto i=RModel::fInitializedTensors.begin(); i!=RModel::fInitializedTensors.end(); ++i) {
1302-
i->second.CastPersistentToShared();
1301+
for (auto & i : fInitializedTensors) {
1302+
i.second.CastPersistentToShared();
13031303
}
13041304
}
13051305
else {
1306-
for(auto i=RModel::fInitializedTensors.begin(); i!=RModel::fInitializedTensors.end(); ++i) {
1307-
i->second.CastSharedToPersistent();
1306+
for (auto & i : fInitializedTensors) {
1307+
i.second.CastSharedToPersistent();
13081308
}
13091309
RModel::Class()->WriteBuffer(R__b, this);
13101310
}

Diff for: tmva/sofie/src/RModel_GNN.cxx

-36
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,6 @@ namespace TMVA {
1010
namespace Experimental {
1111
namespace SOFIE {
1212

13-
RModel_GNN::RModel_GNN(RModel_GNN&& other) {
14-
edges_update_block = std::move(other.edges_update_block);
15-
nodes_update_block = std::move(other.nodes_update_block);
16-
globals_update_block = std::move(other.globals_update_block);
17-
18-
edge_node_agg_block = std::move(other.edge_node_agg_block);
19-
edge_global_agg_block = std::move(other.edge_global_agg_block);
20-
node_global_agg_block = std::move(other.node_global_agg_block);
21-
22-
num_nodes = std::move(other.num_nodes);
23-
num_edges = std::move(other.num_edges);
24-
25-
fName = std::move(other.fName);
26-
fFileName = std::move(other.fFileName);
27-
fParseTime = std::move(other.fParseTime);
28-
}
29-
30-
RModel_GNN& RModel_GNN::operator=(RModel_GNN&& other) {
31-
edges_update_block = std::move(other.edges_update_block);
32-
nodes_update_block = std::move(other.nodes_update_block);
33-
globals_update_block = std::move(other.globals_update_block);
34-
35-
edge_node_agg_block = std::move(other.edge_node_agg_block);
36-
edge_global_agg_block = std::move(other.edge_global_agg_block);
37-
node_global_agg_block = std::move(other.node_global_agg_block);
38-
39-
num_nodes = std::move(other.num_nodes);
40-
num_edges = std::move(other.num_edges);
41-
42-
fName = std::move(other.fName);
43-
fFileName = std::move(other.fFileName);
44-
fParseTime = std::move(other.fParseTime);
45-
46-
return *this;
47-
}
48-
4913
RModel_GNN::RModel_GNN(GNN_Init& graph_input_struct) {
5014
edges_update_block = std::move(graph_input_struct.edges_update_block);
5115
nodes_update_block = std::move(graph_input_struct.nodes_update_block);

Diff for: tmva/sofie/src/RModel_GraphIndependent.cxx

-28
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,6 @@ namespace TMVA {
88
namespace Experimental {
99
namespace SOFIE {
1010

11-
RModel_GraphIndependent::RModel_GraphIndependent(RModel_GraphIndependent&& other) {
12-
edges_update_block = std::move(other.edges_update_block);
13-
nodes_update_block = std::move(other.nodes_update_block);
14-
globals_update_block = std::move(other.globals_update_block);
15-
16-
num_nodes = std::move(other.num_nodes);
17-
num_edges = std::move(other.num_edges);
18-
19-
fName = std::move(other.fName);
20-
fFileName = std::move(other.fFileName);
21-
fParseTime = std::move(other.fParseTime);
22-
}
23-
24-
RModel_GraphIndependent& RModel_GraphIndependent::operator=(RModel_GraphIndependent&& other) {
25-
edges_update_block = std::move(other.edges_update_block);
26-
nodes_update_block = std::move(other.nodes_update_block);
27-
globals_update_block = std::move(other.globals_update_block);
28-
29-
num_nodes = std::move(other.num_nodes);
30-
num_edges = std::move(other.num_edges);
31-
32-
fName = std::move(other.fName);
33-
fFileName = std::move(other.fFileName);
34-
fParseTime = std::move(other.fParseTime);
35-
36-
return *this;
37-
}
38-
3911
RModel_GraphIndependent::RModel_GraphIndependent(GraphIndependent_Init& graph_input_struct) {
4012
edges_update_block = std::move(graph_input_struct.edges_update_block);
4113
nodes_update_block = std::move(graph_input_struct.nodes_update_block);

0 commit comments

Comments
 (0)