forked from wangsl/python-embedding
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.py
More file actions
41 lines (27 loc) · 638 Bytes
/
test.py
File metadata and controls
41 lines (27 loc) · 638 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
37
38
39
#!/bin/env python
import sys
from math import sin
import torch
import numpy
def my_test(x) :
print(' From Python test: {}'.format(x.size))
for i in range(x.size) :
x[i] += 1.0
a = torch.from_numpy(x)
print(a)
b = torch.from_numpy(x.astype(numpy.float32))
print(b)
if torch.cuda.is_available() :
b_dev = b.cuda()
print(b_dev)
my_test2()
sys.stdout.flush()
def my_test2() :
print(' **** From my_test2 ****')
return
if __name__ == '__main__' :
import numpy as np
x = np.arange(10, dtype=numpy.float64)
print(x)
my_test(x)
print(x)