Skip to content

Relocated "fill*" methods #13

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

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
29902d2
Solved issue #10
bits2zbytes Mar 19, 2020
acf949d
Solved #10
bits2zbytes Mar 19, 2020
a342408
Tried solving #10
bits2zbytes Mar 19, 2020
5a525b5
corrected a mistake in data_structures_impl.cpp
bits2zbytes Mar 19, 2020
587e931
added cuda_data_structures header file to operation_impl
bits2zbytes Mar 19, 2020
08c3519
Update adaboost/cuda/cuda_data_structures.hpp
bits2zbytes Mar 25, 2020
ae27bd8
adding windows support to the readme
bits2zbytes Mar 29, 2020
cc96fcb
Update README.md
bits2zbytes Mar 29, 2020
54b9c53
Merge pull request #1 from codezonediitj/master
bits2zbytes Mar 29, 2020
1df6053
adding windows support to the readme
bits2zbytes Mar 29, 2020
783cd2b
Update README.md
bits2zbytes Mar 29, 2020
2df647f
Delete README.md
bits2zbytes Apr 1, 2020
cb7d86f
adding README
bits2zbytes Apr 1, 2020
fbb0f44
Delete README.md
bits2zbytes Apr 1, 2020
a0677af
commit
bits2zbytes Apr 1, 2020
2e05e35
commit
bits2zbytes Apr 1, 2020
2195e6b
Create README.md
bits2zbytes Apr 1, 2020
0a43c10
message
bits2zbytes Apr 1, 2020
b434585
Merge pull request #5 from bits2zbytes/master
bits2zbytes Apr 1, 2020
21a1df8
changed fill method's definition
bits2zbytes Apr 2, 2020
ae4180c
minor modification
bits2zbytes Apr 2, 2020
8c4d0fd
Update README.md
bits2zbytes Apr 2, 2020
551491f
Update README.md
bits2zbytes Apr 3, 2020
5975697
Update README.md
bits2zbytes Apr 3, 2020
061e2d7
Merge branch 'master' into Solves_issue_10
bits2zbytes Apr 3, 2020
613c4fa
added fill kernels to operations
bits2zbytes Apr 3, 2020
ad16abd
commit
bits2zbytes Apr 3, 2020
6bb348a
moved multiply and product methods from CUDA to operations
bits2zbytes Apr 3, 2020
b09423f
Update operations.hpp
bits2zbytes Apr 3, 2020
204e8ab
Minor modifications
bits2zbytes Apr 3, 2020
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ We are using the following technologies in our project,
4. Google Test
5. Boost.Python


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Building from source
--------------------
**Linux**
Expand Down Expand Up @@ -103,3 +104,4 @@ Please follow the rules and guidelines given below,
4. Follow the Pull Request policy given [here](https://github.com/codezonediitj/adaboost/wiki/Pull-Request-Policy). All changes are made through Pull Requests, no direct commits to the master branch.

Keep contributing!!
=======
53 changes: 0 additions & 53 deletions adaboost/core/data_structures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ namespace adaboost
void set(unsigned int index,
data_type_vector value);

/*
* Used for filling the vector with a given value.
*
* @param value The value with which the vector is
* to be populated.
*/
void fill(data_type_vector value);

/*
* Used for obtaining the size of the vector.
*/
Expand Down Expand Up @@ -158,14 +150,6 @@ namespace adaboost
unsigned int y,
data_type_matrix value);

/*
* Used for filling the matrix with a given value.
*
* @param value The value with which the matrix is
* to be populated.
*/
void fill(data_type_matrix value);

/*
* Used for obtaining number of rows in the vector.
*/
Expand All @@ -184,43 +168,6 @@ namespace adaboost
~Matrix();
};

/* @overload
* Used for taking dot product of two vectors.
*
* @param vec1 First vector in dot product.
* @param vec2 Second vector in dot product.
* @param result For storing the result.
*/
template <class data_type_vector>
void product(const Vector<data_type_vector>& vec1,
const Vector<data_type_vector>& vec2,
data_type_vector& result);

/* @overload
* Used for multiplying a vector
* and a matrix.
*
* @param vec The vector.
* @param mat The matrix.
* @param result A vector for storing the result.
*/
template <class data_type_vector, class data_type_matrix>
void multiply(const Vector<data_type_vector>& vec,
const Matrix<data_type_matrix>& mat,
Vector<data_type_vector>& result);

/* @overload
* Used for multiplyng two matrices.
*
* @param vec1 First matrix.
* @param vec2 Second matrix.
* @param result A matrix for storing the result.
*/
template <class data_type_matrix>
void multiply(const Matrix<data_type_matrix>& mat1,
const Matrix<data_type_matrix>& mat2,
Matrix<data_type_matrix>& result);

} // namespace core
} // namespace adaboost

Expand Down
77 changes: 0 additions & 77 deletions adaboost/core/data_structures_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ namespace adaboost
this->data[index] = value;
}

template <class data_type_vector>
void Vector<data_type_vector>::
fill(data_type_vector value)
{
for(unsigned int i = 0; i < this->size; i++)
{
this->data[i] = value;
}
}

template <class data_type_vector>
unsigned int Vector<data_type_vector>::get_size() const
{
Expand Down Expand Up @@ -133,19 +123,6 @@ namespace adaboost
this->data[x*this->cols + y] = value;
}

template <class data_type_matrix>
void Matrix<data_type_matrix>::
fill(data_type_matrix value)
{
for(unsigned int i = 0; i < this->rows; i++)
{
for(unsigned int j = 0; j < this->cols; j++)
{
this->data[i*this->cols + j] = value;
}
}
}

template <class data_type_matrix>
unsigned int Matrix<data_type_matrix>::
get_rows() const
Expand Down Expand Up @@ -176,60 +153,6 @@ namespace adaboost
}
}

template <class data_type_vector>
void product(const Vector<data_type_vector>& vec1,
const Vector<data_type_vector>& vec2,
data_type_vector& result)
{
adaboost::utils::check(vec1.get_size() == vec2.get_size(),
"Size of vectors don't match.");
result = 0;
for(unsigned int i = 0; i < vec1.get_size(); i++)
{
result += (vec1.at(i)*vec2.at(i));
}
}

template <class data_type_vector, class data_type_matrix>
void multiply(const Vector<data_type_vector>& vec,
const Matrix<data_type_matrix>& mat,
Vector<data_type_vector>& result)
{
adaboost::utils::check(vec.get_size() == mat.get_rows(),
"Orders mismatch in the inputs.");
for(unsigned int j = 0; j < mat.get_cols(); j++)
{
data_type_vector _result = 0;
for(unsigned int i = 0; i < mat.get_rows(); i++)
{
_result += (vec.at(i)*mat.at(i, j));
}
result.set(j, _result);
}
}

template <class data_type_matrix>
void multiply(const Matrix<data_type_matrix>& mat1,
const Matrix<data_type_matrix>& mat2,
Matrix<data_type_matrix>& result)
{
adaboost::utils::check(mat1.get_cols() == mat2.get_rows(),
"Order of matrices don't match.");
unsigned int common_cols = mat1.get_cols();
for(unsigned int i = 0; i < result.get_rows(); i++)
{
for(unsigned int j = 0; j < result.get_cols(); j++)
{
data_type_matrix _result = 0;
for(unsigned int k = 0; k < common_cols; k++)
{
_result += (mat1.at(i, k)*mat2.at(k, j));
}
result.set(i, j, _result);
}
}
}

#include "instantiated_templates_data_structures.hpp"

} // namespace core
Expand Down
116 changes: 116 additions & 0 deletions adaboost/core/operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,120 @@ namespace adaboost
{
namespace core
{
/* @overload
* Used for filling the vector with a given value.
*
* @param value The value with which the vector is
* to be populated.
* @param vec The Vector
*/
template <class data_type_vector>
void fill(const data_type_vector value,
const Vector<data_type_vector>& vec);

/*
* Used for taking dot product of two vectors.
*
* @param vec1 First vector in dot product.
* @param vec2 Second vector in dot product.
* @param result For storing the result.
*/
template <class data_type_vector>
void product(const Vector<data_type_vector>& vec1,
const Vector<data_type_vector>& vec2,
data_type_vector& result);

/*@overload
* Used for filling the vector with a given value.
* If block size is passed 0 then the values are
* filled on the CPU otherwise they are filled on
* GPU.
*
* @param value The value with which the vector is
* to be populated.
* @param vec The Vector
* @param block_size The number of threads to be
* launched per block on GPU.
*/
template <class data_type_vector>
void fill(const data_type_vector value,
const VectorGPU<data_type_vector>& vec,
unsigned block_size=0);

/*
* This function computes
* dot product of two vectors on
* GPU.
*/
template <class data_type_vector>
void product_gpu(const VectorGPU<data_type_vector>& vec1,
const VectorGPU<data_type_vector>& vec2,
data_type_vector& result,
unsigned block_size=0);


/* @overload
* Used for filling the matrix with a given value.
*
* @param value The value with which the matrix is
* to be populated.
* @param mat The Matrix
*/
template <class data_type_matrix>
void fill(const data_type_matrix value,
const Matrix<data_type_matrix>& mat);

/* @overload
* Used for multiplyng two matrices.
*
* @param vec1 First matrix.
* @param vec2 Second matrix.
* @param result A matrix for storing the result.
*/
template <class data_type_matrix>
void multiply(const Matrix<data_type_matrix>& mat1,
const Matrix<data_type_matrix>& mat2,
Matrix<data_type_matrix>& result);

/* @overload
* Used for multiplying a vector
* and a matrix.
*
* @param vec The vector.
* @param mat The matrix.
* @param result A vector for storing the result.
*/
template <class data_type_vector, class data_type_matrix>
void multiply(const Vector<data_type_vector>& vec,
const Matrix<data_type_matrix>& mat,
Vector<data_type_vector>& result);

/*@overload
* Used for filling the matrix with a given value.
* If block size x and block size y is passed 0 and 0 then the values are
* filled on the CPU otherwise they are filled on
* GPU.
*
* @param value The value with which the matrix is
* to be populated.
* @param mat The matrix
*/
template <class data_type_matrix>
void fill(const data_type_matrix value,
const MatrixGPU<data_type_matrix>& mat,
unsigned block_size_x=0,
unsigned block_size_y=0);

/*
* This function is
* used for multiplyng two matrices on
* GPU.
*/
template <class data_type_matrix>
void multiply_gpu(const MatrixGPU<data_type_matrix>& mat1,
const MatrixGPU<data_type_matrix>& mat2,
MatrixGPU<data_type_matrix>& result);

/*
* This function computes the sum of
* elements of the given vector and the
Expand Down Expand Up @@ -53,6 +167,8 @@ namespace adaboost
const Vector<data_type_1>& vec,
data_type_1& result);



} // namespace core
} // namespace adaboost

Expand Down
Loading