license import { buffer , KernelConfig , KernelFunc , TensorInfo , Tile , TileAttrs , TileInputs , TypedArray , util } from '@tensorflow/tfjs-core' ; import { MathBackendWebGL } from '../backend_webgl' ; import { tileImplCPU } from '../kernel_utils/shared' ; import { TileProgram } from '../tile_gpu' ; export function tile ( params ) { const { inputs , backend , attrs } = params ; const { x } = inputs ; const { reps } = attrs ; if ( x . dtype === 'string' || x . shape . length > 5 ) { const data = backend . readSync ( x . dataId ) ; const value = x . dtype === 'string' ? ( data as Uint8Array [ ] ) . map ( d => util . decodeString ( d ) ) : data as TypedArray ; const buf = buffer ( x . shape , x . dtype , value ) ; const outBuf = tileImplCPU ( buf , reps ) ; return backend . makeTensorInfo ( outBuf . shape , outBuf . dtype , outBuf . values ) ; } const program = new TileProgram ( x . shape , reps ) ; const output = backend . runWebGLProgram ( program , [ x ] , x . dtype ) ; return output ; } export const tileConfig = { kernelName : Tile , backendName : 'webgl' , kernelFunc : tile as { } as KernelFunc , } ;