• Executes the provided function f() and returns a promise that resolves with information about the function's memory use:

    • newBytes: the number of new bytes allocated
    • newTensors: the number of new tensors created
    • peakBytes: the peak number of bytes allocated
    • kernels: an array of objects for each kernel involved that reports their input and output shapes, number of bytes used, and number of new tensors created.
    • kernelNames: an array of unique strings with just the names of the kernels in the kernels array.
    const profile = await tf.profile(() => {
    const x = tf.tensor1d([1, 2, 3]);
    let x2 = x.square();
    x2.dispose();
    x2 = x.square();
    x2.dispose();
    return x;
    });

    console.log(`newBytes: ${profile.newBytes}`);
    console.log(`newTensors: ${profile.newTensors}`);
    console.log(`byte usage over all kernels: ${profile.kernels.map(k =>
    k.totalBytesSnapshot)}`);

    Parameters

    Returns Promise<ProfileInfo>

    Doc

Generated using TypeDoc