This is a piece of reproduced code.
import sys, torch
@torch.jit.script
def magic_func(x, y):
return torch.tanh(x + y)
x, y = torch.rand(8, device="cuda"), torch.rand(8, device="cuda")
before_encoding = open(sys.argv[0]).encoding
for _ in range(int(sys.argv[1])):
output = magic_func(x, y)
after_encoding = open(sys.argv[0]).encoding
print(f'{before_encoding} vs. {after_encoding}')
Test results:
$ python utf8.py 3
UTF-8 vs. ANSI_X3.4-1968
$ python utf8.py 2
UTF-8 vs. ANSI_X3.4-1968
$ python utf8.py 1
UTF-8 vs. UTF-8
What’s going on here?