Could you check, if the einsum time would be reduced in the second case, if you manually add a .contiguous() call on the output of unfold? The output of unfold might not be contiguous and I’m not sure, if einsum would call it internally, which could explain the difference in performance.