-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utility.cu
executable file
·47 lines (41 loc) · 1.88 KB
/
Utility.cu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <random>
#include <algorithm>
#include <cuda_runtime.h>
#include <cublas_v2.h>
#include "Utility.cuh"
namespace Utility {
const char* cublasGetErrorString(cublasStatus_t status)
{
switch(status)
{
case CUBLAS_STATUS_SUCCESS: return "CUBLAS_STATUS_SUCCESS";
case CUBLAS_STATUS_NOT_INITIALIZED: return "CUBLAS_STATUS_NOT_INITIALIZED";
case CUBLAS_STATUS_ALLOC_FAILED: return "CUBLAS_STATUS_ALLOC_FAILED";
case CUBLAS_STATUS_INVALID_VALUE: return "CUBLAS_STATUS_INVALID_VALUE";
case CUBLAS_STATUS_ARCH_MISMATCH: return "CUBLAS_STATUS_ARCH_MISMATCH";
case CUBLAS_STATUS_MAPPING_ERROR: return "CUBLAS_STATUS_MAPPING_ERROR";
case CUBLAS_STATUS_EXECUTION_FAILED: return "CUBLAS_STATUS_EXECUTION_FAILED";
case CUBLAS_STATUS_INTERNAL_ERROR: return "CUBLAS_STATUS_INTERNAL_ERROR";
}
return "Unknown cuBLAS error";
}
Gradients::Gradients(double* deviceVisiblePositiveGradients_, double* deviceHiddenPositiveGradients_, double* deviceVisibleNegativeGradients_, double* deviceHiddenNegativeGradients_) :
deviceVisiblePositiveGradients(deviceVisiblePositiveGradients_),
deviceHiddenPositiveGradients(deviceHiddenPositiveGradients_),
deviceVisibleNegativeGradients(deviceVisibleNegativeGradients_),
deviceHiddenNegativeGradients(deviceHiddenNegativeGradients_) {}
Gradients::~Gradients() {
cudaFree(deviceHiddenPositiveGradients);
cudaFree(deviceVisibleNegativeGradients);
cudaFree(deviceHiddenNegativeGradients);
}
Deltas::Deltas(double* deviceDeltaWeights_, double* deviceDeltaBiasesVisible_, double* deviceDeltaBiasesHidden_) :
deviceDeltaWeights(deviceDeltaWeights_),
deviceDeltaBiasesVisible(deviceDeltaBiasesVisible_),
deviceDeltaBiasesHidden(deviceDeltaBiasesHidden_) {}
Deltas::~Deltas() {
cudaFree(deviceDeltaWeights);
cudaFree(deviceDeltaBiasesVisible);
cudaFree(deviceDeltaBiasesHidden);
}
}