a A 5 × 5 permutation matrix to be implemented by the ring-waveguide system. The amplitudes of the matrix elements are indicated along with a green colormap. Element-wise amplitudes of the optimized result using four modulation tones (Nf = 4) and b one ring (Nr = 1), achieving a fidelity of 1 − 5.9 × 10−3, and c four rings (Nr = 4), achieving a fidelity of 1 − 3.8 × 10−6. d One minus the maximum fidelities achieved by the inverse-design algorithm as a function of Nr and Nf. A value closer to zero indicates a better performance. Modulation parameters for c are provided in Supplementary Note 6.