license import { backend_util , Concat , ConcatAttrs , ConcatInputs , KernelConfig , KernelFunc , TensorInfo , util } from '@tensorflow/tfjs-core' ; import { MathBackendWebGL } from '../backend_webgl' ; import { concatImpl } from './Concat_impl' ; import { identity } from './Identity' ; export function concat ( args ) { const { inputs , backend , attrs } = args ; const { axis } = attrs ; const $axis = util . parseAxisParam ( axis , inputs [ 0 ] . shape ) [ 0 ] ; const outShape = backend_util . computeOutShape ( inputs . map ( t => t . shape ) , $axis ) ; if ( util . sizeFromShape ( outShape ) === 0 ) { return backend . makeTensorInfo ( outShape , inputs [ 0 ] . dtype , [ ] ) ; } const $inputs = inputs . filter ( t => util . sizeFromShape ( t . shape ) > 0 ) ; if ( $inputs . length === 1 ) { return identity ( { inputs : { x : $inputs [ 0 ] } , backend } ) ; } const shapes = $inputs . map ( t => t . shape ) ; backend_util . assertParamsConsistent ( shapes , $axis ) ; return concatImpl ( $inputs , $axis , backend ) ; } export const concatConfig = { kernelName : Concat , backendName : 'webgl' , kernelFunc : concat as { } as KernelFunc } ;