What about using a devectorized inner loop instead of copying ``A[i, :]`` to ``tmp`` and calling ``find``?