license import { KernelConfig , KernelFunc , Maximum } from '@tensorflow/tfjs-core' ; import { CHECK_NAN_SNIPPET } from '../binaryop_gpu' ; import { CHECK_NAN_SNIPPET as CHECK_NAN_SNIPPET_PACKED } from '../binaryop_packed_gpu' ; import { binaryKernelFunc } from '../kernel_utils/kernel_funcs_utils' ; import { maximumImplCPU } from '../kernel_utils/shared' ; const MAXIMUM = CHECK_NAN_SNIPPET + `
  return max(a, b);
` ; const MAXIMUM_PACKED = `
  vec4 result = vec4(max(a, b));
  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
  ` + CHECK_NAN_SNIPPET_PACKED + `
  return result;
` ; export const maximum = binaryKernelFunc ( { opSnippet : MAXIMUM , packedOpSnippet : MAXIMUM_PACKED , cpuKernelImpl : maximumImplCPU } ) ; export const maximumConfig = { kernelName : Maximum , backendName : 'webgl' , kernelFunc : maximum as { } as KernelFunc } ;