license import { backend_util , BackendValues , DataType , TypedArray , util } from '@tensorflow/tfjs-core' ; export function concatImpl ( inputs , outShape , dtype , simplyConcat ) { const outVals = util . getArrayFromDType ( dtype , util . sizeFromShape ( outShape ) ) ; if ( simplyConcat && dtype !== 'string' ) { let offset = 0 ; inputs . forEach ( input => { const size = util . sizeFromShape ( input . shape ) ; ( outVals as TypedArray ) . set ( input . vals as TypedArray , offset ) ; offset += size ; } ) ; } else { let colOffset = 0 ; inputs . forEach ( input => { const decodedData = dtype === 'string' ? backend_util . fromUint8ToStringArray ( input . vals as Uint8Array [ ] ) : input . vals as TypedArray ; let tIdx = 0 ; for ( let row = 0 ; row < input . shape [ 0 ] ; ++ row ) { const resIdx = row * outShape [ 1 ] + colOffset ; for ( let col = 0 ; col < input . shape [ 1 ] ; ++ col ) { outVals [ resIdx + col ] = decodedData [ tIdx ++ ] ; } } colOffset += input . shape [ 1 ] ; } ) ; } return outVals ; }