Skip to content

Commit

Permalink
await tf.memory() promise
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Apr 28, 2024
1 parent f023102 commit d414c24
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions brainchop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}`)
Expand Down Expand Up @@ -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.") {
Expand Down

0 comments on commit d414c24

Please sign in to comment.