main.es6 864 字节
Newer Older
W
wangqun 已提交
1 2 3 4 5 6 7 8 9 10 11
/* eslint-disable */
/**
 * @file batchnorm主函数
 * @author wangqun
 */
export default `
// start函数
void main(void) {
    // 输出数据
    ivec4 oPos = getOutputTensorPos();
    float o = getValueFromTensorPos_origin(oPos.r, oPos.g, oPos.b, oPos.a);
W
wangqun 已提交
12

W
wangqun 已提交
13
    // 归一化数据
W
wangqun 已提交
14 15 16 17 18 19 20
    vec4 scale = getPixelsFromTexturePos_texture_scale(vec2( float(oPos.g) / float(width_texture_scale), 0.0));
    vec4 bias = getPixelsFromTexturePos_texture_bias(vec2((float(oPos.g)) / float(width_texture_bias), 0.0));
    vec4 mean = getPixelsFromTexturePos_texture_mean(vec2((float(oPos.g)) / float(width_texture_mean), 0.0));
    vec4 variance = getPixelsFromTexturePos_texture_variance(vec2((float(oPos.g)) / float(width_texture_variance), 0.0));

    float x = (o - mean[0]) / sqrt(variance[0] + epsilon);
    float res = scale[0] * x + bias[0];
W
wangqun 已提交
21 22
    setOutput(res);
}
W
wangqun 已提交
23
`;