TensorFlow.js matrix multiplication "async" benchmark

TensorFlow.js (WebGL) based NxN matrix multiplication C = A x B benchmark. Random A, B are generated for calculations. FLOPS = 2 N3 / time. You can set new N value (note that execution time ~N3). The first run initializes A,B and is the slowest.

calculating
N=

GeForce GT 710     ~9 GFLOPS (N=1024)   ~22 GFLOPS (N=2048)   22.8 GFLOPS (N=4096).

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest"> </script>

var N = 1024, A,B;
function init() {
  A = tf.randomUniform([N, N]);
  B = tf.randomUniform([N, N]);
  run()
}
async function run() {
  var ti0 = performance.now()
  const C = A.matMul(B)

  await C.data();

  var ti = performance.now()
  document.getElementById('output').innerText = "N = " + N +
    " time = " + Math.round(10*(ti - ti0))/10 +
    "ms GFLOPS=" + Math.round(N*N*N/(ti - ti0)/10000)/100
}
First "synchronous" script is a bit faster on AMD APU 120/130 ms for N = 1024.
SGEMM in WebGL2-compute     updated 8 May 2019