license import * as tf from '@tensorflow/tfjs-core' ; import { test_util } from '@tensorflow/tfjs-core' ; const { expectArraysClose } = test_util ; import { ALL_ENVS , describeWithFlags } from '@tensorflow/tfjs-core/dist/jasmine_util' ; describeWithFlags ( 'Mean.' , ALL_ENVS , ( ) => { it ( 'does not have memory leak and works for large dimensions.' , async ( ) => { const beforeDataIds = tf . engine ( ) . backend . numDataIds ( ) ; const a = tf . ones ( [ 1 , 70000 ] ) ; const r = tf . mean ( a ) ; expect ( r . dtype ) . toBe ( 'float32' ) ; expectArraysClose ( await r . data ( ) , 1 ) ; const afterResDataIds = tf . engine ( ) . backend . numDataIds ( ) ; expect ( afterResDataIds ) . toEqual ( beforeDataIds + 2 ) ; a . dispose ( ) ; r . dispose ( ) ; const afterDisposeDataIds = tf . engine ( ) . backend . numDataIds ( ) ; expect ( afterDisposeDataIds ) . toEqual ( beforeDataIds ) ; } ) ; } ) ;