Refactor Backend and Layer interfaces

This commit is contained in:
2025-11-18 18:27:57 +01:00
parent 25670f90c4
commit 6340b27055
23 changed files with 154 additions and 201 deletions

42
include/layer.hpp Normal file
View File

@@ -0,0 +1,42 @@
#pragma once
#include <vector>
#include "shape.hpp"
#include "tensor.hpp"
#define CUDANET_SAME_PADDING(inputSize, kernelSize, stride) \
((stride - 1) * inputSize - stride + kernelSize) / 2;
namespace CUDANet {
/**
* @brief Basic Sequential Layer
*
*/
class Layer {
public:
virtual ~Layer(){};
virtual CUDANet::Tensor& forward(CUDANet::Tensor &input) = 0;
virtual CUDANet::Shape input_shape() = 0;
virtual CUDANet::Shape output_shape() = 0;
virtual int input_size() = 0;
virtual int output_size() = 0;
virtual void set_weights(CUDANet::Tensor &input) = 0;
virtual CUDANet::Tensor& get_weights() = 0;
virtual void set_biases(CUDANet::Tensor &input) = 0;
virtual CUDANet::Tensor& get_biases() = 0;
};
} // namespace CUDANet::Layers