mirror of
https://github.com/lordmathis/CUDANet.git
synced 2025-11-06 01:34:22 +00:00
Format source code using clang-format
This commit is contained in:
@@ -7,8 +7,11 @@ __device__ float sigmoid(float a);
|
||||
__device__ float relu(float a);
|
||||
__device__ float linear(float a);
|
||||
|
||||
__global__ void sigmoid_kernel(const float* __restrict__ src, float* __restrict__ dst, int len);
|
||||
__global__ void relu_kernel(const float* __restrict__ src, float* __restrict__ dst, int len);
|
||||
__global__ void linear_kernel(const float* __restrict__ src, float* __restrict__ dst, int len);
|
||||
__global__ void
|
||||
sigmoid_kernel(const float* __restrict__ src, float* __restrict__ dst, int len);
|
||||
__global__ void
|
||||
relu_kernel(const float* __restrict__ src, float* __restrict__ dst, int len);
|
||||
__global__ void
|
||||
linear_kernel(const float* __restrict__ src, float* __restrict__ dst, int len);
|
||||
|
||||
#endif // ACTIVATIONS_H
|
||||
#endif // ACTIVATIONS_H
|
||||
@@ -5,22 +5,27 @@
|
||||
|
||||
namespace Layers {
|
||||
|
||||
class Conv {
|
||||
public:
|
||||
Conv(int inputSize, int outputSize, int kernelSize, cublasHandle_t cublasHandle);
|
||||
~Conv();
|
||||
class Conv {
|
||||
public:
|
||||
Conv(
|
||||
int inputSize,
|
||||
int outputSize,
|
||||
int kernelSize,
|
||||
cublasHandle_t cublasHandle
|
||||
);
|
||||
~Conv();
|
||||
|
||||
void forward(const float* input, float* output);
|
||||
void forward(const float* input, float* output);
|
||||
|
||||
private:
|
||||
int inputSize;
|
||||
int outputSize;
|
||||
int kernelSize;
|
||||
cublasHandle_t cublasHandle;
|
||||
float* d_weights;
|
||||
float* d_biases;
|
||||
};
|
||||
private:
|
||||
int inputSize;
|
||||
int outputSize;
|
||||
int kernelSize;
|
||||
cublasHandle_t cublasHandle;
|
||||
float* d_weights;
|
||||
float* d_biases;
|
||||
};
|
||||
|
||||
} // namespace Layers
|
||||
} // namespace Layers
|
||||
|
||||
#endif // CONV_LAYER_H
|
||||
#endif // CONV_LAYER_H
|
||||
|
||||
@@ -1,42 +1,49 @@
|
||||
#ifndef DENSE_LAYER_H
|
||||
#define DENSE_LAYER_H
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <cublas_v2.h>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ilayer.cuh"
|
||||
|
||||
namespace Layers {
|
||||
|
||||
class Dense : public ILayer {
|
||||
public:
|
||||
Dense(int inputSize, int outputSize, std::string activation, cublasHandle_t cublasHandle);
|
||||
~Dense();
|
||||
class Dense : public ILayer {
|
||||
public:
|
||||
Dense(
|
||||
int inputSize,
|
||||
int outputSize,
|
||||
std::string activation,
|
||||
cublasHandle_t cublasHandle
|
||||
);
|
||||
~Dense();
|
||||
|
||||
void forward(const float* input, float* output);
|
||||
void setWeights(const std::vector<std::vector<float>>& weights);
|
||||
void setBiases(const std::vector<float>& biases);
|
||||
void forward(const float* input, float* output);
|
||||
void setWeights(const std::vector<std::vector<float>>& weights);
|
||||
void setBiases(const std::vector<float>& biases);
|
||||
|
||||
private:
|
||||
int inputSize;
|
||||
int outputSize;
|
||||
private:
|
||||
int inputSize;
|
||||
int outputSize;
|
||||
|
||||
cublasHandle_t cublasHandle;
|
||||
cublasHandle_t cublasHandle;
|
||||
|
||||
float* d_weights;
|
||||
float* d_biases;
|
||||
float* d_weights;
|
||||
float* d_biases;
|
||||
|
||||
std::vector<float> weights;
|
||||
std::vector<float> biases;
|
||||
std::vector<float> weights;
|
||||
std::vector<float> biases;
|
||||
|
||||
std::string activation;
|
||||
std::string activation;
|
||||
|
||||
void initializeWeights();
|
||||
void initializeBiases();
|
||||
void toCuda();
|
||||
};
|
||||
void initializeWeights();
|
||||
void initializeBiases();
|
||||
void toCuda();
|
||||
};
|
||||
|
||||
} // namespace Layers
|
||||
} // namespace Layers
|
||||
|
||||
#endif // DENSE_LAYER_H
|
||||
#endif // DENSE_LAYER_H
|
||||
|
||||
@@ -3,19 +3,20 @@
|
||||
#define I_LAYER_H
|
||||
|
||||
#include <cublas_v2.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Layers {
|
||||
|
||||
class ILayer {
|
||||
public:
|
||||
virtual ~ILayer() {}
|
||||
class ILayer {
|
||||
public:
|
||||
virtual ~ILayer() {}
|
||||
|
||||
virtual void forward(const float* input, float* output) = 0;
|
||||
virtual void setWeights(const std::vector<std::vector<float>>& weights) = 0;
|
||||
virtual void setBiases(const std::vector<float>& biases) = 0;
|
||||
};
|
||||
virtual void forward(const float* input, float* output) = 0;
|
||||
virtual void setWeights(const std::vector<std::vector<float>>& weights) = 0;
|
||||
virtual void setBiases(const std::vector<float>& biases) = 0;
|
||||
};
|
||||
|
||||
} // namespace Layers
|
||||
} // namespace Layers
|
||||
|
||||
#endif // I_LAYERH
|
||||
#endif // I_LAYERH
|
||||
Reference in New Issue
Block a user