From f98b9b720f0f5c511f5cb735f0456f0d5fe3c791 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Mon, 14 Apr 2014 11:18:58 +0800 Subject: Supporting const rev. --- src/CuBaseLib/cumatrix.h | 4 ++-- src/CuBaseLib/cumatrix.tcc | 12 +++++----- src/CuTNetLib/cuActivation.o | Bin 0 -> 387960 bytes src/CuTNetLib/cuBiasedLinearity.o | Bin 0 -> 1141168 bytes src/CuTNetLib/cuBlockArray.o | Bin 0 -> 757728 bytes src/CuTNetLib/cuCache.o | Bin 0 -> 642984 bytes src/CuTNetLib/cuCompDisc.cc | 4 ++-- src/CuTNetLib/cuCompDisc.h | 20 ++++++++-------- src/CuTNetLib/cuCompDisc.o | Bin 0 -> 606616 bytes src/CuTNetLib/cuComponent.h | 45 ++++++++++++++++++------------------ src/CuTNetLib/cuConcatenate.o | Bin 0 -> 757728 bytes src/CuTNetLib/cuDiscreteLinearity.o | Bin 0 -> 1323304 bytes src/CuTNetLib/cuLinearity.o | Bin 0 -> 709800 bytes src/CuTNetLib/cuMisc.h | 42 ++++++++++++++++----------------- src/CuTNetLib/cuNetwork.o | Bin 0 -> 1773944 bytes src/CuTNetLib/cuObjectiveFunction.o | Bin 0 -> 1160864 bytes src/CuTNetLib/cuRbm.o | Bin 0 -> 1301600 bytes src/CuTNetLib/cuRbmSparse.o | Bin 0 -> 1457952 bytes src/CuTNetLib/cuRecurrent.o | Bin 0 -> 1331448 bytes src/CuTNetLib/cuSharedLinearity.o | Bin 0 -> 1093888 bytes src/CuTNetLib/cuSparseLinearity.o | Bin 0 -> 1295680 bytes src/CuTNetLib/cuUpdatableBias.o | Bin 0 -> 891392 bytes src/CuTNetLib/libCuTNet.a | Bin 0 -> 16694972 bytes 23 files changed, 64 insertions(+), 63 deletions(-) create mode 100644 src/CuTNetLib/cuActivation.o create mode 100644 src/CuTNetLib/cuBiasedLinearity.o create mode 100644 src/CuTNetLib/cuBlockArray.o create mode 100644 src/CuTNetLib/cuCache.o create mode 100644 src/CuTNetLib/cuCompDisc.o create mode 100644 src/CuTNetLib/cuConcatenate.o create mode 100644 src/CuTNetLib/cuDiscreteLinearity.o create mode 100644 src/CuTNetLib/cuLinearity.o create mode 100644 src/CuTNetLib/cuNetwork.o create mode 100644 src/CuTNetLib/cuObjectiveFunction.o create mode 100644 src/CuTNetLib/cuRbm.o create mode 100644 src/CuTNetLib/cuRbmSparse.o create mode 100644 src/CuTNetLib/cuRecurrent.o create mode 100644 src/CuTNetLib/cuSharedLinearity.o create mode 100644 src/CuTNetLib/cuSparseLinearity.o create mode 100644 src/CuTNetLib/cuUpdatableBias.o create mode 100644 src/CuTNetLib/libCuTNet.a diff --git a/src/CuBaseLib/cumatrix.h b/src/CuBaseLib/cumatrix.h index 887b92d..dd76bb2 100644 --- a/src/CuBaseLib/cumatrix.h +++ b/src/CuBaseLib/cumatrix.h @@ -76,9 +76,9 @@ namespace TNet { /// Allocate the memory ThisType& Init(size_t rows, size_t cols); /// Copy the ptr of rSrc starting at x with span of cols - ThisType& Init(CuMatrix<_ElemT>& rSrc, size_t x, size_t cols); + ThisType& Init(const CuMatrix<_ElemT>& rSrc, size_t x, size_t cols); /// Copy the settings of rSrc - ThisType& Init(CuMatrix<_ElemT>& rSrc); + ThisType& Init(const CuMatrix<_ElemT>& rSrc); /// Deallocate the memory void Destroy(); diff --git a/src/CuBaseLib/cumatrix.tcc b/src/CuBaseLib/cumatrix.tcc index 7d6a136..66e335d 100644 --- a/src/CuBaseLib/cumatrix.tcc +++ b/src/CuBaseLib/cumatrix.tcc @@ -41,13 +41,13 @@ namespace TNet { template CuMatrix<_ElemT>& CuMatrix<_ElemT>:: - Init(CuMatrix<_ElemT>& rSrc, size_t x, size_t cols) + Init(const CuMatrix<_ElemT>& rSrc, size_t x, size_t cols) { mRows = rSrc.Rows(); mCols = cols; mStride = rSrc.Stride(); - mpCUData = rSrc.pCUData() + x; - isOwn=false; + mpCUData = const_cast<_ElemT*>(rSrc.pCUData()) + x; + isOwn = false; return *this; } @@ -57,13 +57,13 @@ namespace TNet { template CuMatrix<_ElemT>& CuMatrix<_ElemT>:: - Init(CuMatrix<_ElemT>& rSrc) + Init(const CuMatrix<_ElemT>& rSrc) { mRows = rSrc.Rows(); mCols = rSrc.Cols(); mStride = rSrc.Stride(); - mpCUData = rSrc.pCUData(); - isOwn=false; + mpCUData = const_cast<_ElemT*>(rSrc.pCUData()); + isOwn = false; return *this; } diff --git a/src/CuTNetLib/cuActivation.o b/src/CuTNetLib/cuActivation.o new file mode 100644 index 0000000..3e78f77 Binary files /dev/null and b/src/CuTNetLib/cuActivation.o differ diff --git a/src/CuTNetLib/cuBiasedLinearity.o b/src/CuTNetLib/cuBiasedLinearity.o new file mode 100644 index 0000000..05d3438 Binary files /dev/null and b/src/CuTNetLib/cuBiasedLinearity.o differ diff --git a/src/CuTNetLib/cuBlockArray.o b/src/CuTNetLib/cuBlockArray.o new file mode 100644 index 0000000..14bffe2 Binary files /dev/null and b/src/CuTNetLib/cuBlockArray.o differ diff --git a/src/CuTNetLib/cuCache.o b/src/CuTNetLib/cuCache.o new file mode 100644 index 0000000..9e7f457 Binary files /dev/null and b/src/CuTNetLib/cuCache.o differ diff --git a/src/CuTNetLib/cuCompDisc.cc b/src/CuTNetLib/cuCompDisc.cc index 2336a86..4c31f58 100644 --- a/src/CuTNetLib/cuCompDisc.cc +++ b/src/CuTNetLib/cuCompDisc.cc @@ -92,7 +92,7 @@ namespace TNet void CuCompound:: - PropagateF(CuMatrix& X, CuMatrix& Y) + PropagateF(const CuMatrix& X, CuMatrix& Y) { int iLoc=0,oLoc=0; CuMatrix In; @@ -109,7 +109,7 @@ namespace TNet void CuCompound:: - BackpropagateF(CuMatrix& X, CuMatrix& Y) + BackpropagateF(const CuMatrix& X, CuMatrix& Y) { int iLoc=0,oLoc=0; CuMatrix In; diff --git a/src/CuTNetLib/cuCompDisc.h b/src/CuTNetLib/cuCompDisc.h index 5b3232e..937b785 100644 --- a/src/CuTNetLib/cuCompDisc.h +++ b/src/CuTNetLib/cuCompDisc.h @@ -110,12 +110,12 @@ namespace TNet { void ReadFromStream(std::istream& rIn); void WriteToStream(std::ostream& rOut); - int GetInSect() + int GetInSect() const { return inID.size(); } - int GetOutSect() + int GetOutSect() const { return outID.size(); } @@ -139,31 +139,31 @@ namespace TNet { } /// IO Data getters - CuMatrix& GetInput(int pos=0) + const CuMatrix& GetInput(int pos=0) { if (preComp!=NULL) return preComp->GetOutput(pos); return *mpInput; } - CuMatrix& GetOutput(int pos=0) + const CuMatrix& GetOutput(int pos=0) { CuComponent* pComp=FindOutput(pos); return pComp->GetOutput(pos); } - CuMatrix& GetErrorInput(int pos=0) + const CuMatrix& GetErrorInput(int pos=0) { if (nxtComp!=NULL) return nxtComp->GetErrorOutput(pos); return *mpErrorInput; } - CuMatrix& GetErrorOutput(int pos=0) + const CuMatrix& GetErrorOutput(int pos=0) { CuComponent* pComp=FindInput(pos); return pComp->GetErrorOutput(pos); } /// Set input vector (bind with the preceding NetworkComponent) - void SetInput(CuMatrix& rInput,int pos=0) + void SetInput(const CuMatrix& rInput,int pos=0) { if (pos==0) mpInput=&rInput; @@ -171,7 +171,7 @@ namespace TNet { pComp->SetInput(rInput,pos); } /// Set error input vector (bind with the following NetworkComponent) - void SetErrorInput(CuMatrix& rErrorInput,int pos=0) + void SetErrorInput(const CuMatrix& rErrorInput,int pos=0) { if (pos==0) mpErrorInput=&rErrorInput; @@ -238,8 +238,8 @@ namespace TNet { void ReadFromStream(std::istream& rIn); void WriteToStream(std::ostream& rOut); - void PropagateF(CuMatrix& X, CuMatrix& Y); - void BackpropagateF(CuMatrix& X, CuMatrix& Y); + void PropagateF(const CuMatrix& X, CuMatrix& Y); + void BackpropagateF(const CuMatrix& X, CuMatrix& Y); protected: diff --git a/src/CuTNetLib/cuCompDisc.o b/src/CuTNetLib/cuCompDisc.o new file mode 100644 index 0000000..764f3b1 Binary files /dev/null and b/src/CuTNetLib/cuCompDisc.o differ diff --git a/src/CuTNetLib/cuComponent.h b/src/CuTNetLib/cuComponent.h index 6cc8462..fc9666c 100644 --- a/src/CuTNetLib/cuComponent.h +++ b/src/CuTNetLib/cuComponent.h @@ -85,6 +85,7 @@ namespace TNet { } ComponentType; typedef std::vector< CuMatrix* > MatrixPtrVec; + typedef std::vector< const CuMatrix* > ConstMatrixPtrVec; ////////////////////////////////////////////////////////////// // Constructor & Destructor @@ -118,20 +119,20 @@ namespace TNet { void SetNext(CuComponent* pNxt); /// Return the number of different inputs for complex component - int GetInSect(); + int GetInSect() const; /// Return the number of different outputs for complex component - int GetOutSect(); + int GetOutSect() const; /// IO Data getters - CuMatrix& GetInput(int pos=0); - CuMatrix& GetOutput(int pos=0); - CuMatrix& GetErrorInput(int pos=0); - CuMatrix& GetErrorOutput(int pos=0); + const CuMatrix& GetInput(int pos=0); + const CuMatrix& GetOutput(int pos=0); + const CuMatrix& GetErrorInput(int pos=0); + const CuMatrix& GetErrorOutput(int pos=0); /// Set input vector (bind with the preceding NetworkComponent) - void SetInput(CuMatrix& rInput,int pos=0); + void SetInput(const CuMatrix& rInput,int pos=0); /// Set error input vector (bind with the following NetworkComponent) - void SetErrorInput(CuMatrix& rErrorInput,int pos=0); + void SetErrorInput(const CuMatrix& rErrorInput,int pos=0); /// Perform forward pass propagateion Input->Output, /// wrapper for the PropagateFnc method @@ -146,9 +147,9 @@ namespace TNet { virtual void WriteToStream(std::ostream& rOut) { } /// Public wrapper for PropagateFnc - void PropagateF(CuMatrix& X, CuMatrix& Y); + void PropagateF(const CuMatrix& X, CuMatrix& Y); /// Public wrapper for BackpropagateFnc - void BackpropagateF(CuMatrix& X, CuMatrix& Y); + void BackpropagateF(const CuMatrix& X, CuMatrix& Y); /////////////////////////////////////////////////////////////// @@ -171,8 +172,8 @@ namespace TNet { size_t mNInputs; ///< Size of input vectors size_t mNOutputs; ///< Size of output vectors - CuMatrix* mpInput; ///< inputs are NOT OWNED by component - CuMatrix* mpErrorInput;///< inputs are NOT OWNED by component + const CuMatrix* mpInput; ///< inputs are NOT OWNED by component + const CuMatrix* mpErrorInput;///< inputs are NOT OWNED by component CuMatrix mOutput; ///< outputs are OWNED by component CuMatrix mErrorOutput; ///< outputs are OWNED by component @@ -316,7 +317,7 @@ namespace TNet { inline void CuComponent:: - SetInput(CuMatrix& rInput,int pos) + SetInput(const CuMatrix& rInput,int pos) { mpInput = &rInput; } @@ -324,12 +325,12 @@ namespace TNet { inline void CuComponent:: - SetErrorInput(CuMatrix& rErrorInput,int pos) + SetErrorInput(const CuMatrix& rErrorInput,int pos) { mpErrorInput = &rErrorInput; } - inline CuMatrix& + inline const CuMatrix& CuComponent:: GetInput(int pos) { @@ -337,14 +338,14 @@ namespace TNet { return *mpInput; } - inline CuMatrix& + inline const CuMatrix& CuComponent:: GetOutput(int pos) { return mOutput; } - inline CuMatrix& + inline const CuMatrix& CuComponent:: GetErrorInput(int pos) { @@ -352,7 +353,7 @@ namespace TNet { return *mpErrorInput; } - inline CuMatrix& + inline const CuMatrix& CuComponent:: GetErrorOutput(int pos) { @@ -375,14 +376,14 @@ namespace TNet { inline int CuComponent:: - GetInSect() + GetInSect() const { return 1; } inline int CuComponent:: - GetOutSect() + GetOutSect() const { return 1; } @@ -403,13 +404,13 @@ namespace TNet { inline void CuComponent:: - PropagateF(CuMatrix& X, CuMatrix& Y) + PropagateF(const CuMatrix& X, CuMatrix& Y) { PropagateFnc(X,Y); } inline void CuComponent:: - BackpropagateF(CuMatrix& X, CuMatrix& Y) + BackpropagateF(const CuMatrix& X, CuMatrix& Y) { BackpropagateFnc(X,Y); } diff --git a/src/CuTNetLib/cuConcatenate.o b/src/CuTNetLib/cuConcatenate.o new file mode 100644 index 0000000..6dfd15d Binary files /dev/null and b/src/CuTNetLib/cuConcatenate.o differ diff --git a/src/CuTNetLib/cuDiscreteLinearity.o b/src/CuTNetLib/cuDiscreteLinearity.o new file mode 100644 index 0000000..a7eeb56 Binary files /dev/null and b/src/CuTNetLib/cuDiscreteLinearity.o differ diff --git a/src/CuTNetLib/cuLinearity.o b/src/CuTNetLib/cuLinearity.o new file mode 100644 index 0000000..31c9974 Binary files /dev/null and b/src/CuTNetLib/cuLinearity.o differ diff --git a/src/CuTNetLib/cuMisc.h b/src/CuTNetLib/cuMisc.h index 7319adf..b93a983 100644 --- a/src/CuTNetLib/cuMisc.h +++ b/src/CuTNetLib/cuMisc.h @@ -148,19 +148,19 @@ namespace TNet { mOutput.Init(*mpInput); } - int GetOutSect() + int GetOutSect() const { return size; } - CuMatrix& GetErrorInput(int pos=0) + const CuMatrix& GetErrorInput(int pos=0) { if (pos>=0 && pos& rErrorInput,int pos=0) + void SetErrorInput(const CuMatrix& rErrorInput,int pos=0) { if (pos==0) mpErrorInput=&rErrorInput; @@ -181,7 +181,7 @@ namespace TNet { } int size; - MatrixPtrVec ErrInputVec; + ConstMatrixPtrVec ErrInputVec; Vector Scale; }; @@ -227,13 +227,13 @@ namespace TNet { mErrorOutput.Init(*mpErrorInput); } - int GetInSect() + int GetInSect() const { return size; } /// IO Data getters - CuMatrix& GetInput(int pos=0) + const CuMatrix& GetInput(int pos=0) { if (pos>=0 && pos& rInput,int pos=0) + void SetInput(const CuMatrix& rInput,int pos=0) { if (pos==0) mpInput=&rInput; @@ -264,7 +264,7 @@ namespace TNet { } int size; - MatrixPtrVec InputVec; + ConstMatrixPtrVec InputVec; }; /** @@ -289,7 +289,7 @@ namespace TNet { const char* GetName() const { return ""; } - int GetOutSect() + int GetOutSect() const { return size; } @@ -345,7 +345,7 @@ namespace TNet { int size; MatrixPtrVec OutputVec; - MatrixPtrVec ErrorInputVec; + ConstMatrixPtrVec ErrorInputVec; std::vector SectLen; }; @@ -372,7 +372,7 @@ namespace TNet { const char* GetName() const { return ""; } - int GetInSect() + int GetInSect() const { return size; } @@ -428,7 +428,7 @@ namespace TNet { int size; - MatrixPtrVec InputVec; + ConstMatrixPtrVec InputVec; MatrixPtrVec ErrorOutputVec; std::vector SectLen; @@ -456,12 +456,12 @@ namespace TNet { const char* GetName() const { return ""; } - int GetInSect() + int GetInSect() const { return size; } - int GetOutSect() + int GetOutSect() const { return size; } @@ -505,30 +505,30 @@ namespace TNet { } /// IO Data getters - CuMatrix& GetInput(int pos=0) + const CuMatrix& GetInput(int pos=0) { return PipeVec[pos]->GetInput(); } - CuMatrix& GetOutput(int pos=0) + const CuMatrix& GetOutput(int pos=0) { return PipeVec[Order[pos]]->GetOutput(); } - CuMatrix& GetErrorInput(int pos=0) - { + const CuMatrix& GetErrorInput(int pos=0) + { return PipeVec[Order[pos]]->GetErrorInput(); } - CuMatrix& GetErrorOutput(int pos=0) + const CuMatrix& GetErrorOutput(int pos=0) { return PipeVec[pos]->GetErrorOutput(); } /// Set input vector (bind with the preceding NetworkComponent) - void SetInput(CuMatrix& rInput,int pos=0) + void SetInput(const CuMatrix& rInput,int pos=0) { PipeVec[pos]->SetInput(rInput); } /// Set error input vector (bind with the following NetworkComponent) - void SetErrorInput(CuMatrix& rErrorInput,int pos=0) + void SetErrorInput(const CuMatrix& rErrorInput,int pos=0) { PipeVec[Order[pos]]->SetErrorInput(rErrorInput); } diff --git a/src/CuTNetLib/cuNetwork.o b/src/CuTNetLib/cuNetwork.o new file mode 100644 index 0000000..7f3568f Binary files /dev/null and b/src/CuTNetLib/cuNetwork.o differ diff --git a/src/CuTNetLib/cuObjectiveFunction.o b/src/CuTNetLib/cuObjectiveFunction.o new file mode 100644 index 0000000..00eaacd Binary files /dev/null and b/src/CuTNetLib/cuObjectiveFunction.o differ diff --git a/src/CuTNetLib/cuRbm.o b/src/CuTNetLib/cuRbm.o new file mode 100644 index 0000000..5f84017 Binary files /dev/null and b/src/CuTNetLib/cuRbm.o differ diff --git a/src/CuTNetLib/cuRbmSparse.o b/src/CuTNetLib/cuRbmSparse.o new file mode 100644 index 0000000..b56c669 Binary files /dev/null and b/src/CuTNetLib/cuRbmSparse.o differ diff --git a/src/CuTNetLib/cuRecurrent.o b/src/CuTNetLib/cuRecurrent.o new file mode 100644 index 0000000..73969fe Binary files /dev/null and b/src/CuTNetLib/cuRecurrent.o differ diff --git a/src/CuTNetLib/cuSharedLinearity.o b/src/CuTNetLib/cuSharedLinearity.o new file mode 100644 index 0000000..175c607 Binary files /dev/null and b/src/CuTNetLib/cuSharedLinearity.o differ diff --git a/src/CuTNetLib/cuSparseLinearity.o b/src/CuTNetLib/cuSparseLinearity.o new file mode 100644 index 0000000..24547a2 Binary files /dev/null and b/src/CuTNetLib/cuSparseLinearity.o differ diff --git a/src/CuTNetLib/cuUpdatableBias.o b/src/CuTNetLib/cuUpdatableBias.o new file mode 100644 index 0000000..288189d Binary files /dev/null and b/src/CuTNetLib/cuUpdatableBias.o differ diff --git a/src/CuTNetLib/libCuTNet.a b/src/CuTNetLib/libCuTNet.a new file mode 100644 index 0000000..163a1d8 Binary files /dev/null and b/src/CuTNetLib/libCuTNet.a differ -- cgit v1.2.3-70-g09d2