license import { GPGPUProgram } from './gpgpu_math' ; export class OneHotProgram implements GPGPUProgram { variableNames = [ 'indices' ] ; outputShape : number [ ] ; userCode : string ; seedLoc : WebGLUniformLocation ; constructor ( numIndices , depth , onValue , offValue ) { this . outputShape = [ numIndices , depth ] ; this . userCode = `
      void main() {
        ivec2 coords = getOutputCoords();
        int index = round(getIndices(coords.x));
        setOutput(mix(float(${ offValue }), float(${ onValue }),
                      float(index == coords.y)));
      }
    ` ; } }