mirror of
https://github.com/lordmathis/CUDANet.git
synced 2025-12-23 14:54:28 +00:00
Migrate input layer
This commit is contained in:
22
src/backends/cuda/layers/input.cu
Normal file
22
src/backends/cuda/layers/input.cu
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "cuda_helper.cuh"
|
||||
#include "input.hpp"
|
||||
|
||||
using namespace CUDANet::Layers;
|
||||
|
||||
void Input::initCUDA() {
|
||||
d_output = nullptr;
|
||||
CUDA_CHECK(cudaMalloc((void**)&d_output, sizeof(float) * inputSize));
|
||||
}
|
||||
|
||||
void Input::delCUDA() {
|
||||
cudaFree(d_output);
|
||||
}
|
||||
|
||||
float* Input::forwardCUDA(const float* input) {
|
||||
CUDA_CHECK(cudaMemcpy(
|
||||
d_output, input, sizeof(float) * inputSize, cudaMemcpyHostToDevice
|
||||
));
|
||||
CUDA_CHECK(cudaDeviceSynchronize());
|
||||
|
||||
return d_output;
|
||||
}
|
||||
Reference in New Issue
Block a user