• Executes f() and returns a promise that resolves with timing information.

    The result is an object with the following properties:

    • wallMs: Wall execution time.
    • kernelMs: Kernel execution time, ignoring data transfer. If using the WebGL backend and the query timer extension is not available, this will return an error object.
    • On WebGL The following additional properties exist:
      • uploadWaitMs: CPU blocking time on texture uploads.
      • downloadWaitMs: CPU blocking time on texture downloads (readPixels).
    const x = tf.randomNormal([20, 20]);
    const time = await tf.time(() => x.matMul(x));

    console.log(`kernelMs: ${time.kernelMs}, wallTimeMs: ${time.wallMs}`);

    Parameters

    • f: (() => void)

      The function to execute and time.

        • (): void
        • Returns void

    Returns Promise<TimingInfo>

    Doc

Generated using TypeDoc