I don't think so: the weights depend on the difference between pixel values in the two patches (tmp_diff), so I don't see what could be precomputed.