arr_t = [
[0,0,1,1,1,0,0],
[0,0,1,0,1,0,0],
[0,0,1,0,1,0,3],
[0,0,1,0,1,0,3],
[0,0,1,1,1,0,3]
]
mask = [
[0,0,1,1,1,0,0],
[0,0,1,0,1,0,0],
[0,0,1,1,1,0,0],
[0,0,1,0,1,0,0],
[0,0,1,1,1,0,0]
]
t1 = torch.IntTensor(arr_t).to(torch.int8)
t2 = torch.IntTensor(mask).to(torch.int8)
t3 = t2 >0
t1[t3] = t2[t3] # when using c++ this line can't be success
print(t1)
tensor([[0, 0, 1, 1, 1, 0, 0],
[0, 0, 1, 0, 1, 0, 0],
[0, 0, 1, 1, 1, 0, 3],
[0, 0, 1, 0, 1, 0, 3],
[0, 0, 1, 1, 1, 0, 3]], dtype=torch.int8)