mirror of
https://github.com/lordmathis/CUDANet.git
synced 2025-11-07 10:14:27 +00:00
Remove cublas dependency
This commit is contained in:
@@ -4,15 +4,11 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "activations.cuh"
|
||||
#include "test_cublas_fixture.cuh"
|
||||
|
||||
class ActivationsTest : public CublasTestFixture {
|
||||
protected:
|
||||
cudaError_t cudaStatus;
|
||||
cublasStatus_t cublasStatus;
|
||||
};
|
||||
TEST(ActivationsTest, SigmoidSanityCheck) {
|
||||
|
||||
cudaError_t cudaStatus;
|
||||
|
||||
TEST_F(ActivationsTest, SigmoidSanityCheck) {
|
||||
float input[3] = {-100.0f, 0.0f, 100.0f};
|
||||
|
||||
std::vector<float> expected_output = {0.0f, 0.5f, 1.0f};
|
||||
@@ -26,8 +22,8 @@ TEST_F(ActivationsTest, SigmoidSanityCheck) {
|
||||
cudaStatus = cudaMalloc((void**)&d_output, sizeof(float) * 3);
|
||||
EXPECT_EQ(cudaStatus, cudaSuccess);
|
||||
|
||||
cublasStatus = cublasSetVector(3, sizeof(float), input, 1, d_input, 1);
|
||||
EXPECT_EQ(cublasStatus, CUBLAS_STATUS_SUCCESS);
|
||||
cudaStatus = cudaMemcpy(d_input, input, sizeof(float) * 3, cudaMemcpyHostToDevice);
|
||||
EXPECT_EQ(cudaStatus, cudaSuccess);
|
||||
|
||||
sigmoid_kernel<<<1, 3>>>(d_input, d_output, 3);
|
||||
cudaStatus = cudaDeviceSynchronize();
|
||||
@@ -35,9 +31,8 @@ TEST_F(ActivationsTest, SigmoidSanityCheck) {
|
||||
|
||||
std::vector<float> output(3);
|
||||
|
||||
cublasStatus =
|
||||
cublasGetVector(3, sizeof(float), d_output, 1, output.data(), 1);
|
||||
EXPECT_EQ(cublasStatus, CUBLAS_STATUS_SUCCESS);
|
||||
cudaStatus = cudaMemcpy(output.data(), d_output, sizeof(float) * 3, cudaMemcpyDeviceToHost);
|
||||
EXPECT_EQ(cudaStatus, cudaSuccess);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
EXPECT_NEAR(expected_output[i], output[i], 1e-5);
|
||||
|
||||
Reference in New Issue
Block a user