license import { KernelConfig , Unpack , UnpackAttrs , UnpackInputs } from '@tensorflow/tfjs' ; import { createTensorsTypeOpAttr , NodeJSKernelBackend } from '../nodejs_kernel_backend' ; export const unpackConfig = { kernelName : Unpack , backendName : 'tensorflow' , kernelFunc : ( args ) => { const { value } = args . inputs as UnpackInputs ; const backend = args . backend as NodeJSKernelBackend ; let { axis } = args . attrs as { } as UnpackAttrs ; if ( axis < 0 ) { axis += value . shape . length ; } if ( axis >= value . shape . length ) { throw new Error ( `Invalid axis supplied: ${ axis } shape length: ${ value . shape . length }` ) ; } const num = value . shape [ axis ] ; const opAttrs = [ { name : 'num' , type : backend . binding . TF_ATTR_INT , value : num } , createTensorsTypeOpAttr ( 'T' , value . dtype ) , { name : 'axis' , type : backend . binding . TF_ATTR_INT , value : axis } ] ; return backend . executeMultipleOutputs ( Unpack , opAttrs , [ value ] , num ) ; } } ;