From d414c2431012f49d79572f22d72a51e921d004b0 Mon Sep 17 00:00:00 2001 From: neurolabusc Date: Sun, 28 Apr 2024 18:30:15 -0400 Subject: [PATCH] await tf.memory() promise --- brainchop.js | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/brainchop.js b/brainchop.js index 8a47d17..3d90056 100644 --- a/brainchop.js +++ b/brainchop.js @@ -1248,7 +1248,7 @@ class SequentialConvLayer { const seqTimer = window.setInterval(async function () { tf.engine().startScope() // Start TensorFlow.js scope console.log('=======================') - const memoryInfo0 = tf.memory() + const memoryInfo0 = await tf.memory() console.log(`| Number of Tensors: ${memoryInfo0.numTensors}`) console.log(`| Number of Data Buffers: ${memoryInfo0.numDataBuffers}`) console.log('Channel : ', chIdx) @@ -1273,20 +1273,12 @@ class SequentialConvLayer { return [newoutC, newoutB] }) - // -- await showMemStatus(chIdx, self.outChannels); - - const memoryInfo1 = tf.memory() - console.log(`| Number of Tensors: ${memoryInfo1.numTensors}`) - console.log(`| Number of Data Buffers: ${memoryInfo1.numDataBuffers}`) console.log('=======================') - - // Log memory usage - - const memoryInfo = tf.memory() + const memoryInfo = await tf.memory() self.callbackUI(`Iteration ${chIdx}`, chIdx / self.outChannels) console.log(`Number of Tensors: ${memoryInfo.numTensors}`) console.log(`Number of Data Buffers: ${memoryInfo.numDataBuffers}`) - console.log(`Bytes In Use: ${memoryInfo.numBytes}`) + console.log(`Megabytes In Use: ${(memoryInfo.numBytes / 1048576).toFixed(3)} MB`) if (memoryInfo.unreliable) { console.log(`Unreliable: ${memoryInfo.unreliable}`) @@ -1643,16 +1635,6 @@ async function inferenceFullVolumeSeqCovLayerPhase2( 3 ) // important for memory use } - - // // Log memory usage - // const memoryInfo = tf.memory(); - // console.log(`Iteration ${i}:`); - // console.log(`Number of Tensors: ${memoryInfo.numTensors}`); - // console.log(`Number of Data Buffers: ${memoryInfo.numDataBuffers}`); - // console.log(`Bytes In Use: ${memoryInfo.numBytes}`); - // console.log(`Megabytes In Use: ${(memoryInfo.numBytes / 1048576).toFixed(3)} MB`); - // console.log(`Unreliable: ${memoryInfo.unreliable}`); - tf.dispose(curTensor[i - 1]) } catch (err) { // ? original code provided special dialog for shaders if( err.message === "Failed to compile fragment shader.") {