PetaVision  Alpha
WeightsPair.hpp
1 /*
2  * WeightsPair.hpp
3  *
4  * Created on: Nov 17, 2017
5  * Author: Pete Schultz
6  */
7 
8 #ifndef WEIGHTSPAIR_HPP_
9 #define WEIGHTSPAIR_HPP_
10 
11 #include "components/ArborList.hpp"
12 #include "components/SharedWeights.hpp"
13 #include "components/WeightsPairInterface.hpp"
14 
15 namespace PV {
16 
18  protected:
25  virtual void ioParam_writeStep(enum ParamsIOFlag ioFlag);
26  virtual void ioParam_initialWriteTime(enum ParamsIOFlag ioFlag);
27  virtual void ioParam_writeCompressedWeights(enum ParamsIOFlag ioFlag);
28  virtual void ioParam_writeCompressedCheckpoints(enum ParamsIOFlag ioFlag);
29 
35  virtual void ioParam_initializeFromCheckpointFlag(enum ParamsIOFlag ioFlag);
36  // end of WeightsPair parameters
38 
39  public:
40  WeightsPair(char const *name, HyPerCol *hc);
41 
42  virtual ~WeightsPair();
43 
44  virtual Response::Status respond(std::shared_ptr<BaseMessage const> message) override;
45 
46  Weights *getPreWeights() { return mPreWeights; }
47  Weights *getPostWeights() { return mPostWeights; }
48 
49  bool getInitializeFromCheckpointFlag() const { return mInitializeFromCheckpointFlag; }
50 
51  bool getWriteCompressedCheckpoints() const { return mWriteCompressedCheckpoints; }
52 
53  ArborList const *getArborList() const { return mArborList; }
54 
55  protected:
56  WeightsPair() {}
57 
58  int initialize(char const *name, HyPerCol *hc);
59 
60  virtual void setObjectType() override;
61 
62  int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override;
63 
64  Response::Status
65  respondConnectionFinalizeUpdate(std::shared_ptr<ConnectionFinalizeUpdateMessage const> message);
66 
67  Response::Status respondConnectionOutput(std::shared_ptr<ConnectionOutputMessage const> message);
68 
69  virtual Response::Status
70  communicateInitInfo(std::shared_ptr<CommunicateInitInfoMessage const> message) override;
71 
72  virtual void createPreWeights(std::string const &weightsName) override;
73  virtual void createPostWeights(std::string const &weightsName) override;
74 
75  virtual void allocatePreWeights() override;
76 
77  virtual void allocatePostWeights() override;
78 
79  virtual Response::Status registerData(Checkpointer *checkpointer) override;
80 
81  virtual Response::Status readStateFromCheckpoint(Checkpointer *checkpointer) override;
82 
83  virtual void finalizeUpdate(double timestamp, double deltaTime);
84 
85  void openOutputStateFile(Checkpointer *checkpointer);
86 
87  virtual void outputState(double timestamp);
88 
89  protected:
90  double mWriteStep = 0.0;
91  double mInitialWriteTime = 0.0;
92  bool mWriteCompressedWeights = false;
93  bool mWriteCompressedCheckpoints = false;
94 
95  // If this flag is set and HyPerCol sets initializeFromCheckpointDir, load initial state from
96  // the initializeFromCheckpointDir directory.
97  bool mInitializeFromCheckpointFlag = false;
98 
99  ArborList *mArborList = nullptr;
100  SharedWeights *mSharedWeights = nullptr;
101  double mWriteTime = 0.0;
102 
103  CheckpointableFileStream *mOutputStateStream = nullptr; // weights file written by outputState
104 };
105 
106 } // namespace PV
107 
108 #endif // WEIGHTSPAIR_HPP_
int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
Definition: WeightsPair.cpp:27
virtual void ioParam_initializeFromCheckpointFlag(enum ParamsIOFlag ioFlag)
initializeFromCheckpointFlag: If set to true, initialize using checkpoint direcgtory set in HyPerCol...
virtual void createPreWeights(std::string const &weightsName) override
virtual void createPostWeights(std::string const &weightsName) override