-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathautograd.cpp
More file actions
28 lines (27 loc) · 716 Bytes
/
Copy pathautograd.cpp
File metadata and controls
28 lines (27 loc) · 716 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
#include "autograd.h"
void testEinsor()
{
// EinsorD tensora(3, 2, true);
// tensora << 1, 2, 3, 4, 5, 6;
// EinsorD tensorb(2, 3, true);
// tensorb << 1, 2, 3, 4, 5, 6;
// EinsorD tensorc(3, 3, true);
// tensorc << 1, 1, 1, 1, 1, 1, 1, 1, 1;
// // tensorc << 2, 2, 2, 2, 2, 2, 2, 2, 2;
// EinsorD result = tensora * tensorb;
// result = (result * tensorc).sum();
// result.backward();
// // result.backward();
// cout << tensora;
// cout << tensorb;
// cout << tensorc;
EinsorD tensora(3, 2, true);
tensora << 1, 2, 3, 4, 5, 6;
EinsorD tensorb(3, 2, true);
tensorb << 2, 3, 4, 5, 6, 7;
auto rab = tensora / tensorb;
auto rabd = rab.sum();
rabd.backward();
cout << tensora;
cout << tensorb;
}