Solved by Michael_Suo in post #3 
              
              
                Actually: I believe this is correct behavior. Indexing a tensor with another tensor produces a copy of the original tensor. So in the code: 
data_sigma[data_sigma < 1e-12].fill_(1.0)

you are performing fill_ on a copy of data_sigma, then immediately throwing it away. The TorchScript compiler is cor…