mirror of
https://github.com/lordmathis/CUDANet.git
synced 2025-11-06 09:44:28 +00:00
Change forward function to return output pointer
This commit is contained in:
@@ -26,10 +26,10 @@ class Conv2d : public ILayer {
|
||||
// Outputs
|
||||
int outputSize;
|
||||
|
||||
void forward(const float* d_input, float* d_output);
|
||||
void setWeights(const float* weights_input);
|
||||
void setBiases(const float* biases_input);
|
||||
void host_conv(const float* input, float* output);
|
||||
float* forward(const float* d_input);
|
||||
void setWeights(const float* weights_input);
|
||||
void setBiases(const float* biases_input);
|
||||
void host_conv(const float* input, float* output);
|
||||
|
||||
private:
|
||||
// Inputs
|
||||
@@ -47,6 +47,7 @@ class Conv2d : public ILayer {
|
||||
std::vector<float> biases;
|
||||
|
||||
// Cuda
|
||||
float* d_output;
|
||||
float* d_weights;
|
||||
float* d_biases;
|
||||
float* d_padded;
|
||||
|
||||
@@ -18,7 +18,7 @@ class Dense : public ILayer {
|
||||
);
|
||||
~Dense();
|
||||
|
||||
void forward(const float* d_input, float* d_output);
|
||||
float* forward(const float* d_input);
|
||||
void setWeights(const float* weights);
|
||||
void setBiases(const float* biases);
|
||||
|
||||
@@ -26,6 +26,8 @@ class Dense : public ILayer {
|
||||
int inputSize;
|
||||
int outputSize;
|
||||
|
||||
float* d_output;
|
||||
|
||||
float* d_weights;
|
||||
float* d_biases;
|
||||
|
||||
|
||||
@@ -6,24 +6,17 @@
|
||||
|
||||
namespace Layers {
|
||||
|
||||
enum Activation {
|
||||
SIGMOID,
|
||||
RELU,
|
||||
NONE
|
||||
};
|
||||
enum Activation { SIGMOID, RELU, NONE };
|
||||
|
||||
enum Padding {
|
||||
SAME,
|
||||
VALID
|
||||
};
|
||||
enum Padding { SAME, VALID };
|
||||
|
||||
class ILayer {
|
||||
public:
|
||||
virtual ~ILayer() {}
|
||||
|
||||
virtual void forward(const float* input, float* output) = 0;
|
||||
virtual void setWeights(const float* weights) = 0;
|
||||
virtual void setBiases(const float* biases) = 0;
|
||||
virtual float* forward(const float* input) = 0;
|
||||
virtual void setWeights(const float* weights) = 0;
|
||||
virtual void setBiases(const float* biases) = 0;
|
||||
|
||||
private:
|
||||
virtual void initializeWeights() = 0;
|
||||
@@ -34,6 +27,8 @@ class ILayer {
|
||||
int inputSize;
|
||||
int outputSize;
|
||||
|
||||
float* d_output;
|
||||
|
||||
float* d_weights;
|
||||
float* d_biases;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define CUDA_HELPER_H
|
||||
|
||||
#include <cuda_runtime.h>
|
||||
#include <cstdio>
|
||||
|
||||
// CUDA error checking macro
|
||||
#define CUDA_CHECK(call) \
|
||||
|
||||
Reference in New Issue
Block a user