mirror of
https://github.com/lordmathis/CUDANet.git
synced 2025-11-07 18:24:26 +00:00
Move cuda source to separate directory
This commit is contained in:
31
src/cuda/layers/input.cu
Normal file
31
src/cuda/layers/input.cu
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "cuda_helper.cuh"
|
||||
#include "input.cuh"
|
||||
|
||||
using namespace CUDANet::Layers;
|
||||
|
||||
Input::Input(int inputSize) : inputSize(inputSize) {
|
||||
d_output = nullptr;
|
||||
CUDA_CHECK(cudaMalloc((void**)&d_output, sizeof(float) * inputSize));
|
||||
}
|
||||
|
||||
Input::~Input() {
|
||||
cudaFree(d_output);
|
||||
}
|
||||
|
||||
float* Input::forward(const float* input) {
|
||||
CUDA_CHECK(cudaMemcpy(
|
||||
d_output, input, sizeof(float) * inputSize, cudaMemcpyHostToDevice
|
||||
));
|
||||
CUDA_CHECK(cudaDeviceSynchronize());
|
||||
|
||||
return d_output;
|
||||
}
|
||||
|
||||
int Input::getOutputSize() {
|
||||
return inputSize;
|
||||
}
|
||||
|
||||
|
||||
int Input::getInputSize() {
|
||||
return inputSize;
|
||||
}
|
||||
Reference in New Issue
Block a user