Public Member Functions | Private Attributes | List of all members
tensorflow::TFFifoHandler Class Reference

Wrapper which handles communication with a TF script via FIFO pipes. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-15/TensorFlowHandler/TFFifoHandler.h"

Public Member Functions

 TFFifoHandler (fhicl::ParameterSet const &pset)
 Basic constructor, takes path to model pb. More...
 
 ~TFFifoHandler ()
 
std::vector< std::vector< double > > Predict (const std::vector< cvn::PixelMap const * > pixellist) const
 

Private Attributes

std::string fToTF
 
std::string fFromTF
 

Detailed Description

Wrapper which handles communication with a TF script via FIFO pipes.

Definition at line 20 of file TFFifoHandler.h.

Constructor & Destructor Documentation

tensorflow::TFFifoHandler::TFFifoHandler ( fhicl::ParameterSet const &  pset)

Basic constructor, takes path to model pb.

Definition at line 15 of file TFFifoHandler.cxx.

15  :
16  fToTF(pset.get<std::string>("PipeToTF")),
17  fFromTF(pset.get<std::string>("PipeFromTF"))
18  {
19  }
enum BeamMode string
tensorflow::TFFifoHandler::~TFFifoHandler ( )

Definition at line 21 of file TFFifoHandler.cxx.

22  {
23  }

Member Function Documentation

std::vector< std::vector< double > > tensorflow::TFFifoHandler::Predict ( const std::vector< cvn::PixelMap const * >  pixellist) const

Definition at line 25 of file TFFifoHandler.cxx.

References allTimeWatchdog::endl, fFromTF, fToTF, make_syst_table_plots::line, confusionMatrixTree::out, submit_concat_project::parts, makeDatasetsPage::results, split(), and string.

Referenced by cvntf::CVNCosmicTF::produce().

26  {
27 
28  //
29  // loop over pixel maps to send all to TF together
30  //
31 
32  // Open the output pipe
33  std::ofstream totf;
34  totf.open(fToTF, std::ios::out);
35 
36  int nimages = pixellist.size();
37  int nviews = 2;
38 
39  // Print summary info first to pipe
40  totf << nimages << " " << nviews << " "<< pixellist[0]->NPlanePerView() << " " << pixellist[0]->NCell() << std::endl;
41 
42  // Loop over pixel maps and print them to the pipe
43  for(size_t iP = 0; iP < pixellist.size(); ++iP) {
44  // Print this pixel map to pipe
45  pixellist[iP]->ToFile(totf, iP, true);
46  }
47 
48  // Close the pipe
49  totf.close();
50 
51 
52  //
53  // Read results back from all pixel maps
54  //
55 
56  std::vector<std::vector<double>> tfoutput;
57 
58  // Open the pipe
59  std::ifstream fromtf;
60  fromtf.open(fFromTF);
61 
62  // Read results from the file
63  // Each line corresponds to a pixel map
65  while (std::getline(fromtf, line))
66  {
67  //std::cout << "Debug:" << line << std::endl;
68  std::vector<std::string> parts;
69  std::vector<double> results;
70  boost::split(parts, line, boost::is_any_of(" "));
71  for (std::string p : parts) {
72  if (!p.empty())
73  results.push_back( std::stof(p) );
74  }
75  tfoutput.emplace_back(results);
76  }
77 
78  return tfoutput;
79  }
void split(double tt, double *fr)
const char * p
Definition: xmltok.h:285
enum BeamMode string

Member Data Documentation

std::string tensorflow::TFFifoHandler::fFromTF
private

Definition at line 31 of file TFFifoHandler.h.

Referenced by Predict().

std::string tensorflow::TFFifoHandler::fToTF
private

Definition at line 30 of file TFFifoHandler.h.

Referenced by Predict().


The documentation for this class was generated from the following files: