The DP state dp[k][i][j] uses space. You can reduce this to . Notice that dp[k+1][i][j] only depends on dp[k]. You can update dist[i][j] in place without storing all layers.
This is why Floyd-Warshall uses a array and updates it during iteration. The space drops from to . This improvement makes the algorithm practical for graphs with thousands of vertices.