Dense Layer, Add
added the dense layer with a forward functions. I also made the add functions for most cases.
This commit is contained in:
+20
-20
@@ -49,7 +49,7 @@
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// VARIABLE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
static const panic::uint_t vector_omp_min_size = 10000;
|
||||
static const panic::types::uint_t vector_omp_min_size = 10000;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// FUNCTION PROTOTYPE
|
||||
@@ -77,7 +77,7 @@ vector<T>::vector() {
|
||||
// Creates a vector with size allocation and initializes all values to zero.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
vector<T>::vector(panic::uint_t size){
|
||||
vector<T>::vector(panic::types::uint_t size){
|
||||
length = size;
|
||||
|
||||
if (length == 0){
|
||||
@@ -88,7 +88,7 @@ vector<T>::vector(panic::uint_t size){
|
||||
data = new T[length];
|
||||
|
||||
PANIC_OMP_PARALLEL_FOR_IF(length > vector_omp_min_size)
|
||||
for (panic::uint_t i = 0; i < size; ++i){
|
||||
for (panic::types::uint_t i = 0; i < size; ++i){
|
||||
data[i] = static_cast<T>(0);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ vector<T>::vector(panic::uint_t size){
|
||||
// Creates a vector with size allocation and initializes all values.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
vector<T>::vector(panic::uint_t size, T value){
|
||||
vector<T>::vector(panic::types::uint_t size, T value){
|
||||
length = size;
|
||||
|
||||
if (size == 0){
|
||||
@@ -112,7 +112,7 @@ vector<T>::vector(panic::uint_t size, T value){
|
||||
data = new T[size];
|
||||
|
||||
PANIC_OMP_PARALLEL_FOR_IF(length > vector_omp_min_size)
|
||||
for (panic::uint_t i = 0; i < size; ++i){
|
||||
for (panic::types::uint_t i = 0; i < size; ++i){
|
||||
data[i] = value;
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ vector<T>::vector(const vector& other){
|
||||
data = new T[length];
|
||||
|
||||
PANIC_OMP_PARALLEL_FOR_IF(length > vector_omp_min_size)
|
||||
for (panic::uint_t i = 0; i < length; ++i){
|
||||
for (panic::types::uint_t i = 0; i < length; ++i){
|
||||
data[i] = other.data[i];
|
||||
}
|
||||
}
|
||||
@@ -177,7 +177,7 @@ vector<T>& vector<T>::operator=(const vector& other){
|
||||
new_data = new T[other.length];
|
||||
|
||||
PANIC_OMP_PARALLEL_FOR_IF(length > vector_omp_min_size)
|
||||
for (panic::uint_t i = 0; i < other.length; ++i){
|
||||
for (panic::types::uint_t i = 0; i < other.length; ++i){
|
||||
new_data[i] = other.data[i];
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ vector<T>& vector<T>::operator=(const vector& other){
|
||||
// Returns the length/size of the vector
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
panic::uint_t vector<T>::size() const{
|
||||
panic::types::uint_t vector<T>::size() const{
|
||||
return length;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ panic::uint_t vector<T>::size() const{
|
||||
// Resizes the vector to new length and keeps old values
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
bool vector<T>::resize(panic::uint_t new_size){
|
||||
bool vector<T>::resize(panic::types::uint_t new_size){
|
||||
if (new_size == length){
|
||||
return true;
|
||||
}
|
||||
@@ -221,19 +221,19 @@ bool vector<T>::resize(panic::uint_t new_size){
|
||||
}
|
||||
|
||||
T* new_data = new T[new_size];
|
||||
panic::uint_t copy_size = length;
|
||||
panic::types::uint_t copy_size = length;
|
||||
|
||||
if (new_size < length){
|
||||
copy_size = new_size;
|
||||
}
|
||||
|
||||
PANIC_OMP_PARALLEL_FOR_IF(copy_size > vector_omp_min_size)
|
||||
for (panic::uint_t i = 0; i < copy_size; ++i){
|
||||
for (panic::types::uint_t i = 0; i < copy_size; ++i){
|
||||
new_data[i] = data[i];
|
||||
}
|
||||
|
||||
PANIC_OMP_PARALLEL_FOR_IF(copy_size - new_size > vector_omp_min_size)
|
||||
for (panic::uint_t i = copy_size; i < new_size; ++i){
|
||||
for (panic::types::uint_t i = copy_size; i < new_size; ++i){
|
||||
new_data[i] = static_cast<T>(0);
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ bool vector<T>::resize(panic::uint_t new_size){
|
||||
template <typename T>
|
||||
bool vector<T>::fill(T value){
|
||||
PANIC_OMP_PARALLEL_FOR_IF(length > vector_omp_min_size)
|
||||
for (panic::uint_t i = 0; i < length; ++i){
|
||||
for (panic::types::uint_t i = 0; i < length; ++i){
|
||||
data[i] = value;
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ bool vector<T>::fill(T value){
|
||||
// Lets you read and write v[index]
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
T& vector<T>::operator[](panic::uint_t index){
|
||||
T& vector<T>::operator[](panic::types::uint_t index){
|
||||
return data[index];
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ T& vector<T>::operator[](panic::uint_t index){
|
||||
// Lets you read v[index] from a const vector
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
const T& vector<T>::operator[](panic::uint_t index) const{
|
||||
const T& vector<T>::operator[](panic::types::uint_t index) const{
|
||||
return data[index];
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ const T& vector<T>::operator[](panic::uint_t index) const{
|
||||
// Lets you read and write v.at(index) with index bounse
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
T& vector<T>::at(panic::uint_t index){
|
||||
T& vector<T>::at(panic::types::uint_t index){
|
||||
|
||||
if (index >= length){
|
||||
return data[length-1];
|
||||
@@ -307,7 +307,7 @@ T& vector<T>::at(panic::uint_t index){
|
||||
// Lets you read v[index] from a const vector with index bounse
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
const T& vector<T>::at(panic::uint_t index) const{
|
||||
const T& vector<T>::at(panic::types::uint_t index) const{
|
||||
if (index >= length){
|
||||
return data[length-1];
|
||||
}
|
||||
@@ -320,9 +320,9 @@ const T& vector<T>::at(panic::uint_t index) const{
|
||||
// EXPLICIT TEMPLATE INSTANTIATION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
template struct vector<panic::real_t>;
|
||||
template struct vector<panic::int_t>;
|
||||
template struct vector<panic::uint_t>;
|
||||
template struct vector<panic::types::real_t>;
|
||||
template struct vector<panic::types::int_t>;
|
||||
template struct vector<panic::types::uint_t>;
|
||||
|
||||
|
||||
} // namespace tensor
|
||||
|
||||
Reference in New Issue
Block a user