-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTensor.cuh
More file actions
80 lines (74 loc) · 2.04 KB
/
Tensor.cuh
File metadata and controls
80 lines (74 loc) · 2.04 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef TENSOR_H
#define TENSOR_H
#include <cuda.h>
#include <cuda_runtime.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <cmath>
#include <random>
#include <stdexcept>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
class Tensor {
public:
Tensor();
Tensor(int, int, int);
Tensor(int, int, int, double);
Tensor(int, int, int, double, double, string);
Tensor(const Tensor&);
Tensor(vector<double>);
Tensor(vector<vector<double>>);
Tensor(vector<vector<vector<double>>>);
~Tensor();
Tensor transpose();
Tensor dot_product(const Tensor&) const;
Tensor& operator=(const Tensor&);
double& operator()(int, int, int);
double operator()(int, int, int) const;
Tensor operator+(const Tensor&);
Tensor operator-(const Tensor&);
Tensor operator*(const Tensor&);
Tensor operator/(const Tensor&);
Tensor operator+(double);
Tensor operator-(double);
Tensor operator*(double);
Tensor operator/(double);
Tensor& operator+=(const Tensor&);
Tensor& operator-=(const Tensor&);
Tensor& operator*=(const Tensor&);
Tensor& operator/=(const Tensor&);
Tensor& operator+=(double);
Tensor& operator-=(double);
Tensor& operator*=(double);
Tensor& operator/=(double);
Tensor power(double);
Tensor sign() const;
Tensor abs() const;
Tensor copy();
Tensor getitem(int) const;
Tensor getitem(int, int) const;
double getitem(int, int, int) const;
void setitem(int, int, int, double);
void setitem(int, int, double);
void setitem(int, int, const Tensor&);
void setitem(int, const Tensor&);
double sum() const;
int size() const;
int getBatchsize() const;
int getRows() const;
int getCols() const;
string toString() const;
static void err_check(cudaError_t, string);
vector<vector<vector<double>>> tolist() const;
int rows_;
int cols_;
int batch_size_;
tuple<int, int, int> shape_;
int size_;
double* data_;
};
#endif // TENSOR_H