license import { KernelConfig , KernelFunc , TensorInfo , Transform , TransformAttrs , TransformInputs } from '@tensorflow/tfjs-core' ; import { MathBackendWebGL } from '../backend_webgl' ; import { TransformProgram } from '../transform_gpu' ; export function transform ( args ) { const { inputs , backend , attrs } = args ; const { image , transforms } = inputs ; const { interpolation , fillMode , fillValue , outputShape } = attrs ; const [ batch , imageHeight , imageWidth , numChannels ] = image . shape ; const [ outHeight , outWidth ] = outputShape != null ? outputShape : [ imageHeight , imageWidth ] ; const outShape = [ batch , outHeight , outWidth , numChannels ] as [ number , number , number , number ] ; const program = new TransformProgram ( imageHeight , imageWidth , interpolation , fillMode , fillValue , outShape ) ; return backend . runWebGLProgram ( program , [ image , transforms ] , 'float32' ) ; } export const transformConfig = { kernelName : Transform , backendName : 'webgl' , kernelFunc : transform as { } as KernelFunc } ;