(
gpgpu: GPGPUContext, program: GPGPUProgram, inputs: TensorData[],
output: TensorData)
| 82 | } |
| 83 | |
| 84 | export function compileProgram<T extends Tensor, K extends Tensor>( |
| 85 | gpgpu: GPGPUContext, program: GPGPUProgram, inputs: TensorData[], |
| 86 | output: TensorData): GPGPUBinary { |
| 87 | const inputInfos: InputInfo[] = inputs.map((input, i) => { |
| 88 | const shapeInfo: ShapeInfo = { |
| 89 | logicalShape: input.shape, |
| 90 | texShape: input.isUniform ? null : input.texData.texShape, |
| 91 | isUniform: input.isUniform, |
| 92 | isPacked: input.isUniform ? false : input.texData.isPacked, |
| 93 | flatOffset: null |
| 94 | }; |
| 95 | if (input.texData != null && input.texData.slice != null && |
| 96 | input.texData.slice.flatOffset > 0) { |
| 97 | shapeInfo.flatOffset = input.texData.slice.flatOffset; |
| 98 | } |
| 99 | return {name: program.variableNames[i], shapeInfo}; |
| 100 | }); |
| 101 | const inShapeInfos = inputInfos.map(x => x.shapeInfo); |
| 102 | const outShapeInfo: ShapeInfo = { |
| 103 | logicalShape: output.shape, |
| 104 | texShape: output.texData.texShape, |
| 105 | isUniform: false, |
| 106 | isPacked: output.texData.isPacked, |
| 107 | flatOffset: null |
| 108 | }; |
| 109 | const source = shader_compiler.makeShader(inputInfos, outShapeInfo, program); |
| 110 | const fragmentShader = createFragmentShader(gpgpu.gl, source); |
| 111 | const webGLProgram = gpgpu.createProgram(fragmentShader); |
| 112 | |
| 113 | if (!env().get('ENGINE_COMPILE_ONLY')) { |
| 114 | gpgpu.buildVao(webGLProgram); |
| 115 | return { |
| 116 | program, |
| 117 | fragmentShader, |
| 118 | source, |
| 119 | webGLProgram, |
| 120 | inShapeInfos, |
| 121 | outShapeInfo, |
| 122 | ...getUniformLocations(gpgpu, program, webGLProgram) |
| 123 | }; |
| 124 | } else { |
| 125 | return { |
| 126 | program, |
| 127 | fragmentShader, |
| 128 | source, |
| 129 | webGLProgram, |
| 130 | inShapeInfos, |
| 131 | outShapeInfo, |
| 132 | variablesLocations: null, |
| 133 | customUniformLocations: null, |
| 134 | infLoc: null, |
| 135 | nanLoc: null, |
| 136 | outShapeLocation: null, |
| 137 | outShapeStridesLocation: null, |
| 138 | outTexShapeLocation: null |
| 139 | }; |
| 140 | } |
| 141 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…