OpenGM  2.3.x
Discrete Graphical Model Library
graphicalmodel_hdf5.hxx
Go to the documentation of this file.
1 #pragma once
2 #ifndef OPENGM_GRAPHICALMODEL_HDF5_HXX
3 #define OPENGM_GRAPHICALMODEL_HDF5_HXX
4 
5 #include <string>
6 #include <iostream>
7 #include <sstream>
8 #include <typeinfo>
9 
10 #include "opengm/opengm.hxx"
14 
24 
25 namespace opengm {
26 
28 namespace hdf5 {
29 
31 template<class T>
32 struct IsValidTypeForHdf5Save {
33  typedef opengm::meta::Bool<
34  opengm::meta::Not<
35  opengm::meta::IsInvalidType<T>::value
36  >::value
37  > tmpBoolAType;
38  typedef opengm::meta::Bool<
39  std::numeric_limits<T>::is_specialized
40  > tmpBoolBType;
41  enum Values {
42  value=meta::And<tmpBoolAType::value,tmpBoolBType::value>::value
43  };
44 };
45 
46 struct StoredValueTypeInfo{
47  enum Values{
48  AsFloat=0,
49  AsDouble=1,
50  AsUInt=2,
51  AsInt=3
52  };
53 };
54 
55 template<class GM, size_t IX, size_t DX, bool END>
56 struct GetFunctionRegistration;
57 
58 template<class GM, size_t IX, size_t DX>
59 struct GetFunctionRegistration<GM, IX, DX, false> {
60  static size_t get(const size_t functionIndex) {
61  if(IX == functionIndex) {
62  typedef typename meta::TypeAtTypeList<typename GM::FunctionTypeList, IX>::type TypeAtIX ;
63  return FunctionRegistration< TypeAtIX >::Id;
64  }
65  else {
66  return GetFunctionRegistration
67  <
68  GM,
69  meta::Increment<IX>::value,
70  DX,
71  meta::EqualNumber<meta::Increment<IX>::value, DX>::value
72  >::get(functionIndex);
73  }
74  }
75 };
76 
77 template<class GM, size_t IX, size_t DX>
78 struct GetFunctionRegistration<GM, IX, DX, true>{
79  static size_t get(const size_t functionIndex) {
80  throw RuntimeError("Incorrect function type id.");
81  }
82 };
83 
84 template<class GM, size_t IX, size_t DX, bool END>
85 struct SaveAndLoadFunctions;
86 
87 template<class GM, size_t IX, size_t DX>
88 struct SaveAndLoadFunctions<GM, IX, DX, false>
89 {
90  template<class HDF5_HANDLE>
91  static void save
92  (
93  HDF5_HANDLE handle,
94  const GM& gm,
95  const opengm::UInt64Type storeValueTypeAs
96  ) {
97  if(meta::FieldAccess::template byIndex<IX>(gm.functionDataField_).functionData_.functions_.size() != 0)
98  {
99  // create group
100  std::stringstream ss;
101  typedef typename meta::TypeAtTypeList<typename GM::FunctionTypeList, IX>::type TypeAtIX;
102  ss << "function-id-" << (FunctionRegistration<TypeAtIX>::Id);
103  hid_t group = marray::hdf5::createGroup(handle, ss.str());
104 
105  // loop over all functions of this type
106  size_t indexCounter = 0;
107  size_t valueCounter = 0;
108  for(size_t i=0; i<meta::FieldAccess::template byIndex<IX>(gm.functionDataField_).functionData_.functions_.size(); ++i) {
109  indexCounter += FunctionSerialization<TypeAtIX>::indexSequenceSize(
110  meta::FieldAccess::template byIndex<IX> (gm.functionDataField_).functionData_.functions_[i]);
111  valueCounter += FunctionSerialization<TypeAtIX>::valueSequenceSize(
112  meta::FieldAccess::template byIndex<IX> (gm.functionDataField_).functionData_.functions_[i]);
113  }
114  marray::Vector<typename GM::ValueType> valueVector(valueCounter);
115  marray::Vector<opengm::UInt64Type> indexVector(indexCounter);
116  typename marray::Vector<typename GM::ValueType>::iterator valueIter = valueVector.begin();
117  typename marray::Vector<opengm::UInt64Type>::iterator indexIter = indexVector.begin();
118  for(size_t i=0; i<meta::FieldAccess::template byIndex<IX>(gm.functionDataField_).functionData_.functions_.size(); ++i) {
119  FunctionSerialization<TypeAtIX>::serialize(
120  meta::FieldAccess::template byIndex<IX> (gm.functionDataField_).functionData_.functions_[i], indexIter, valueIter);
121  indexIter+=FunctionSerialization<TypeAtIX>::indexSequenceSize(
122  meta::FieldAccess::template byIndex<IX> (gm.functionDataField_).functionData_.functions_[i]);
123  valueIter+=FunctionSerialization<TypeAtIX>::valueSequenceSize(
124  meta::FieldAccess::template byIndex<IX> (gm.functionDataField_).functionData_.functions_[i]);
125  }
126  marray::hdf5::save(group, std::string("indices"), indexVector);
127  OPENGM_ASSERT(storeValueTypeAs<4);
128  typedef typename GM::ValueType GmValueType;
129  if(storeValueTypeAs==static_cast<opengm::UInt64Type>(StoredValueTypeInfo::AsFloat)) {
130  typedef opengm::detail_types::Float StorageType;
131  if(opengm::meta::Compare<GmValueType,StorageType>::value==true) {
132  marray::hdf5::save(group, std::string("values"), valueVector);
133  }
134  else{
135  marray::Vector<StorageType> tmpValueVector=valueVector;
136  marray::hdf5::save(group, std::string("values"), tmpValueVector);
137  }
138  }
139  else if(storeValueTypeAs==static_cast<opengm::UInt64Type>(StoredValueTypeInfo::AsDouble)) {
140  typedef opengm::detail_types::Double StorageType;
141  if(opengm::meta::Compare<GmValueType,StorageType>::value==true) {
142  marray::hdf5::save(group, std::string("values"), valueVector);
143  }
144  else{
145  marray::Vector<StorageType> tmpValueVector=valueVector;
146  marray::hdf5::save(group, std::string("values"), tmpValueVector);
147  }
148  }
149  else if(storeValueTypeAs==static_cast<opengm::UInt64Type>(StoredValueTypeInfo::AsUInt)) {
150  typedef opengm::detail_types::UInt64Type StorageType;
151  if(opengm::meta::Compare<GmValueType,StorageType>::value==true) {
152  marray::hdf5::save(group, std::string("values"), valueVector);
153  }
154  else{
155  marray::Vector<StorageType> tmpValueVector=valueVector;
156  marray::hdf5::save(group, std::string("values"), tmpValueVector);
157  }
158  }
159  else if (storeValueTypeAs==static_cast<opengm::UInt64Type>(StoredValueTypeInfo::AsInt)) {
160  typedef opengm::detail_types::Int64Type StorageType;
161  if(opengm::meta::Compare<GmValueType,StorageType>::value==true) {
162  marray::hdf5::save(group, std::string("values"), valueVector);
163  }
164  else{
165  marray::Vector<StorageType> tmpValueVector=valueVector;
166  marray::hdf5::save(group, std::string("values"), tmpValueVector);
167  }
168  }
170  }
171 
172  // save functions of the next type in the typelist
173  typedef typename opengm::meta::Increment<IX>::type NewIX;
174  SaveAndLoadFunctions<GM, NewIX::value, DX, opengm::meta::EqualNumber<NewIX::value, DX>::value >::save(handle, gm,storeValueTypeAs);
175  }
176 
177  template<class HDF5_HANDLE>
178  static void load
179  (
180  HDF5_HANDLE handle,
181  GM& gm,
182  const std::vector<opengm::UInt64Type>& numberOfFunctions,
183  const std::vector<opengm::UInt64Type>& functionIndexLookup,
184  const std::vector<bool> & useFunction,
185  const opengm::UInt64Type loadValueTypeAs,
186  bool oldFormat=false
187  ) {
188  if(useFunction[IX]==true) {
189  size_t mappedIndex;
190  bool foundIndex=false;
191  for(size_t i=0;i<functionIndexLookup.size();++i) {
192  if(functionIndexLookup[i]==IX ) {
193  mappedIndex=i;
194  foundIndex=true;
195  break;
196  }
197  }
198  if(!foundIndex) {
199  throw RuntimeError("Could not load function.");
200  }
201 
202  if(numberOfFunctions[mappedIndex] != 0) {
203  // create subgroup
204  std::stringstream ss;
205  typedef typename meta::TypeAtTypeList<typename GM::FunctionTypeList, IX>::type TypeAtIX ;
206  ss << "function-id-" << (FunctionRegistration<TypeAtIX>::Id);
207  hid_t group = marray::hdf5::openGroup(handle, ss.str());
208  marray::Vector<typename GM::ValueType> serializationValues;
209  marray::Vector<opengm::UInt64Type> serializationIndicies;
210  {
211  std::string subDatasetName("indices");
212  marray::hdf5::load(group, subDatasetName, serializationIndicies);
213  }
214  {
215  std::string subDatasetName("values");
216  OPENGM_ASSERT(loadValueTypeAs<4);
217  typedef typename GM::ValueType GmValueType;
218  if(oldFormat==false) {
219  if(loadValueTypeAs==static_cast<opengm::UInt64Type>(StoredValueTypeInfo::AsFloat)) {
220  typedef opengm::detail_types::Float StorageType;
221  if(opengm::meta::Compare<GmValueType,StorageType>::value==true) {
222  marray::hdf5::load(group, subDatasetName, serializationValues);
223  }
224  else{
225  marray::Vector<StorageType> tmpSerializationValues;
226  marray::hdf5::load(group, subDatasetName, tmpSerializationValues);
227  serializationValues=tmpSerializationValues;
228  }
229  }
230  else if(loadValueTypeAs==static_cast<opengm::UInt64Type>(StoredValueTypeInfo::AsDouble)) {
231  typedef opengm::detail_types::Double StorageType;
232  if(opengm::meta::Compare<GmValueType,StorageType>::value==true) {
233  marray::hdf5::load(group, subDatasetName, serializationValues);
234  }
235  else{
236  marray::Vector<StorageType> tmpSerializationValues;
237  marray::hdf5::load(group, subDatasetName, tmpSerializationValues);
238  serializationValues=tmpSerializationValues;
239  }
240  }
241  else if(loadValueTypeAs==static_cast<opengm::UInt64Type>(StoredValueTypeInfo::AsUInt)) {
242  typedef opengm::detail_types::UInt64Type StorageType;
243  if(opengm::meta::Compare<GmValueType,StorageType>::value==true) {
244  marray::hdf5::load(group, subDatasetName, serializationValues);
245  }
246  else{
247  marray::Vector<StorageType> tmpSerializationValues;
248  marray::hdf5::load(group, subDatasetName, tmpSerializationValues);
249  serializationValues=tmpSerializationValues;
250  }
251  }
252  else if (loadValueTypeAs==static_cast<opengm::UInt64Type>(StoredValueTypeInfo::AsInt)) {
253  typedef opengm::detail_types::Int64Type StorageType;
254  if(opengm::meta::Compare<GmValueType,StorageType>::value==true) {
255  marray::hdf5::load(group, subDatasetName, serializationValues);
256  }
257  else{
258  marray::Vector<StorageType> tmpSerializationValues;
259  marray::hdf5::load(group, subDatasetName, tmpSerializationValues);
260  serializationValues=tmpSerializationValues;
261  }
262  }
263  }
264  else{
265  marray::hdf5::load(group, subDatasetName, serializationValues);
266  }
267 
268  }
269  // resize function
270  gm.template functions<IX>().resize(numberOfFunctions[mappedIndex]);
271  typename marray::Vector<opengm::UInt64Type>::const_iterator indexIter=serializationIndicies.begin();
272  typename marray::Vector<typename GM::ValueType>::const_iterator valueIter=serializationValues.begin();
273  // fill function with data
274  for(size_t i=0; i<meta::FieldAccess::template byIndex<IX> (gm.functionDataField_).functionData_.functions_.size(); ++i) {
275  FunctionSerialization<TypeAtIX>::deserialize(
276  indexIter, valueIter, meta::FieldAccess::template byIndex<IX> (gm.functionDataField_).functionData_.functions_[i]);
277  indexIter += FunctionSerialization<TypeAtIX>::indexSequenceSize(
278  meta::FieldAccess::template byIndex<IX> (gm.functionDataField_).functionData_.functions_[i]);
279  valueIter+=FunctionSerialization<TypeAtIX>::valueSequenceSize(
280  meta::FieldAccess::template byIndex<IX> (gm.functionDataField_).functionData_.functions_[i]);
281  }
283  }
284  }
285 
286  // load functions of the next type in the typelist
287  typedef typename opengm::meta::Increment<IX>::type NewIX;
288  SaveAndLoadFunctions<GM, NewIX::value, DX, opengm::meta::EqualNumber<NewIX::value, DX>::value >::load
289  (handle, gm, numberOfFunctions,functionIndexLookup,useFunction,loadValueTypeAs,oldFormat);
290  }
291 };
292 
293 template<class GM, size_t IX, size_t DX>
294 struct SaveAndLoadFunctions<GM, IX, DX, true> {
295  template<class HDF5_HANDLE>
296  static void save
297  (
298  HDF5_HANDLE handle,
299  const GM& gm,
300  const opengm::UInt64Type storeValueTypeAs
301  )
302  {
303 
304  }
305 
306  template<class HDF5_HANDLE>
307  static void load
308  (
309  HDF5_HANDLE handle,
310  GM& gm,
311  const std::vector<opengm::UInt64Type>& numberOfFunctions,
312  const std::vector<opengm::UInt64Type>& functionIndexLookup,
313  const std::vector<bool> & useFunction ,
314  const opengm::UInt64Type loadValueTypeAs,
315  bool oldFormat=false
316  )
317  {
318 
319  }
320 };
322 
327 template<class GM>
328 void save
329 (
330  const GM& gm,
331  const std::string& filepath,
332  const std::string& datasetName
333 )
334 {
335  typedef typename GM::ValueType ValueType;
336  typedef typename GM::FactorType FactorType;
337 
338  if(IsValidTypeForHdf5Save<typename GM::ValueType>::value==false) {
339  throw opengm::RuntimeError( std::string("ValueType has no support for hdf5 export") );
340  }
342  hid_t group = marray::hdf5::createGroup(file, datasetName);
343  std::vector<UInt64Type> serializationIndicies;
344  opengm::UInt64Type storeValueTypeAs;
345  // float
346  if(opengm::meta::Compare<opengm::detail_types::Float,ValueType>::value==true) {
347  storeValueTypeAs=static_cast<opengm::UInt64Type>(StoredValueTypeInfo::AsFloat);
348  }
349  //double
350  else if(opengm::meta::Compare<opengm::detail_types::Double,ValueType>::value==true) {
351  storeValueTypeAs=static_cast<opengm::UInt64Type>(StoredValueTypeInfo::AsDouble);
352  }
353  // long double
354  else if(opengm::meta::Compare<opengm::detail_types::LongDouble,ValueType>::value==true) {
355  throw RuntimeError(std::string("ValueType \" long double\" has no support for hdf5 export"));
356  }
357  // bool
358  else if(opengm::meta::Compare<opengm::detail_types::Bool,ValueType>::value==true) {
359  storeValueTypeAs = static_cast<opengm::UInt64Type> (StoredValueTypeInfo::AsUInt);
360  }
361  // unsigned integers
362  else if(std::numeric_limits<ValueType>::is_integer==true && std::numeric_limits<ValueType>::is_signed==false) {
363  storeValueTypeAs = static_cast<opengm::UInt64Type> (StoredValueTypeInfo::AsUInt);
364  }
365  // signed integers
366  else if(std::numeric_limits<ValueType>::is_integer==true && std::numeric_limits<ValueType>::is_signed==true) {
367  storeValueTypeAs = static_cast<opengm::UInt64Type> (StoredValueTypeInfo::AsInt);
368  }
369  else{
370  throw RuntimeError(std::string("ValueType has no support for hdf5 export"));
371  }
372  //opengm::UInt64Type
373  // save meta data
374  {
375  std::string subDatasetName("header");
376  serializationIndicies.push_back(VERSION_MAJOR);
377  serializationIndicies.push_back(VERSION_MINOR);
378  serializationIndicies.push_back(gm.numberOfVariables());
379  serializationIndicies.push_back(gm.factors_.size());
380  serializationIndicies.push_back(GM::NrOfFunctionTypes);
381  for(size_t i=0; i<GM::NrOfFunctionTypes; ++i) {
382  const size_t fRegId=GetFunctionRegistration
383  <
384  GM,
385  0,
386  GM::NrOfFunctionTypes,
387  meta::EqualNumber<GM::NrOfFunctionTypes, 0>::value
388  >::get(i);
389  serializationIndicies.push_back(fRegId);
390  serializationIndicies.push_back(gm.numberOfFunctions(i));
391  }
392  serializationIndicies.push_back(storeValueTypeAs);
393  marray::hdf5::save(group, subDatasetName, serializationIndicies);
394  }
395 
396  // save numbers of states
397  {
398  std::string subDatasetName("numbers-of-states");
399  serializationIndicies.resize(gm.numberOfVariables());
400  for(size_t i=0;i<gm.numberOfVariables();++i) {
401  serializationIndicies[i]=
402  static_cast<opengm::UInt64Type>(gm.numberOfLabels(i));
403  }
404  marray::hdf5::save(group, subDatasetName, serializationIndicies);
405  }
406  serializationIndicies.clear();
407 
408  // save all functions
410 
411  // save all factors
412  {
413  std::string subDatasetName("factors");
414  for(size_t i = 0; i < gm.factors_.size(); ++i) {
415  serializationIndicies.push_back(static_cast<opengm::UInt64Type>(gm.factors_[i].functionIndex_));
416  serializationIndicies.push_back(static_cast<opengm::UInt64Type>(gm.factors_[i].functionTypeId_));
417  serializationIndicies.push_back(static_cast<opengm::UInt64Type>(gm.factors_[i].numberOfVariables()));
418  for(size_t j = 0; j < gm.factors_[i].numberOfVariables(); ++j) {
419  //serializationIndicies.push_back(static_cast<opengm::UInt64Type> (gm.factors_[i].variableIndices_[j]));
420  serializationIndicies.push_back(static_cast<opengm::UInt64Type> (gm.factors_[i].variableIndex(j)));
421  }
422  }
423  if(serializationIndicies.size() != 0)marray::hdf5::save(group, subDatasetName, serializationIndicies);
424  }
427 }
428 
429 template<class GM>
430 void load
431 (
432  GM& gm,
433  const std::string& filepath,
434  const std::string& datasetName
435 )
436 {
437  typedef typename GM::ValueType ValueType;
438  typedef typename GM::FactorType FactorType;
440  hid_t group =marray::hdf5::openGroup(file, datasetName);
441  marray::Vector<opengm::UInt64Type> serializationIndicies;
442  std::vector<opengm::UInt64Type> numberOfFunctions;
443  std::vector<opengm::UInt64Type> functionIndexLookup;
444  std::vector<bool> useFunction(GM::NrOfFunctionTypes,false);
445  marray::Vector<opengm::UInt64Type> typeRegisterId;
446  //size_t numberOfVariables;
447  bool oldFormat=false;
448  opengm::UInt64Type loadValueTypeAs=0;
449  {
450  std::string subDatasetName("header");
451  marray::hdf5::load(group, subDatasetName, serializationIndicies);
452  OPENGM_CHECK_OP(serializationIndicies.size() ,>, 5," ")
453  //OPENGM_CHECK_OP(serializationIndicies.size() ,<=, 5 + 2 * GM::NrOfFunctionTypes+1," ")
454  //OPENGM_ASSERT( serializationIndicies.size() > 5 && serializationIndicies.size() <= 5 + 2 * GM::NrOfFunctionTypes+1);
455  if(!(serializationIndicies.size() > 5 && serializationIndicies.size() <= 5 + 2 * GM::NrOfFunctionTypes)) {
456  }
457  if(serializationIndicies[0] != 2 || serializationIndicies[1] != 0) {
458  throw RuntimeError("This version of the HDF5 file format is not supported by this version of OpenGM.");
459  }
460  //numberOfVariables=serializationIndicies[2];
461  //gm.numbersOfStates_.resize(serializationIndicies[2]);
462  gm.factors_.resize(serializationIndicies[3], FactorType(&gm));
463  numberOfFunctions.resize(serializationIndicies[4]);
464  functionIndexLookup.resize(serializationIndicies[4]);
465  typeRegisterId.resize(serializationIndicies[4]);
466  for(size_t i=0; i<numberOfFunctions.size(); ++i) {
467  //const size_t fRegId=GetFunctionRegistration<GM, 0, GM::NrOfFunctionTypes, meta::EqualNumber<GM::NrOfFunctionTypes, 0>::value>::get(i);
468  typeRegisterId[i]=serializationIndicies[5 + 2 * i];
469  numberOfFunctions[i]=serializationIndicies[5 + 2*i + 1];
470  }
471 
472  if(serializationIndicies.size()!=5+2*numberOfFunctions.size()+1) {
473  if(serializationIndicies.size()==5+2*numberOfFunctions.size()) {
474  oldFormat=true;
475  }
476  else{
477  throw RuntimeError(std::string("error in hdf5 file"));
478  }
479  }
480  else{
481  loadValueTypeAs=serializationIndicies[serializationIndicies.size()-1];
482  OPENGM_ASSERT(loadValueTypeAs<4);
483  }
484  // check if saved function (type list) is a subset of the typelist of the
485  // gm in which we want to load
486  for(size_t i=0; i<numberOfFunctions.size(); ++i) {
487  opengm::UInt64Type regIdToFind=typeRegisterId[i];
488  bool foundId=false;
489  for(size_t j=0; j<GM::NrOfFunctionTypes; ++j) {
490  opengm::UInt64Type regIdInList=GetFunctionRegistration<GM, 0, GM::NrOfFunctionTypes, meta::EqualNumber<GM::NrOfFunctionTypes, 0>::value>::get(j);
491  if(regIdToFind==regIdInList ) {
492  foundId=true;
493  functionIndexLookup[i]=j;
494  useFunction[j]=true;
495  break;
496  }
497  }
498  if(foundId==false && numberOfFunctions[i]!=0) {
499  std::stringstream ss;
500  ss << "The HDF5 file contains the function type "
501  << regIdToFind
502  << " which is not contained in the type list in the C++ code.";
503  throw RuntimeError(ss.str());
504  }
505  }
506  }
507  //if(numberOfVariables != 0) {
508  std::string subDatasetName("numbers-of-states");
509  marray::hdf5::load(group, subDatasetName, serializationIndicies);
510  gm.space_.assignDense(serializationIndicies.begin(), serializationIndicies.end());
511  OPENGM_ASSERT(serializationIndicies.size() == gm.numberOfVariables());
512  //}
514  (group, gm, numberOfFunctions,functionIndexLookup,useFunction,loadValueTypeAs,oldFormat);
515 
516  gm.factorsVis_.clear();
517 
518  if(gm.factors_.size() != 0) {
519 
520  std::string subDatasetName("factors");
521  marray::hdf5::load(group, subDatasetName, serializationIndicies);
522  size_t sIndex = 0;
523  for(size_t i = 0; i < gm.factors_.size(); ++i) {
524  gm.factors_[i].functionIndex_ = static_cast<opengm::UInt64Type> (serializationIndicies[sIndex]);
525  sIndex++;
526  gm.factors_[i].functionTypeId_ =
527  functionIndexLookup[static_cast<opengm::UInt64Type> (serializationIndicies[sIndex])];
528  sIndex++;
529 
530 
531  //factorsVis_
532  const opengm::UInt64Type order = static_cast<opengm::UInt64Type> (serializationIndicies[sIndex]);
533  const opengm::UInt64Type indexInVisVector = static_cast<opengm::UInt64Type> (gm.factorsVis_.size());
534 
535  gm.factors_[i].vis_.assign(gm.factorsVis_,indexInVisVector,order);
536  gm.order_ = std::max( static_cast<size_t>(gm.order_),
537  static_cast<size_t>(order));
538 
539  //gm.factors_[i].order_=static_cast<opengm::UInt64Type> (serializationIndicies[sIndex]);
540  //gm.factors_[i].indexInVisVector_=static_cast<opengm::UInt64Type> (gm.factorsVis_.size());
541 
542  sIndex++;
543  for(size_t j = 0; j < gm.factors_[i].numberOfVariables(); ++j) {
544  gm.factorsVis_.push_back( static_cast<opengm::UInt64Type> (serializationIndicies[sIndex]));
545  sIndex++;
546  }
547 
548 
549 
550  }
551  }
552 
555  gm.variableFactorAdjaceny_.resize(gm.numberOfVariables());
556  // adjacenies
557 
558  for(size_t i=0; i<gm.numberOfFactors(); ++i) {
559  for(size_t vi=0;vi<gm[i].numberOfVariables(); ++vi) {
560  gm.variableFactorAdjaceny_[ gm[i].variableIndex(vi) ].insert(i);
561  }
562  //typedef functionwrapper::AddFactorUpdateAdjacencyWrapper<GM::NrOfFunctionTypes> WrapperType;
563  //WrapperType::op(gm.functionDataField_, gm[i].functionIndex(), i, gm[i].functionType());
564  }
565  //gm.initializeFactorFunctionAdjacency();
566 }
567 
568 } // namespace hdf5
569 } // namespace opengm
570 
571 #endif // #ifndef OPENGM_GRAPHICALMODEL_HDF5_HXX
The OpenGM namespace.
Definition: config.hxx:43
hid_t createFile(const std::string &, HDF5Version=DEFAULT_HDF5_VERSION)
Create an HDF5 file.
STL-compliant random access iterator for View and Marray.
Definition: marray.hxx:49
void load(GM_ &gm, const std::string &, const std::string &)
detail_types::Int64Type Int64Type
int32
Definition: config.hxx:308
hid_t createGroup(const hid_t &, const std::string &)
Create an HDF5 group.
#define OPENGM_ASSERT(expression)
Definition: opengm.hxx:77
void load(const hid_t &, const std::string &, Marray< T > &)
Load an Marray from an HDF5 dataset.
const unsigned int VERSION_MAJOR
major version number of opengm
Definition: config.hxx:47
One-dimensional Marray.
Definition: marray.hxx:50
detail_types::UInt64Type UInt64Type
uint64
Definition: config.hxx:300
const size_t size() const
void closeFile(const hid_t &)
Close an HDF5 file.
void save(const hid_t &, const std::string &, const Marray< T > &)
Save an Marray as an HDF5 dataset.
#define OPENGM_CHECK_OP(A, OP, B, TXT)
Definition: submodel2.hxx:24
void resize(const size_t, const T &=T())
Resize (existing entries are preserved, new entries are initialized).
Definition: marray.hxx:4912
void closeGroup(const hid_t &)
Close an HDF5 group.
const unsigned int VERSION_MINOR
minor version number of opengm
Definition: config.hxx:49
OpenGM runtime error.
Definition: opengm.hxx:100
void save(const GM &, const std::string &, const std::string &)
save a graphical model to an HDF5 file
hid_t openFile(const std::string &, FileAccessMode=READ_ONLY, HDF5Version=DEFAULT_HDF5_VERSION)
Open an HDF5 file.
hid_t openGroup(const hid_t &, const std::string &)
Open an HDF5 group.