Fix Tensor issues

This commit is contained in:
2025-11-18 22:38:56 +01:00
parent 4c26efe826
commit 10c84d75fc
4 changed files with 21 additions and 25 deletions

View File

@@ -10,10 +10,10 @@ Dense::Dense(CUDANet::Backend* backend, CUDANet::Shape in, CUDANet::Shape out)
in_shape(in),
out_shape(out),
weights(
CUDANet::Tensor{{in[0] * out[0]}, CUDANet::DType::FLOAT32, backend}
CUDANet::Tensor(Shape{in[0] * out[0]}, CUDANet::DType::FLOAT32, backend)
),
biases(CUDANet::Tensor({out[0]}, CUDANet::DType::FLOAT32, backend)),
output(CUDANet::Tensor({out[0]}, CUDANet::DType::FLOAT32, backend)) {
biases(CUDANet::Tensor(Shape{out[0]}, CUDANet::DType::FLOAT32, backend)),
output(CUDANet::Tensor(Shape{out[0]}, CUDANet::DType::FLOAT32, backend)) {
// Allocate memory for weights and biases
if (in.size() != 1) {
@@ -35,6 +35,8 @@ Dense::Dense(CUDANet::Backend* backend, CUDANet::Shape in, CUDANet::Shape out)
biases.zero();
}
Dense::~Dense() {}
CUDANet::Tensor& Dense::forward(const CUDANet::Tensor& input) {
backend->dense(weights, biases, input, output, in_shape[0], out_shape[0]);
return output;