license import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter' ; import { ExecutionContext } from '../../executor/execution_context' ; import * as spectral from '../op_list/spectral' ; import { Node } from '../types' ; import { executeOp } from './spectral_executor' ; import { createTensorAttr , validateParam } from './test_helper' ; describe ( 'spectral' , ( ) => { let node ; const input1 = [ tfOps . scalar ( 1 ) ] ; const context = new ExecutionContext ( { } , { } , { } ) ; beforeEach ( ( ) => { node = { name : 'test' , op : '' , category : 'spectral' , inputNames : [ 'input1' ] , inputs : [ ] , inputParams : { x : createTensorAttr ( 0 ) } , attrParams : { } , children : [ ] } ; } ) ; describe ( 'executeOp' , ( ) => { describe ( 'FFT' , ( ) => { it ( 'should call tfOps.fft' , ( ) => { spyOn ( tfOps , 'fft' ) ; node . op = 'FFT' ; executeOp ( node , { input1 } , context ) ; expect ( tfOps . fft ) . toHaveBeenCalledWith ( input1 [ 0 ] ) ; } ) ; it ( 'should match json def' , ( ) => { node . op = 'FFT' ; expect ( validateParam ( node , spectral . json ) ) . toBeTruthy ( ) ; } ) ; } ) ; describe ( 'IFFT' , ( ) => { it ( 'should call tfOps.ifft' , ( ) => { spyOn ( tfOps , 'ifft' ) ; node . op = 'IFFT' ; executeOp ( node , { input1 } , context ) ; expect ( tfOps . ifft ) . toHaveBeenCalledWith ( input1 [ 0 ] ) ; } ) ; it ( 'should match json def' , ( ) => { node . op = 'IFFT' ; expect ( validateParam ( node , spectral . json ) ) . toBeTruthy ( ) ; } ) ; } ) ; describe ( 'RFFT' , ( ) => { it ( 'should call tfOps.rfft' , ( ) => { spyOn ( tfOps , 'rfft' ) ; node . op = 'RFFT' ; executeOp ( node , { input1 } , context ) ; expect ( tfOps . rfft ) . toHaveBeenCalledWith ( input1 [ 0 ] ) ; } ) ; it ( 'should match json def' , ( ) => { node . op = 'RFFT' ; expect ( validateParam ( node , spectral . json ) ) . toBeTruthy ( ) ; } ) ; } ) ; describe ( 'IRFFT' , ( ) => { it ( 'should call tfOps.irfft' , ( ) => { spyOn ( tfOps , 'irfft' ) ; node . op = 'IRFFT' ; executeOp ( node , { input1 } , context ) ; expect ( tfOps . irfft ) . toHaveBeenCalledWith ( input1 [ 0 ] ) ; } ) ; it ( 'should match json def' , ( ) => { node . op = 'IRFFT' ; expect ( validateParam ( node , spectral . json ) ) . toBeTruthy ( ) ; } ) ; } ) ; } ) ; } ) ;