license import * as tf from '@tensorflow/tfjs-core' ; import { ALL_ENVS , describeWithFlags } from '@tensorflow/tfjs-core/dist/jasmine_util' ; describeWithFlags ( 'stft memory test' , ALL_ENVS , ( ) => { it ( 'should have no mem leak' , async ( ) => { const win = 320 ; const fft = 320 ; const hop = 160 ; const input = tf . zeros < tf . Rank . R1 > ( [ 1760 ] ) ; const startTensors = tf . memory ( ) . numTensors ; const startDataIds = tf . engine ( ) . backend . numDataIds ( ) ; const result = await tf . signal . stft ( input , win , hop , fft ) ; expect ( tf . memory ( ) . numTensors ) . toBe ( startTensors + 1 ) ; expect ( tf . engine ( ) . backend . numDataIds ( ) ) . toBe ( startTensors + 3 ) ; result . dispose ( ) ; expect ( tf . memory ( ) . numTensors ) . toBe ( startTensors ) ; expect ( tf . engine ( ) . backend . numDataIds ( ) ) . toBe ( startDataIds ) ; input . dispose ( ) ; } ) ; } ) ;