-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
26 lines (21 loc) · 762 Bytes
/
main.cpp
File metadata and controls
26 lines (21 loc) · 762 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
#include <iostream>
#include <tannic.hpp>
#include <tannic/functions.hpp>
#include <tannic/transformations.hpp>
using namespace tannic;
/*
Copy and paste this file into main.cpp and then run ``bash main.sh``
*/
int main() {
std::cout << "Working example of the tensor library" << std::endl;
Tensor X(float16, {2,2}); // X.initialize(Device()); for CUDA support
X[0, range{0,-1}] = 1;
X[1,0] = 3;
X[1][1] = 4;
Tensor Y(float32, {1,2}); // or X.initialize(Device()); for CUDA support
Y[0,0] = 4;
Y[0,1] = 6;
Y = log(X) + Y * Y - exp(X) + matmul(X, Y.transpose());
std::cout << Y; /* Tensor([[23.2817, 43.2817],
[33.0131, 18.7881]] dtype=float32, shape=(2, 2))*/
}