if you are summing over LongTensor, converting it float before sum may help. Something like below:
            non_padding = target.ne(pad)
            correct = seqlist[step].view(-1).eq(target).masked_select(non_padding).float().sum().data[0]
            match += correct
            total += non_padding.float().sum().data[0]