PetaVision  Alpha
PvpLayer.cpp
1 #include "PvpLayer.hpp"
2 #include "arch/mpi/mpi.h"
3 #include "io/FileStream.hpp"
4 #include "io/fileio.hpp"
5 #include "structures/SparseList.hpp"
6 
7 #include <cstring>
8 #include <iostream>
9 
10 namespace PV {
11 
12 PvpLayer::PvpLayer(const char *name, HyPerCol *hc) { initialize(name, hc); }
13 
14 PvpLayer::~PvpLayer() {}
15 
16 Response::Status PvpLayer::allocateDataStructures() { return InputLayer::allocateDataStructures(); }
17 
19  FileStream headerStream(
20  getInputPath().c_str(), std::ios_base::in | std::ios_base::binary, false);
21  struct BufferUtils::ActivityHeader header = BufferUtils::readActivityHeader(headerStream);
22 
23  int pvpFrameCount = header.nBands;
24  if (header.fileType == PVP_ACT_SPARSEVALUES_FILE_TYPE || header.fileType == PVP_ACT_FILE_TYPE) {
25  sparseTable = BufferUtils::buildSparseFileTable(headerStream, pvpFrameCount - 1);
26  }
27  return header.nBands;
28 }
29 
31  // If we're playing through the pvp file like a movie, use
32  // BatchIndexer to get the frame number. Otherwise, just use
33  // the start_frame_index value for this batch.
34  Buffer<float> result;
35  BufferUtils::readActivityFromPvp<float>(
36  getInputPath().c_str(), &result, inputIndex, &sparseTable);
37 
38  return result;
39 }
40 } // end namespace PV
virtual int countInputImages() override
Definition: PvpLayer.cpp:18
virtual Buffer< float > retrieveData(int inputIndex) override
Definition: PvpLayer.cpp:30