Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new compiler flag for storage order #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/Activation/Identity.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace MiniDNN
class Identity
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;

public:
// a = activation(z) = z
Expand Down
1 change: 0 additions & 1 deletion include/Activation/Mish.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace MiniDNN
class Mish
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;

public:
// Mish(x) = x * tanh(softplus(x))
Expand Down
1 change: 0 additions & 1 deletion include/Activation/ReLU.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace MiniDNN
class ReLU
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;

public:
// a = activation(z) = max(z, 0)
Expand Down
1 change: 0 additions & 1 deletion include/Activation/Sigmoid.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace MiniDNN
class Sigmoid
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;

public:
// a = activation(z) = 1 / (1 + exp(-z))
Expand Down
1 change: 0 additions & 1 deletion include/Activation/Softmax.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace MiniDNN
class Softmax
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
typedef Eigen::Array<Scalar, 1, Eigen::Dynamic> RowArray;

public:
Expand Down
1 change: 0 additions & 1 deletion include/Activation/Tanh.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace MiniDNN
class Tanh
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;

public:
// a = activation(z) = tanh(z)
Expand Down
1 change: 0 additions & 1 deletion include/Callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class Network;
class Callback
{
protected:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
typedef Eigen::RowVectorXi IntegerVector;

public:
Expand Down
9 changes: 8 additions & 1 deletion include/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@
namespace MiniDNN
{


// Floating-point number type
#ifndef MDNN_SCALAR
typedef double Scalar;
#else
typedef MDNN_SCALAR Scalar;
#endif

#if(MDNN_ROWMAJOR == 1)
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> Matrix;
#else
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
#endif

typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;


} // namespace MiniDNN

Expand Down
2 changes: 0 additions & 2 deletions include/Layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ namespace MiniDNN
class Layer
{
protected:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
typedef std::map<std::string, int> MetaInfo;

const int m_in_size; // Size of input units
Expand Down
2 changes: 0 additions & 2 deletions include/Layer/Convolutional.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ template <typename Activation>
class Convolutional: public Layer
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
typedef Matrix::ConstAlignedMapType ConstAlignedMapMat;
typedef Vector::ConstAlignedMapType ConstAlignedMapVec;
typedef Vector::AlignedMapType AlignedMapVec;
Expand Down
2 changes: 0 additions & 2 deletions include/Layer/FullyConnected.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ template <typename Activation>
class FullyConnected: public Layer
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
typedef Vector::ConstAlignedMapType ConstAlignedMapVec;
typedef Vector::AlignedMapType AlignedMapVec;
typedef std::map<std::string, int> MetaInfo;
Expand Down
1 change: 0 additions & 1 deletion include/Layer/MaxPooling.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ template <typename Activation>
class MaxPooling: public Layer
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
typedef Eigen::MatrixXi IntMatrix;
typedef std::map<std::string, int> MetaInfo;

Expand Down
10 changes: 9 additions & 1 deletion include/Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace MiniDNN
class Network
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
typedef Eigen::RowVectorXi IntegerVector;
typedef std::map<std::string, int> MetaInfo;

Expand Down Expand Up @@ -437,10 +436,19 @@ class Network
// We want to force XType and YType to be column-majored
typedef typename Eigen::MatrixBase<DerivedX>::PlainObject PlainObjectX;
typedef typename Eigen::MatrixBase<DerivedY>::PlainObject PlainObjectY;

#if (MDNN_ROWMAJOR == 1 )
typedef Eigen::Matrix<typename PlainObjectX::Scalar, PlainObjectX::RowsAtCompileTime, PlainObjectX::ColsAtCompileTime, Eigen::RowMajor>
XType;
typedef Eigen::Matrix<typename PlainObjectY::Scalar, PlainObjectY::RowsAtCompileTime, PlainObjectY::ColsAtCompileTime, Eigen::RowMajor>
YType;
#else
typedef Eigen::Matrix<typename PlainObjectX::Scalar, PlainObjectX::RowsAtCompileTime, PlainObjectX::ColsAtCompileTime>
XType;
typedef Eigen::Matrix<typename PlainObjectY::Scalar, PlainObjectY::RowsAtCompileTime, PlainObjectY::ColsAtCompileTime>
YType;
#endif

const int nlayer = num_layers();

if (nlayer <= 0)
Expand Down
1 change: 0 additions & 1 deletion include/Optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace MiniDNN
class Optimizer
{
protected:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
typedef Vector::ConstAlignedMapType ConstAlignedMapVec;
typedef Vector::AlignedMapType AlignedMapVec;

Expand Down
1 change: 0 additions & 1 deletion include/Optimizer/AdaGrad.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace MiniDNN
class AdaGrad: public Optimizer
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
typedef Eigen::Array<Scalar, Eigen::Dynamic, 1> Array;
typedef Vector::ConstAlignedMapType ConstAlignedMapVec;
typedef Vector::AlignedMapType AlignedMapVec;
Expand Down
1 change: 0 additions & 1 deletion include/Optimizer/Adam.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace MiniDNN
class Adam: public Optimizer
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
typedef Eigen::Array<Scalar, Eigen::Dynamic, 1> Array;
typedef Vector::ConstAlignedMapType ConstAlignedMapVec;
typedef Vector::AlignedMapType AlignedMapVec;
Expand Down
1 change: 0 additions & 1 deletion include/Optimizer/RMSProp.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace MiniDNN
class RMSProp: public Optimizer
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
typedef Eigen::Array<Scalar, Eigen::Dynamic, 1> Array;
typedef Vector::ConstAlignedMapType ConstAlignedMapVec;
typedef Vector::AlignedMapType AlignedMapVec;
Expand Down
1 change: 0 additions & 1 deletion include/Optimizer/SGD.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace MiniDNN
class SGD: public Optimizer
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
typedef Vector::ConstAlignedMapType ConstAlignedMapVec;
typedef Vector::AlignedMapType AlignedMapVec;

Expand Down
2 changes: 0 additions & 2 deletions include/Output.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ namespace MiniDNN
class Output
{
protected:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
typedef Eigen::RowVectorXi IntegerVector;

public:
Expand Down
2 changes: 0 additions & 2 deletions include/Output/RegressionMSE.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ namespace MiniDNN
class RegressionMSE: public Output
{
private:
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;

Matrix m_din; // Derivative of the input of this layer.
// Note that input of this layer is also the output of previous layer
Expand Down
10 changes: 4 additions & 6 deletions include/Utils/Convolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ inline void moving_product(
const int step,
const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>&
mat1,
Eigen::Map< const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> >& mat2,
Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& res
Eigen::Map< const Matrix >& mat2,
Matrix& res
)
{
const int row1 = mat1.rows();
Expand All @@ -156,7 +156,6 @@ inline void convolve_valid(
const Scalar* filter_data,
Scalar* dest)
{
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
RMatrix;
typedef Eigen::Map<const Matrix> ConstMapMat;
Expand Down Expand Up @@ -243,8 +242,8 @@ inline void moving_product(
const int padding, const int step,
const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>&
mat1,
const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& mat2,
Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& res
const Matrix& mat2,
Matrix & res
)
{
const int row1 = mat1.rows();
Expand Down Expand Up @@ -294,7 +293,6 @@ inline void convolve_full(
const Scalar* src, const int n_obs, const Scalar* filter_data,
Scalar* dest)
{
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
RMatrix;
typedef Eigen::Map<const Matrix> ConstMapMat;
Expand Down