-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cu
More file actions
36 lines (29 loc) · 1016 Bytes
/
main.cu
File metadata and controls
36 lines (29 loc) · 1016 Bytes
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
#include "include/tensor.cuh"
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
void xyz() {
/* Write to binary file */
DTensor<double> r = DTensor<double>::createRandomTensor(3, 6, 4, -1, 1).setStreamIdx(1);
std::string fName = "abcd.bt"; // binary tensor file extension: .bt
r.saveToFile(fName);
/* Parse binary file */
auto recov = DTensor<double>::parseFromFile(fName);
std::cout << r;
std::cout << recov;
auto err = r - recov;
std::cout << "max error : " << err.maxAbs() << std::endl;
std::cout << "Memory: " << std::setprecision(3)
<< (float) Session::getInstance().totalAllocatedBytes() / 1e6
<< " MB" << std::endl;
Session::getInstance().synchronizeAllStreams();
}
int main() {
Session::setStreams(5);
xyz();
std::cout << "Memory (outside): " << std::setprecision(3)
<< (float) Session::getInstance().totalAllocatedBytes() / 1e6
<< " MB" << std::endl;
return 0;
}