summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2014-04-14 11:18:58 +0800
committerJoe Zhao <ztuowen@gmail.com>2014-04-14 11:18:58 +0800
commitf98b9b720f0f5c511f5cb735f0456f0d5fe3c791 (patch)
treecb9398f27458348c9f1b43fb1a734ded16a5507a
parentcccccbf6cca94a3eaf813b4468453160e91c332b (diff)
downloadtnet-f98b9b720f0f5c511f5cb735f0456f0d5fe3c791.tar.gz
tnet-f98b9b720f0f5c511f5cb735f0456f0d5fe3c791.tar.bz2
tnet-f98b9b720f0f5c511f5cb735f0456f0d5fe3c791.zip
Supporting const rev.
-rw-r--r--src/CuBaseLib/cumatrix.h4
-rw-r--r--src/CuBaseLib/cumatrix.tcc12
-rw-r--r--src/CuTNetLib/cuActivation.obin0 -> 387960 bytes
-rw-r--r--src/CuTNetLib/cuBiasedLinearity.obin0 -> 1141168 bytes
-rw-r--r--src/CuTNetLib/cuBlockArray.obin0 -> 757728 bytes
-rw-r--r--src/CuTNetLib/cuCache.obin0 -> 642984 bytes
-rw-r--r--src/CuTNetLib/cuCompDisc.cc4
-rw-r--r--src/CuTNetLib/cuCompDisc.h20
-rw-r--r--src/CuTNetLib/cuCompDisc.obin0 -> 606616 bytes
-rw-r--r--src/CuTNetLib/cuComponent.h45
-rw-r--r--src/CuTNetLib/cuConcatenate.obin0 -> 757728 bytes
-rw-r--r--src/CuTNetLib/cuDiscreteLinearity.obin0 -> 1323304 bytes
-rw-r--r--src/CuTNetLib/cuLinearity.obin0 -> 709800 bytes
-rw-r--r--src/CuTNetLib/cuMisc.h42
-rw-r--r--src/CuTNetLib/cuNetwork.obin0 -> 1773944 bytes
-rw-r--r--src/CuTNetLib/cuObjectiveFunction.obin0 -> 1160864 bytes
-rw-r--r--src/CuTNetLib/cuRbm.obin0 -> 1301600 bytes
-rw-r--r--src/CuTNetLib/cuRbmSparse.obin0 -> 1457952 bytes
-rw-r--r--src/CuTNetLib/cuRecurrent.obin0 -> 1331448 bytes
-rw-r--r--src/CuTNetLib/cuSharedLinearity.obin0 -> 1093888 bytes
-rw-r--r--src/CuTNetLib/cuSparseLinearity.obin0 -> 1295680 bytes
-rw-r--r--src/CuTNetLib/cuUpdatableBias.obin0 -> 891392 bytes
-rw-r--r--src/CuTNetLib/libCuTNet.abin0 -> 16694972 bytes
23 files changed, 64 insertions, 63 deletions
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<typename _ElemT>
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<typename _ElemT>
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
--- /dev/null
+++ b/src/CuTNetLib/cuActivation.o
Binary files differ
diff --git a/src/CuTNetLib/cuBiasedLinearity.o b/src/CuTNetLib/cuBiasedLinearity.o
new file mode 100644
index 0000000..05d3438
--- /dev/null
+++ b/src/CuTNetLib/cuBiasedLinearity.o
Binary files differ
diff --git a/src/CuTNetLib/cuBlockArray.o b/src/CuTNetLib/cuBlockArray.o
new file mode 100644
index 0000000..14bffe2
--- /dev/null
+++ b/src/CuTNetLib/cuBlockArray.o
Binary files differ
diff --git a/src/CuTNetLib/cuCache.o b/src/CuTNetLib/cuCache.o
new file mode 100644
index 0000000..9e7f457
--- /dev/null
+++ b/src/CuTNetLib/cuCache.o
Binary files 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<BaseFloat>& X, CuMatrix<BaseFloat>& Y)
+ PropagateF(const CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y)
{
int iLoc=0,oLoc=0;
CuMatrix<BaseFloat> In;
@@ -109,7 +109,7 @@ namespace TNet
void
CuCompound::
- BackpropagateF(CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y)
+ BackpropagateF(const CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y)
{
int iLoc=0,oLoc=0;
CuMatrix<BaseFloat> 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<BaseFloat>& GetInput(int pos=0)
+ const CuMatrix<BaseFloat>& GetInput(int pos=0)
{
if (preComp!=NULL)
return preComp->GetOutput(pos);
return *mpInput;
}
- CuMatrix<BaseFloat>& GetOutput(int pos=0)
+ const CuMatrix<BaseFloat>& GetOutput(int pos=0)
{
CuComponent* pComp=FindOutput(pos);
return pComp->GetOutput(pos);
}
- CuMatrix<BaseFloat>& GetErrorInput(int pos=0)
+ const CuMatrix<BaseFloat>& GetErrorInput(int pos=0)
{
if (nxtComp!=NULL)
return nxtComp->GetErrorOutput(pos);
return *mpErrorInput;
}
- CuMatrix<BaseFloat>& GetErrorOutput(int pos=0)
+ const CuMatrix<BaseFloat>& GetErrorOutput(int pos=0)
{
CuComponent* pComp=FindInput(pos);
return pComp->GetErrorOutput(pos);
}
/// Set input vector (bind with the preceding NetworkComponent)
- void SetInput(CuMatrix<BaseFloat>& rInput,int pos=0)
+ void SetInput(const CuMatrix<BaseFloat>& 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<BaseFloat>& rErrorInput,int pos=0)
+ void SetErrorInput(const CuMatrix<BaseFloat>& 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<BaseFloat>& X, CuMatrix<BaseFloat>& Y);
- void BackpropagateF(CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y);
+ void PropagateF(const CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y);
+ void BackpropagateF(const CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y);
protected:
diff --git a/src/CuTNetLib/cuCompDisc.o b/src/CuTNetLib/cuCompDisc.o
new file mode 100644
index 0000000..764f3b1
--- /dev/null
+++ b/src/CuTNetLib/cuCompDisc.o
Binary files 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<BaseFloat>* > MatrixPtrVec;
+ typedef std::vector< const CuMatrix<BaseFloat>* > 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<BaseFloat>& GetInput(int pos=0);
- CuMatrix<BaseFloat>& GetOutput(int pos=0);
- CuMatrix<BaseFloat>& GetErrorInput(int pos=0);
- CuMatrix<BaseFloat>& GetErrorOutput(int pos=0);
+ const CuMatrix<BaseFloat>& GetInput(int pos=0);
+ const CuMatrix<BaseFloat>& GetOutput(int pos=0);
+ const CuMatrix<BaseFloat>& GetErrorInput(int pos=0);
+ const CuMatrix<BaseFloat>& GetErrorOutput(int pos=0);
/// Set input vector (bind with the preceding NetworkComponent)
- void SetInput(CuMatrix<BaseFloat>& rInput,int pos=0);
+ void SetInput(const CuMatrix<BaseFloat>& rInput,int pos=0);
/// Set error input vector (bind with the following NetworkComponent)
- void SetErrorInput(CuMatrix<BaseFloat>& rErrorInput,int pos=0);
+ void SetErrorInput(const CuMatrix<BaseFloat>& 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<BaseFloat>& X, CuMatrix<BaseFloat>& Y);
+ void PropagateF(const CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y);
/// Public wrapper for BackpropagateFnc
- void BackpropagateF(CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y);
+ void BackpropagateF(const CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y);
///////////////////////////////////////////////////////////////
@@ -171,8 +172,8 @@ namespace TNet {
size_t mNInputs; ///< Size of input vectors
size_t mNOutputs; ///< Size of output vectors
- CuMatrix<BaseFloat>* mpInput; ///< inputs are NOT OWNED by component
- CuMatrix<BaseFloat>* mpErrorInput;///< inputs are NOT OWNED by component
+ const CuMatrix<BaseFloat>* mpInput; ///< inputs are NOT OWNED by component
+ const CuMatrix<BaseFloat>* mpErrorInput;///< inputs are NOT OWNED by component
CuMatrix<BaseFloat> mOutput; ///< outputs are OWNED by component
CuMatrix<BaseFloat> mErrorOutput; ///< outputs are OWNED by component
@@ -316,7 +317,7 @@ namespace TNet {
inline void
CuComponent::
- SetInput(CuMatrix<BaseFloat>& rInput,int pos)
+ SetInput(const CuMatrix<BaseFloat>& rInput,int pos)
{
mpInput = &rInput;
}
@@ -324,12 +325,12 @@ namespace TNet {
inline void
CuComponent::
- SetErrorInput(CuMatrix<BaseFloat>& rErrorInput,int pos)
+ SetErrorInput(const CuMatrix<BaseFloat>& rErrorInput,int pos)
{
mpErrorInput = &rErrorInput;
}
- inline CuMatrix<BaseFloat>&
+ inline const CuMatrix<BaseFloat>&
CuComponent::
GetInput(int pos)
{
@@ -337,14 +338,14 @@ namespace TNet {
return *mpInput;
}
- inline CuMatrix<BaseFloat>&
+ inline const CuMatrix<BaseFloat>&
CuComponent::
GetOutput(int pos)
{
return mOutput;
}
- inline CuMatrix<BaseFloat>&
+ inline const CuMatrix<BaseFloat>&
CuComponent::
GetErrorInput(int pos)
{
@@ -352,7 +353,7 @@ namespace TNet {
return *mpErrorInput;
}
- inline CuMatrix<BaseFloat>&
+ inline const CuMatrix<BaseFloat>&
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<BaseFloat>& X, CuMatrix<BaseFloat>& Y)
+ PropagateF(const CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y)
{
PropagateFnc(X,Y);
}
inline void
CuComponent::
- BackpropagateF(CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y)
+ BackpropagateF(const CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y)
{
BackpropagateFnc(X,Y);
}
diff --git a/src/CuTNetLib/cuConcatenate.o b/src/CuTNetLib/cuConcatenate.o
new file mode 100644
index 0000000..6dfd15d
--- /dev/null
+++ b/src/CuTNetLib/cuConcatenate.o
Binary files differ
diff --git a/src/CuTNetLib/cuDiscreteLinearity.o b/src/CuTNetLib/cuDiscreteLinearity.o
new file mode 100644
index 0000000..a7eeb56
--- /dev/null
+++ b/src/CuTNetLib/cuDiscreteLinearity.o
Binary files differ
diff --git a/src/CuTNetLib/cuLinearity.o b/src/CuTNetLib/cuLinearity.o
new file mode 100644
index 0000000..31c9974
--- /dev/null
+++ b/src/CuTNetLib/cuLinearity.o
Binary files 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<BaseFloat>& GetErrorInput(int pos=0)
+ const CuMatrix<BaseFloat>& GetErrorInput(int pos=0)
{
if (pos>=0 && pos<size)
return *ErrInputVec[pos];
return *ErrInputVec[0];
}
- void SetErrorInput(CuMatrix<BaseFloat>& rErrorInput,int pos=0)
+ void SetErrorInput(const CuMatrix<BaseFloat>& rErrorInput,int pos=0)
{
if (pos==0)
mpErrorInput=&rErrorInput;
@@ -181,7 +181,7 @@ namespace TNet {
}
int size;
- MatrixPtrVec ErrInputVec;
+ ConstMatrixPtrVec ErrInputVec;
Vector<BaseFloat> Scale;
};
@@ -227,13 +227,13 @@ namespace TNet {
mErrorOutput.Init(*mpErrorInput);
}
- int GetInSect()
+ int GetInSect() const
{
return size;
}
/// IO Data getters
- CuMatrix<BaseFloat>& GetInput(int pos=0)
+ const CuMatrix<BaseFloat>& GetInput(int pos=0)
{
if (pos>=0 && pos<size)
return *InputVec[pos];
@@ -241,7 +241,7 @@ namespace TNet {
}
/// Set input vector (bind with the preceding NetworkComponent)
- void SetInput(CuMatrix<BaseFloat>& rInput,int pos=0)
+ void SetInput(const CuMatrix<BaseFloat>& 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 "<divide>"; }
- int GetOutSect()
+ int GetOutSect() const
{
return size;
}
@@ -345,7 +345,7 @@ namespace TNet {
int size;
MatrixPtrVec OutputVec;
- MatrixPtrVec ErrorInputVec;
+ ConstMatrixPtrVec ErrorInputVec;
std::vector<int> SectLen;
};
@@ -372,7 +372,7 @@ namespace TNet {
const char* GetName() const
{ return "<merge>"; }
- int GetInSect()
+ int GetInSect() const
{
return size;
}
@@ -428,7 +428,7 @@ namespace TNet {
int size;
- MatrixPtrVec InputVec;
+ ConstMatrixPtrVec InputVec;
MatrixPtrVec ErrorOutputVec;
std::vector<int> SectLen;
@@ -456,12 +456,12 @@ namespace TNet {
const char* GetName() const
{ return "<reorder>"; }
- int GetInSect()
+ int GetInSect() const
{
return size;
}
- int GetOutSect()
+ int GetOutSect() const
{
return size;
}
@@ -505,30 +505,30 @@ namespace TNet {
}
/// IO Data getters
- CuMatrix<BaseFloat>& GetInput(int pos=0)
+ const CuMatrix<BaseFloat>& GetInput(int pos=0)
{
return PipeVec[pos]->GetInput();
}
- CuMatrix<BaseFloat>& GetOutput(int pos=0)
+ const CuMatrix<BaseFloat>& GetOutput(int pos=0)
{
return PipeVec[Order[pos]]->GetOutput();
}
- CuMatrix<BaseFloat>& GetErrorInput(int pos=0)
- {
+ const CuMatrix<BaseFloat>& GetErrorInput(int pos=0)
+ {
return PipeVec[Order[pos]]->GetErrorInput();
}
- CuMatrix<BaseFloat>& GetErrorOutput(int pos=0)
+ const CuMatrix<BaseFloat>& GetErrorOutput(int pos=0)
{
return PipeVec[pos]->GetErrorOutput();
}
/// Set input vector (bind with the preceding NetworkComponent)
- void SetInput(CuMatrix<BaseFloat>& rInput,int pos=0)
+ void SetInput(const CuMatrix<BaseFloat>& rInput,int pos=0)
{
PipeVec[pos]->SetInput(rInput);
}
/// Set error input vector (bind with the following NetworkComponent)
- void SetErrorInput(CuMatrix<BaseFloat>& rErrorInput,int pos=0)
+ void SetErrorInput(const CuMatrix<BaseFloat>& 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
--- /dev/null
+++ b/src/CuTNetLib/cuNetwork.o
Binary files differ
diff --git a/src/CuTNetLib/cuObjectiveFunction.o b/src/CuTNetLib/cuObjectiveFunction.o
new file mode 100644
index 0000000..00eaacd
--- /dev/null
+++ b/src/CuTNetLib/cuObjectiveFunction.o
Binary files differ
diff --git a/src/CuTNetLib/cuRbm.o b/src/CuTNetLib/cuRbm.o
new file mode 100644
index 0000000..5f84017
--- /dev/null
+++ b/src/CuTNetLib/cuRbm.o
Binary files differ
diff --git a/src/CuTNetLib/cuRbmSparse.o b/src/CuTNetLib/cuRbmSparse.o
new file mode 100644
index 0000000..b56c669
--- /dev/null
+++ b/src/CuTNetLib/cuRbmSparse.o
Binary files differ
diff --git a/src/CuTNetLib/cuRecurrent.o b/src/CuTNetLib/cuRecurrent.o
new file mode 100644
index 0000000..73969fe
--- /dev/null
+++ b/src/CuTNetLib/cuRecurrent.o
Binary files differ
diff --git a/src/CuTNetLib/cuSharedLinearity.o b/src/CuTNetLib/cuSharedLinearity.o
new file mode 100644
index 0000000..175c607
--- /dev/null
+++ b/src/CuTNetLib/cuSharedLinearity.o
Binary files differ
diff --git a/src/CuTNetLib/cuSparseLinearity.o b/src/CuTNetLib/cuSparseLinearity.o
new file mode 100644
index 0000000..24547a2
--- /dev/null
+++ b/src/CuTNetLib/cuSparseLinearity.o
Binary files differ
diff --git a/src/CuTNetLib/cuUpdatableBias.o b/src/CuTNetLib/cuUpdatableBias.o
new file mode 100644
index 0000000..288189d
--- /dev/null
+++ b/src/CuTNetLib/cuUpdatableBias.o
Binary files differ
diff --git a/src/CuTNetLib/libCuTNet.a b/src/CuTNetLib/libCuTNet.a
new file mode 100644
index 0000000..163a1d8
--- /dev/null
+++ b/src/CuTNetLib/libCuTNet.a
Binary files differ