license import { ClipByValue , ClipByValueAttrs , ClipByValueInputs , env , KernelConfig , KernelFunc , TensorInfo } from '@tensorflow/tfjs-core' ; import { MathBackendWebGL } from '../backend_webgl' ; import { ClipProgram } from '../clip_gpu' ; import { ClipPackedProgram } from '../clip_packed_gpu' ; export function clipByValue ( args ) { const { inputs , backend , attrs } = args ; const { x } = inputs ; const { clipValueMin , clipValueMax } = attrs ; let program ; if ( env ( ) . getBool ( 'WEBGL_PACK_CLIP' ) ) { program = new ClipPackedProgram ( x . shape ) ; } else { program = new ClipProgram ( x . shape ) ; } const customValues = [ [ clipValueMin ] , [ clipValueMax ] ] ; return backend . runWebGLProgram ( program , [ x ] , x . dtype , customValues ) ; } export const clipByValueConfig = { kernelName : ClipByValue , backendName : 'webgl' , kernelFunc : clipByValue as { } as KernelFunc } ;