mirror of
https://github.com/lordmathis/CUDANet.git
synced 2025-11-06 01:34:22 +00:00
Update activation test
This commit is contained in:
@@ -17,6 +17,8 @@ Activation::Activation(ActivationType activation, const int length)
|
||||
|
||||
d_softmax_sum = nullptr;
|
||||
CUDA_CHECK(cudaMalloc((void**)&d_softmax_sum, sizeof(float) * length));
|
||||
|
||||
std::cout << "Activation: Softmax " << length << std::endl;
|
||||
}
|
||||
|
||||
gridSize = (length + BLOCK_SIZE - 1) / BLOCK_SIZE;
|
||||
|
||||
@@ -28,7 +28,16 @@ void Utils::max(float* d_vec, float* d_max, const unsigned int length) {
|
||||
|
||||
const int grid_size = (length + BLOCK_SIZE - 1) / BLOCK_SIZE;
|
||||
|
||||
std::cout << "grid_size: " << grid_size << ", length: " << length << std::endl;
|
||||
CUDA_CHECK(cudaGetLastError());
|
||||
|
||||
Kernels::max_reduce<<<grid_size, BLOCK_SIZE>>>(d_vec, d_max, length);
|
||||
|
||||
std::cout << "input: " << std::endl;
|
||||
print_vec(d_vec, length);
|
||||
std::cout << "max: " << std::endl;
|
||||
print_vec(d_max, length);
|
||||
|
||||
CUDA_CHECK(cudaGetLastError());
|
||||
|
||||
int remaining = grid_size;
|
||||
@@ -46,7 +55,6 @@ void Utils::sum(float* d_vec, float* d_sum, const unsigned int length) {
|
||||
|
||||
const int gridSize = (length + BLOCK_SIZE - 1) / BLOCK_SIZE;
|
||||
|
||||
|
||||
CUDANet::Kernels::sum_reduce<<<gridSize, BLOCK_SIZE>>>(
|
||||
d_vec, d_sum, length
|
||||
);
|
||||
@@ -57,7 +65,7 @@ void Utils::sum(float* d_vec, float* d_sum, const unsigned int length) {
|
||||
int blocks_needed = (remaining + BLOCK_SIZE - 1) / BLOCK_SIZE;
|
||||
CUDANet::Kernels::sum_reduce<<<blocks_needed, BLOCK_SIZE>>>(d_sum, d_sum, remaining);
|
||||
CUDA_CHECK(cudaGetLastError());
|
||||
|
||||
|
||||
remaining = blocks_needed;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user