-
Notifications
You must be signed in to change notification settings - Fork 0
/
general.cuh
49 lines (34 loc) · 2.08 KB
/
general.cuh
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
48
49
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>;
#include <vector>
#include "general.h"
using namespace std;
#define gpuErrorchk(ans) { gpuAssert((ans), __FILE__, __LINE__);}
inline void gpuAssert(cudaError code, const char* file, int line, bool abort = true) {
if (code != cudaSuccess) {
fprintf(stderr, "GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
if (abort) exit(code);
}
}
void cudaAllocate2dOffVectorHostRef(double*** d_inputs, vector<vector<double>> h_inputs, bool vocal = false);
void cudaFree2dHostRef(double*** d_a, int size);
void cudaMemCopy2dOffVectorHostRef(double*** d_a, vector<vector<double>> h_a, bool vocal = false);
void cudaAllocateFull2dOffVectorHostRef(double*** d_a, vector<vector<double>> h_a, int batchSize);
void cudaAllocate3dOffVectorHostRef(double*** d_a, vector<vector<vector<double>>> h_a);
void cudaAllocate2dOffVector(double** d_a, vector<vector<double>> h_inputs, int** lengths);
void cudaAllocate2dOffVector(double** d_a, vector<vector<double>> h_inputs);
void cudaAllocate3dOffVector(double** d_inputs, vector<vector<vector<double>>> h_inputs);
void cudaMemcpy2dOffVector(double** d_a, vector<vector<double>> h_inputs);
void cudaMemcpy3dOffVector(double** d_a, vector<vector<vector<double>>> h_inputs);
void cudaMemcpy3dOffVectorHostRef(double*** d_a, vector<vector<vector<double>>> h_a);
vector<vector<double>> cudaCopy2dBackToVector(double** d_a, vector<int> lengths);
vector<vector<vector<double>>> cudaCopy3dBackToVector(double** d_a, vector<vector<int>> lengths);
vector<vector<double>> cudaCopy2dBackToVectorHref(double** d_a, vector<int> lengths);
vector<vector<vector<double>>> cudaCopy3dBackToVectorHref(double*** d_a, vector<vector<int>> lengths);
vector<vector<double>> cudaCopyBatchBackToVectorHref(double** d_a, int size, int batchSize);
vector<double> cudaCopy2dBackTo1dVector(double** d_a, vector<int> lengths);
double*** createBatches(double** hr_a, int batchSize, int examples, int size);
vector<vector<double>> batchify(vector<vector<double>>* data, int batchSize);