license import { RealDiv } from '@tensorflow/tfjs-core' ; import { KernelConfig } from '@tensorflow/tfjs-core' ; import { binaryKernelFunc } from '../kernel_utils/kernel_funcs_utils' ; const DIV = `
if (a == b) {
  return 1.0;
};
return a / b;` ; const DIV_PACKED = `
  // vec4 one = vec4(equal(a, b));
  // return one + (vec4(1.0) - one) * a / b;
  vec4 result = a / b;
  if(a.x == b.x) {
    result.x = 1.;
  }
  if(a.y == b.y) {
    result.y = 1.;
  }
  if(a.z == b.z) {
    result.z = 1.;
  }
  if(a.w == b.w) {
    result.w = 1.;
  }

  return result;
` ; export const realDiv = binaryKernelFunc ( { opSnippet : DIV , packedOpSnippet : DIV_PACKED , checkOutOfBounds : true } ) ; export const realDivConfig = { kernelName : RealDiv , backendName : 'webgl' , kernelFunc : realDiv , } ;