85 const std::vector<const Trk::SpacePoint*>& spacepoints,
86 std::vector<std::vector<uint32_t> >& tracks,
87 std::unordered_map<
int, std::unordered_map<int, float>>* )
const
89 int64_t numSpacepoints = (int64_t)spacepoints.size();
90 std::vector<float> eNodeFeatures;
91 std::vector<float> fNodeFeatures;
92 std::vector<float> gNodeFeatures;
93 std::vector<uint32_t> spacepointIDs;
97 for(
const auto&
sp: spacepoints){
99 regions.push_back(featureMap[
"region"]);
102 eNodeFeatures.push_back(
108 fNodeFeatures.push_back(
114 gNodeFeatures.push_back(
118 spacepointIDs.push_back(sp_idx++);
124 std::vector<Ort::Value> eInputTensor;
127 std::vector<Ort::Value> eOutputTensor;
128 std::vector<float> eOutputData;
136 std::vector<int64_t> senders;
137 std::vector<int64_t> receivers;
139 int64_t numEdges = senders.size();
142 eNodeFeatures.clear();
143 eInputTensor.clear();
145 eOutputTensor.clear();
148 std::vector<std::pair<int64_t, int64_t>> edgePairs;
149 for(int64_t idx = 0; idx < numEdges; idx ++ ) {
150 edgePairs.push_back({senders[idx], receivers[idx]});
152 std::sort(edgePairs.begin(), edgePairs.end());
153 edgePairs.erase(
std::unique(edgePairs.begin(), edgePairs.end()), edgePairs.end());
156 std::random_device rd;
157 std::mt19937 rdm_gen(rd());
158 std::random_shuffle(edgePairs.begin(), edgePairs.end());
161 std::sort(edgePairs.begin(), edgePairs.end(),
162 [numSpacepoints](
const std::pair<int64_t, int64_t>&
a,
const std::pair<int64_t, int64_t>& b){
163 return a.first * numSpacepoints + a.second < b.first * numSpacepoints + b.second;
169 for(
const auto& edge: edgePairs){
170 senders.push_back(edge.first);
171 receivers.push_back(edge.second);
179 std::vector<Ort::Value> fInputTensor;
182 std::vector<int64_t> edgeList(numEdges * 2);
183 std::copy(senders.begin(), senders.end(), edgeList.begin());
184 std::copy(receivers.begin(), receivers.end(), edgeList.begin() + senders.size());
189 std::vector<float> fOutputData;
190 std::vector<Ort::Value> fOutputTensor;
198 std::vector<int64_t> rowIndices;
199 std::vector<int64_t> colIndices;
200 for (int64_t i = 0; i < numEdges; i++){
201 float v = 1.f / (1.f + std::exp(-fOutputData[i]));
203 auto src = edgeList[i];
204 auto dst = edgeList[numEdges + i];
208 rowIndices.push_back(src);
209 colIndices.push_back(dst);
212 int64_t numEdgesAfterF = rowIndices.size();
215 fNodeFeatures.clear();
216 fInputTensor.clear();
218 fOutputTensor.clear();
223 std::vector<int64_t> edgesAfterFiltering(numEdgesAfterF * 2);
224 std::copy(rowIndices.begin(), rowIndices.end(), edgesAfterFiltering.begin());
225 std::copy(colIndices.begin(), colIndices.end(), edgesAfterFiltering.begin() + senders.size());
232 for(
size_t idx = 0; idx < static_cast<size_t>(numSpacepoints); idx++){
240 std::vector<Ort::Value> gInputTensor;
245 std::vector<float> gnnEdgeFeatures;
250 std::vector<float> gOutputData;
251 std::vector<Ort::Value> gOutputTensor;
256 for(
auto& v : gOutputData){
257 v = 1.f / (1.f + std::exp(-v));
261 gNodeFeatures.clear();
262 gInputTensor.clear();
263 edgesAfterFiltering.clear();
271 rowIndices, colIndices, gOutputData,
275 return StatusCode::SUCCESS;