TensorFlow.js matrix multiplication 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= it=

GeForce RTX 2070, OpenGL backend, Windows 10, 64 bit (N=4096)   0.77 TFLOPS

"Semi-quantitative" plot.
<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()
}
function run() {
  var ti0 = performance.now(), ti, Tmin = 100000, str = "\n T(ms)= "
  for(var i = 0; i < it; i++){
    const C = A.matMul(B)
    var t = C.dataSync()[0];
    ti = performance.now()
    dt = ti - ti0
    if(Tmin > dt) Tmin = dt
    str += Math.round(10*dt)/10 + "\u2003"
    ti0 = ti
  }
  document.getElementById('output').innerText = "N = " + N +
    " GFLOPS=" + Math.round(2*N*N*N/Tmin/10000)/100 + str
}

Comments

This script uses dummy "C.dataSync()[0]" every run for synchronisation. "Asynchronous" script.
GEMM tests on RTX 2070     updated 17 July 2019